renaming SliceAttribute into SliceTag and InterfaceSetting into InterfaceTag
[plewww.git] / planetlab / slices / attrib_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 // ATTRIBUTES -------------------------------------------------
27
28 // attribute deletion
29 if( $_GET['rem_id'] ) {
30   // get the id of the attrib to remove from GET
31   $attribute_id= intval( $_GET['rem_id'] );
32
33   // get slice_id 
34   $attrib_info= $api->GetSliceTags( array( $attribute_id ), array( "slice_id" ) );
35   $slice_id= $attrib_info[0]['slice_id'];
36   
37   // delete the attribute
38   $api->DeleteSliceTag( $attribute_id );
39
40
41   header( "location: index.php?id=$slice_id" );
42   exit();
43 }
44
45
46 // attirbute updates
47 if( $_POST['edit_attribute'] ) {
48   // get the id of the attrib to update and teh value from POST
49   $attribute_id= intval( $_POST['attribute_id'] );
50   $value= $_POST['value'];
51   $slice_id= $_POST['slice_id'];
52
53   // update it!
54   $api->UpdateSliceTag( $attribute_id, $value );
55
56   header( "location: index.php?id=$slice_id" );
57   exit();
58 }
59
60
61 // attribute adds
62 if( $_POST['add_attribute'] ) {
63   // get the slice_id, attribute_type_id, and value from POST
64   $slice_id= intval( $_POST['slice_id'] );
65   $attribute_type_id= intval( $_POST['attribute_type_id'] );
66   $value= $_POST['value'];
67
68   // add it!
69   $api->AddSliceTag( $slice_id, $attribute_type_id, $value );
70
71   header( "location: index.php?id=$slice_id" );
72   exit();
73 }
74
75 // ATTRIBUTE TYPES ---------------------------------------------------
76   
77 // attribute 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 attribute_type_fields dict
85   $attribute_type_fields= array( "min_role_id" => $min_role_id, "name" => $name, "description" => $description );
86   
87   // add it!!
88   $api->AddSliceTagType( $attribute_type_fields );
89
90   header( "location: attributes.php" );
91   exit();
92 }
93   
94
95 // attribute type updates
96 if( $_POST['edit_type'] ) {
97   // get post vars 
98   $name= $_POST['name'];
99   $min_role_id= intval( $_POST['min_role_id'] );
100   $description= $_POST['description'];  
101   $attribute_type_id= intval( $_POST['attribute_type_id'] );
102   
103   // make attribute_type_fields dict
104   $attribute_type_fields= array( "min_role_id" => $min_role_id, "name" => $name, "description" => $description );
105
106   // Update it!
107   $api->UpdateSliceTagType( $attribute_type_id, $attribute_type_fields );
108   
109   header( "location: attributes.php" );
110   exit();
111 }
112
113
114 // delete attribute types
115 if( $_GET['del_type'] ) {
116   // get vars
117   $type_id= intval( $_GET['del_type'] );
118
119   // delete it!
120   $api->DeleteSliceTagType( $type_id );
121   
122   header( "location: attributes.php" );
123   exit();
124 }
125
126   
127   
128 /*
129 // Print footer
130 include 'plc_footer.php';
131 */
132
133 ?>