towards 5.0
[plewww.git] / planetlab / nodes / setting_action.php
1 <?php
2
3 // $Id: setting_action.php 1159 2008-01-24 18:51:36Z thierry $
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 // attribute type updates
31 if( $_POST['edit_type'] ) {
32   $setting_type_id= intval( $_POST['interface_setting_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->UpdateInterfaceSettingType( $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 // attribute 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->AddInterfaceSettingType( $setting_type );
57
58   header( "location: settings.php" );
59   exit();
60 }
61   
62
63 // attribute deletion
64 if( $_GET['rem_id'] ) {
65   // get the id of the attrib to remove from GET
66   $setting_id= intval( $_GET['rem_id'] );
67
68   // get interface_id 
69   $setting= $api->GetInterfaceSettings( array( $setting_id ), array( "interface_id" ) );
70   $interface_id= $setting[0]['interface_id'];
71   
72   // delete the attribute
73   $api->DeleteInterfaceSetting( $setting_id );
74
75   header( "location: node_networks.php?id=$interface_id" );
76   exit();
77 }
78
79 // attribute adds
80 if( $_POST['add_setting'] ) {
81   // get the interface_id, attribute_type_id, and value from POST
82   $interface_id= intval( $_POST['interface_id'] );
83   $interface_setting_type_id= intval( $_POST['interface_setting_type_id'] );
84   $value= $_POST['value'];
85
86   // add it!
87   $api->AddInterfaceSetting( $interface_id, $interface_setting_type_id, $value );
88
89   header( "location: node_networks.php?id=$interface_id" );
90   exit();
91 }
92
93 // attribute 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->UpdateInterfaceSetting($setting_id, $value );
102
103   header( "location: node_networks.php?id=$interface_id" );
104   exit();
105 }
106
107 // down here is some codqe from attrib_action.php that was not converted yet
108 // Settings -------------------------------------------------
109
110 // ATTRIBUTE TYPES ---------------------------------------------------
111   
112 // delete attribute types
113 if( $_GET['del_type'] ) {
114   // get vars
115   $type_id= intval( $_GET['del_type'] );
116
117   // delete it!
118   $api->DeleteInterfaceSettingType( $type_id );
119   
120   header( "location: settings.php" );
121   exit();
122 }
123
124   
125   
126 /*
127 // Print footer
128 include 'plc_footer.php';
129 */
130
131 ?>