brute-force changed access to $_GET['key'] to use get_array instead
[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
20 // find person roles
21 $_person= $plc->person;
22 $_roles= $_person['role_ids'];
23
24
25 drupal_set_message ("xxx tag_action.php is deprecated - use planetlab/actions.php instead");
26 return;
27
28
29 // TAGS -------------------------------------------------
30
31 // tag deletion
32 if( get_array($_GET, 'rem_id') ) {
33   // get the id of the tag to remove from GET
34   $tag_id= intval( get_array($_GET, 'rem_id') );
35
36   // get slice_id 
37   $tag_info= $api->GetSliceTags( array( $tag_id ), array( "slice_id" ) );
38   $slice_id= $tag_info[0]['slice_id'];
39   
40   // delete the tag
41   $api->DeleteSliceTag( $tag_id );
42
43   plc_redirect( "index.php?id=$slice_id" );
44 }
45
46
47 // tag updates
48 if( $_POST['edit_tag'] ) {
49   // get the id of the tag to update and the value from POST
50   $tag_id= intval( $_POST['tag_id'] );
51   $value= $_POST['value'];
52   $slice_id= $_POST['slice_id'];
53
54   // update it!
55   $api->UpdateSliceTag( $tag_id, $value );
56
57   plc_redirect( "index.php?id=$slice_id" );
58 }
59
60
61 // tag adds
62 if( $_POST['add_tag'] ) {
63   // get the slice_id, tag_type_id, and value from POST
64   $slice_id= intval( $_POST['slice_id'] );
65   $tag_type_id= intval( $_POST['tag_type_id'] );
66   $value= $_POST['value'];
67
68   // add it!
69   $api->AddSliceTag( $slice_id, $tag_type_id, $value );
70
71   plc_redirect( "index.php?id=$slice_id" );
72 }
73
74 // TAG TYPES ---------------------------------------------------
75   
76 // tag type adds
77 if( $_POST['add_type'] ) {
78   // get post vars 
79   $name= $_POST['name'];
80   $min_role_id= intval( $_POST['min_role_id'] );
81   $description= $_POST['description'];
82   
83   // make the tag_type_fields dict
84   // xxx misses category
85   $tag_type_fields= array( "min_role_id" => $min_role_id, 
86                            "tagname" => $name, 
87                            "description" => $description );
88   
89   // add it!!
90   $api->AddTagType( $tag_type_fields );
91
92   plc_redirect( "tags.php?type=slice" );
93 }
94   
95
96 // tag type updates
97 if( $_POST['edit_type'] ) {
98   // get post vars 
99   $name= $_POST['name'];
100   $min_role_id= intval( $_POST['min_role_id'] );
101   $description= $_POST['description'];  
102   $tag_type_id= intval( $_POST['tag_type_id'] );
103   
104   // make tag_type_fields dict
105   $tag_type_fields= array( "min_role_id" => $min_role_id, "tagname" => $name, "description" => $description );
106
107   // Update it!
108   $api->UpdateTagType( $tag_type_id, $tag_type_fields );
109   
110   plc_redirect( "tags.php?type=slice" );
111 }
112
113
114 /*
115 // Print footer
116 include 'plc_footer.php';
117 */
118
119 ?>