brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / tags / tag_set.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 // Print header
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
15
16 // Common functions
17 require_once 'plc_functions.php';
18 require_once 'linetabs.php';
19 require_once 'table.php';
20
21 drupal_set_message ("xxx tag_set.php is deprecated - use planetlab/actions.php instead");
22 return;
23
24
25   // get slice id from GET
26   $slice_id= intval( get_array($_GET, 'add') );
27   
28   // get all tag types 
29   $tag_types= $api->GetTagTypes( $tag_type_filter , array( "tag_type_id", "tagname" ) );
30   
31   foreach( $tag_types as $tag_type ) {
32     $all_tags[$tag_type['tag_type_id']]= $tag_type['tagname'];
33   }
34   
35   // get slice's tag types
36   $slice_info= $api->GetSlices( array( $slice_id ), array( "slice_tag_ids" ) );
37   $tag_info= $api->GetSliceTags( $slice_info[0]['slice_tag_ids'], array( "tag_type_id", "tagname" ) );
38   
39   foreach( $tag_info as $info ) {
40     $slice_tag_types[$info['tag_type_id']]= $info['tagname'];
41   }
42
43
44     $tag_types= $all_tags;
45   
46   // start form
47   echo "<form action='tag_action.php' method='post'>\n";
48   echo "<h2>Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."</h2>\n";
49   
50   echo "<select name='tag_type_id'><option value=''>Choose a type to add</option>\n";
51   
52   foreach( $tag_types as $key => $val ) {
53     echo "<option value='". $key ."'>". $val ."</option>\n";
54   
55   }
56   echo "</select>\n";
57   
58   echo "<p><span class='bold'>Value: </span><input type=text name='value'>\n";
59   
60   echo "<p><input type=submit name='add_tag' value='Add Tag'>\n";
61   echo "<input type=hidden name='slice_id' value='$slice_id'>\n";
62   echo "</form>\n";
63   
64 }
65 else {
66   $tag_id= intval( get_array($_GET, 'id') );
67   
68   // get tag
69   $slice_tag= $api->GetSliceTags( array( $tag_id ), array( "slice_id", "slice_tag_id", "tag_type_id", "value", "description", "min_role_id" ) );
70   
71   // get type info 
72   $tag_type= $api->GetTagTypes( array( $slice_tag[0]['tag_type_id'] ), array( "tag_type_id", "tagname", "description" ) );
73   
74   // slice info
75   $slice_info= $api->GetSlices( array( $slice_tag[0]['slice_id'] ), array( "name" ) );
76   
77   // start form and put values in to be edited.
78   echo "<form action='tag_action.php' method='post'>\n";
79   echo "<h2>Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."</h2>\n";
80   
81   echo $slice_tag[0]['description'] ."<br />\n";
82   echo "<span class='bold'>Value:</span> <input type=text name=value value='". $slice_tag[0]['value'] ."'><br /><br />\n";
83   
84   echo "<input type=submit value='Edit Tag' name='edit_tag'>\n";
85   echo "<input type=hidden name='slice_id' value='". $slice_tag[0]['slice_id'] ."'>\n";
86   echo "<input type=hidden name='tag_id' value='". $tag_id ."'>\n";
87   echo "</form>\n";
88   
89 }
90
91 // Print footer
92 include 'plc_footer.php';
93
94 ?>