details can be updated inline - old forms still to be cleaned up
[plewww.git] / planetlab / tags / tags.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 'plc_minitabs.php';
19 require_once 'plc_tables.php';
20 require_once 'plc_forms.php';
21
22 // -------------------- 
23 // recognized URL arguments
24 $pattern=$_GET['pattern'];
25
26 // --- decoration
27 $title="Tag Types";
28 $tabs=array();
29 $tabs['New Tag Type']=array('url'=>l_tag_add(),'bubble'=>"Create a new tag type");
30 $tabs['All Nodes']=array('url'=>l_nodes(),'bubble'=>"Nodes from all peers");
31 $tabs['Local Nodes']=array('url'=>l_nodes(),'values'=>array('peerscope'=>'local'),'bubble'=>"All local nodes");
32 //$tabs['Interfaces']=l_interfaces();
33 $tabs['All Slices']=array('url'=>l_slices(),'bubble'=>"Slices from all peers");
34
35 // -------------------- 
36 drupal_set_title($title);
37 plc_tabs($tabs);
38
39 $tag_type_columns = array( "tag_type_id", "tagname", "category", "description", "min_role_id" );
40
41 $tag_type_filter=NULL;
42 if ($pattern) 
43   $tag_type_filter['category']=$pattern;
44
45 // get types
46 $tag_types= $api->GetTagTypes($tag_type_filter, $tag_type_columns);
47   
48 $headers=array();
49 // delete button
50 if (plc_is_admin()) $headers[' ']="none";
51 $headers["Id"]="int";
52 $headers['Name']="string";
53 $headers['Description']="string";
54 $headers['Min role']="string";
55 $headers['Category']="string";
56
57 $table = new PlcTable("tags",$headers,1);
58 $table->start();
59
60 $roles_hash=plc_role_global_hash($api);
61
62 foreach( $tag_types as $tag_type ) {
63   $role_name=$roles_hash[$tag_type['min_role_id']];
64
65   $table->row_start();
66   $id=$tag_type['tag_type_id'];
67   if (plc_is_admin()) 
68     // xxx this is deprecated
69     $table->cell(plc_delete_link_button ('tag_action.php?del_type='. $id,
70                                            $tag_type['tagname']));
71   $table->cell($id);
72   $table->cell(href(l_tag_update($id),$tag_type['tagname']));
73   $table->cell(wordwrap($tag_type['description'],40,"<br/>"));
74   $table->cell($role_name);
75   $table->cell($tag_type['category']);
76   $table->row_end();
77 }
78 if (plc_is_admin()) {
79   $table->tfoot_start();
80   $table->row_start();
81   $button=new PlcFormButton(l_tag_add(),"add_type_id","Add a Tag Type","GET");
82   $table->cell ($button->html(), $table->columns(),"right");
83   $table->row_end();
84  }
85
86 $table->end();
87
88 // Print footer
89 include 'plc_footer.php';
90
91 ?>