6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_minitabs.php';
19 require_once 'plc_details.php';
20 require_once 'plc_tables.php';
21 require_once 'plc_forms.php';
23 // --------------------
24 // recognized URL arguments
25 $tag_type_id=intval($_GET['id']);
26 if ( ! $tag_type_id ) {
27 plc_error('Malformed URL - id not set');
34 $tabs['All Types']=array('url'=>l_tags(),'bubble'=>"All Tag Types");
36 // --------------------
37 $tag_types= $api->GetTagTypes( array( $tag_type_id ) );
38 $tag_type=$tag_types[0];
40 $tagname=$tag_type['tagname'];
41 $min_role_id= $tag_type['min_role_id'];
42 $description= $tag_type['description'];
43 $category=$tag_type['category'];
46 $filter=array('tag_type_id'=>$tag_type_id);
47 $node_tags=$api->GetNodeTags($filter);
48 $interface_tags=$api->GetInterfaceTags($filter);
49 $slice_tags=$api->GetSliceTags(array_merge($filter,array("node_id"=>array())));
50 $sliver_tags=$api->GetSliceTags(array_merge($filter,array("~node_id"=>array())));
52 drupal_set_title("Details for tag type $tagname");
56 $can_update=plc_is_admin();
57 $details=new PlcDetails ($can_update);
59 $details->form_start(l_actions(),array("action"=>"update-tag-type",
60 "tag_type_id"=>$tag_type_id));
62 $details->line("Name",$tagname,"tagname");
63 $details->line("Category",$category,"category");
64 $details->line("Description",$description,"description");
66 // xxx misses in PlcDetails
69 // select the option corresponding with min_role_id
70 $selectors = $details->form()->role_selectors($api,"",$min_role_id);
71 $select_field = $details->form()->select_html("min_role_id",$selectors);
72 $save_i=$details->set_input_type("select");
73 $details->line("Min role",$select_field,"min_role_id");
74 $details->set_input_type($save_i);
76 $details->line("Min role",$min_role_id);
79 $details->single($details->form()->submit_html('update-tag-type',"Update tag type"),"right");
82 $details->line("Used in nodes",count($node_tags));
83 $details->line("Used in interfaces",count($interface_tags));
84 $details->line("Used in slices",count($slice_tags));
85 $details->line("Used in slivers",count($sliver_tags));
90 // common options for tables below
91 $table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'search_width'=>10);
93 // xxx could outline values corresponding to a nodegroup
94 if (count ($node_tags)) {
96 $table=new PlcTable ("tag_nodes",array("Hostname"=>"string","value"=>"string"),0,$table_options);
98 foreach ($node_tags as $node_tag) {
100 $table->cell(href(l_node($node_tag['node_id']),$node_tag['hostname']));
101 $table->cell($node_tag['value']);
107 if (count ($interface_tags)) {
108 plc_section("Interfaces");
109 $table=new PlcTable ("tag_interfaces",array("IP"=>"IPAddress","value"=>"string"),0,$table_options);
111 foreach ($interface_tags as $interface_tag) {
113 $table->cell(href(l_interface($interface_tag['interface_id']),$interface_tag['ip']));
114 $table->cell($interface_tag['value']);
120 // grouping both kinds of slice tags
121 // xxx don't show hostnames yet
122 $slice_tags = array_merge ($slice_tags,$sliver_tags);
123 if (count ($slice_tags)) {
124 plc_section("Slice and sliver tags");
125 $table=new PlcTable ("tag_slices",array("Slice"=>"string","value"=>"string","Node id"=>"int"),0,$table_options);
127 foreach ($slice_tags as $slice_tag) {
129 $table->cell(href(l_slice($slice_tag['slice_id']),$slice_tag['name']));
130 $table->cell($slice_tag['value']);
133 if ($slice_tag['node_id'])
134 $node_text=l_node($slice_tag['node_id'],$slice_tag['node_id']);
135 $table->cell($node_text);
142 include 'plc_footer.php';