svn:keywords
[plewww.git] / planetlab / nodes / setting_action.php
1 <?php
2
3 // $Id$
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api;
11
12 /*
13 // Print header
14 require_once 'plc_drupal.php';
15 drupal_set_title('Slices');
16 include 'plc_header.php';
17 */
18
19 // Common functions
20 require_once 'plc_functions.php';
21 require_once 'plc_sorts.php';
22
23 // find person roles
24 $_person= $plc->person;
25 $_roles= $_person['role_ids'];
26
27 //plc_debug('GET',$_GET);
28 //plc_debug('POST',$_POST);
29
30 // tag type updates
31 if( $_POST['edit_type'] ) {
32   $setting_type_id= intval( $_POST['interface_tag_type_id'] );
33   $setting_type = array ('category' => $_POST['category'],
34                          'name' => $_POST['name'],
35                          'min_role_id' => intval( $_POST['min_role_id'] ),
36                          'description' => $_POST['description']);
37   
38   // Update it!
39   $api->UpdateTagType( $setting_type_id, $setting_type );
40   $api_error=$api->error();
41   if (!empty($api_error)) {
42     print "<div class='plc-error'>" . $api_error . "</div>";
43   }
44   
45   header( "location: settings.php" );
46   exit();
47 }
48
49 // tag type adds
50 if( $_POST['add_type'] ) {
51   $setting_type = array ('category' => $_POST['category'],
52                          'name' => $_POST['name'],
53                          'min_role_id' => intval( $_POST['min_role_id'] ),
54                          'description' => $_POST['description']);
55   // add it!!
56   $api->AddTagType( $setting_type );
57
58   header( "location: settings.php" );
59   exit();
60 }
61   
62
63 // tag deletion
64 if( $_GET['rem_id'] ) {
65   // get the id of the tag to remove from GET
66   $setting_id= intval( $_GET['rem_id'] );
67
68   // get interface_id 
69   $setting= $api->GetInterfaceTags( array( $setting_id ), array( "interface_id" ) );
70   $interface_id= $setting[0]['interface_id'];
71   
72   // delete the tag
73   $api->DeleteInterfaceTag( $setting_id );
74
75   header( "location: interfaces.php?id=$interface_id" );
76   exit();
77 }
78
79 // tag adds
80 if( $_POST['add_setting'] ) {
81   // get the interface_id, tag_type_id, and value from POST
82   $interface_id= intval( $_POST['interface_id'] );
83   $interface_tag_type_id= intval( $_POST['interface_tag_type_id'] );
84   $value= $_POST['value'];
85
86   // add it!
87   $api->AddInterfaceTag( $interface_id, $interface_tag_type_id, $value );
88
89   header( "location: interfaces.php?id=$interface_id" );
90   exit();
91 }
92
93 // tag updates
94 if( $_POST['edit_setting'] ) {
95   // get the id of the setting to update and the value from POST
96   $setting_id= intval( $_POST['setting_id'] );
97   $value= $_POST['value'];
98   $interface_id= $_POST['interface_id'];
99
100   // update it!
101   $api->UpdateInterfaceTag($setting_id, $value );
102
103   header( "location: interfaces.php?id=$interface_id" );
104   exit();
105 }
106
107 // Settings -------------------------------------------------
108
109 // TAG TYPES ---------------------------------------------------
110   
111 // delete tag types
112 if( $_GET['del_type'] ) {
113   // get vars
114   $type_id= intval( $_GET['del_type'] );
115
116   // delete it!
117   $api->DeleteTagType( $type_id );
118   
119   header( "location: settings.php" );
120   exit();
121 }
122   
123 /*
124 // Print footer
125 include 'plc_footer.php';
126 */
127
128 ?>