ckp
[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 // TAGS -------------------------------------------------
27
28 // tag deletion
29 if( $_GET['rem_id'] ) {
30   // get the id of the tag to remove from GET
31   $tag_id= intval( $_GET['rem_id'] );
32
33   // get slice_id 
34   $tag_info= $api->GetSliceTags( array( $tag_id ), array( "slice_id" ) );
35   $slice_id= $tag_info[0]['slice_id'];
36   
37   // delete the tag
38   $api->DeleteSliceTag( $tag_id );
39
40
41   header( "location: index.php?id=$slice_id" );
42   exit();
43 }
44
45
46 // tag updates
47 if( $_POST['edit_tag'] ) {
48   // get the id of the tag to update and the value from POST
49   $tag_id= intval( $_POST['tag_id'] );
50   $value= $_POST['value'];
51   $slice_id= $_POST['slice_id'];
52
53   // update it!
54   $api->UpdateSliceTag( $tag_id, $value );
55
56   header( "location: index.php?id=$slice_id" );
57   exit();
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   header( "location: index.php?id=$slice_id" );
72   exit();
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   header( "location: tags.php?type=slice" );
94   exit();
95 }
96   
97
98 // tag type updates
99 if( $_POST['edit_type'] ) {
100   // get post vars 
101   $name= $_POST['name'];
102   $min_role_id= intval( $_POST['min_role_id'] );
103   $description= $_POST['description'];  
104   $tag_type_id= intval( $_POST['tag_type_id'] );
105   
106   // make tag_type_fields dict
107   $tag_type_fields= array( "min_role_id" => $min_role_id, "tagname" => $name, "description" => $description );
108
109   // Update it!
110   $api->UpdateTagType( $tag_type_id, $tag_type_fields );
111   
112   header( "location: tags.php?type=slice" );
113   exit();
114 }
115
116
117 // delete tag types
118 if( $_GET['del_type'] ) {
119   // get vars
120   $type_id= intval( $_GET['del_type'] );
121
122   // delete it!
123   $api->DeleteTagType( $type_id );
124   
125   header( "location: tags.php?type=slice" );
126   exit();
127 }
128
129   
130   
131 /*
132 // Print footer
133 include 'plc_footer.php';
134 */
135
136 ?>