redirects
[plewww.git] / planetlab / tags / tag_action.php
1 <?php
2
3 // Require login
4 require_once 'plc_login.php';
5
6 // Get session and API handles
7 require_once 'plc_session.php';
8 global $plc, $api;
9
10 /*
11 // Print header
12 require_once 'plc_drupal.php';
13 drupal_set_title('Slices');
14 include 'plc_header.php';
15 */
16
17 // Common functions
18 require_once 'plc_functions.php';
19 require_once 'plc_sorts.php';
20
21 // find person roles
22 $_person= $plc->person;
23 $_roles= $_person['role_ids'];
24
25
26 drupal_set_message ("xxx tag_action.php is deprecated - use planetlab/actions.php instead");
27 return;
28
29
30 // TAGS -------------------------------------------------
31
32 // tag deletion
33 if( $_GET['rem_id'] ) {
34   // get the id of the tag to remove from GET
35   $tag_id= intval( $_GET['rem_id'] );
36
37   // get slice_id 
38   $tag_info= $api->GetSliceTags( array( $tag_id ), array( "slice_id" ) );
39   $slice_id= $tag_info[0]['slice_id'];
40   
41   // delete the tag
42   $api->DeleteSliceTag( $tag_id );
43
44   plc_redirect( "index.php?id=$slice_id" );
45 }
46
47
48 // tag updates
49 if( $_POST['edit_tag'] ) {
50   // get the id of the tag to update and the value from POST
51   $tag_id= intval( $_POST['tag_id'] );
52   $value= $_POST['value'];
53   $slice_id= $_POST['slice_id'];
54
55   // update it!
56   $api->UpdateSliceTag( $tag_id, $value );
57
58   plc_redirect( "index.php?id=$slice_id" );
59 }
60
61
62 // tag adds
63 if( $_POST['add_tag'] ) {
64   // get the slice_id, tag_type_id, and value from POST
65   $slice_id= intval( $_POST['slice_id'] );
66   $tag_type_id= intval( $_POST['tag_type_id'] );
67   $value= $_POST['value'];
68
69   // add it!
70   $api->AddSliceTag( $slice_id, $tag_type_id, $value );
71
72   plc_redirect( "index.php?id=$slice_id" );
73 }
74
75 // TAG TYPES ---------------------------------------------------
76   
77 // tag type adds
78 if( $_POST['add_type'] ) {
79   // get post vars 
80   $name= $_POST['name'];
81   $min_role_id= intval( $_POST['min_role_id'] );
82   $description= $_POST['description'];
83   
84   // make the tag_type_fields dict
85   // xxx misses category
86   $tag_type_fields= array( "min_role_id" => $min_role_id, 
87                            "tagname" => $name, 
88                            "description" => $description );
89   
90   // add it!!
91   $api->AddTagType( $tag_type_fields );
92
93   plc_redirect( "tags.php?type=slice" );
94 }
95   
96
97 // tag type updates
98 if( $_POST['edit_type'] ) {
99   // get post vars 
100   $name= $_POST['name'];
101   $min_role_id= intval( $_POST['min_role_id'] );
102   $description= $_POST['description'];  
103   $tag_type_id= intval( $_POST['tag_type_id'] );
104   
105   // make tag_type_fields dict
106   $tag_type_fields= array( "min_role_id" => $min_role_id, "tagname" => $name, "description" => $description );
107
108   // Update it!
109   $api->UpdateTagType( $tag_type_id, $tag_type_fields );
110   
111   plc_redirect( "tags.php?type=slice" );
112 }
113
114
115 // delete tag types
116 if( $_GET['del_type'] ) {
117   // get vars
118   $type_id= intval( $_GET['del_type'] );
119
120   // delete it!
121   $api->DeleteTagType( $type_id );
122   
123   plc_redirect( "tags.php?type=slice" );
124 }
125
126   
127   
128 /*
129 // Print footer
130 include 'plc_footer.php';
131 */
132
133 ?>