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 'linetabs.php';
19 require_once 'details.php';
20 require_once 'table.php';
21 require_once 'form.php';
22 require_once 'toggle.php';
24 // --------------------
25 // recognized URL arguments
26 $tag_type_id=intval($_GET['id']);
27 if ( ! $tag_type_id ) {
28 plc_error('Malformed URL - id not set');
37 // --------------------
38 $tag_types= $api->GetTagTypes( array( $tag_type_id ) );
39 $tag_type=$tag_types[0];
41 $tagname=$tag_type['tagname'];
42 $min_role_id= $tag_type['min_role_id'];
43 $description= $tag_type['description'];
44 $category=$tag_type['category'];
47 $filter=array('tag_type_id'=>$tag_type_id);
48 $node_tags=$api->GetNodeTags($filter);
49 $interface_tags=$api->GetInterfaceTags($filter);
50 $slice_tags=$api->GetSliceTags(array_merge($filter,array("node_id"=>array())));
51 $sliver_tags=$api->GetSliceTags(array_merge($filter,array("~node_id"=>array())));
53 drupal_set_title("Details for tag type $tagname");
54 plekit_linetabs($tabs);
57 $can_update=plc_is_admin();
58 $details=new PlekitDetails ($can_update);
60 $details->form_start(l_actions(),array("action"=>"update-tag-type",
61 "tag_type_id"=>$tag_type_id));
63 $details->th_td("Name",$tagname,"tagname");
64 $details->th_td("Category",$category,"category");
65 $details->th_td("Description",$description,"description");
68 // select the option corresponding with min_role_id
69 $selectors = $details->form()->role_selectors($api,"",$min_role_id);
70 $select_field = $details->form()->select_html("min_role_id",$selectors);
71 // xxx would need to turn role_id into role name
72 $details->th_td("Min role",$select_field,"min_role_id",array('input_type'=>'select','value'=>$min_role_id));
74 $details->th_td("Min role",$min_role_id);
77 $details->tr_submit('update-tag-type',"Update tag type");
80 $details->th_td("Used in nodes",count($node_tags));
81 $details->th_td("Used in interfaces",count($interface_tags));
82 $details->th_td("Used in slices",count($slice_tags));
83 $details->th_td("Used in slivers",count($sliver_tags));
88 // common options for tables below
89 $table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'search_width'=>10);
91 // xxx could outline values corresponding to a nodegroup
92 if (count ($node_tags)) {
93 $toggle=new PlekitToggle('tag_nodes',"Nodes");
95 $table=new PlekitTable ("tag_nodes",array("Hostname"=>"string","value"=>"string"),0,$table_options);
97 foreach ($node_tags as $node_tag) {
99 $table->cell(href(l_node($node_tag['node_id']),$node_tag['hostname']));
100 $table->cell($node_tag['value']);
107 if (count ($interface_tags)) {
108 $toggle=new PlekitToggle('tag_interfaces',"Interfaces");
110 $table=new PlekitTable ("tag_interfaces",array("IP"=>"IPAddress","value"=>"string"),0,$table_options);
112 foreach ($interface_tags as $interface_tag) {
114 $table->cell(href(l_interface($interface_tag['interface_id']),$interface_tag['ip']));
115 $table->cell($interface_tag['value']);
122 // grouping both kinds of slice tags
123 // xxx don't show hostnames yet
124 $slice_tags = array_merge ($slice_tags,$sliver_tags);
125 if (count ($slice_tags)) {
126 $toggle=new PlekitToggle('tag_slices',"Slice and sliver tags");
128 $table=new PlekitTable ("tag_slices",array("Slice"=>"string","value"=>"string","Node id"=>"int"),0,$table_options);
130 foreach ($slice_tags as $slice_tag) {
132 $table->cell(href(l_slice($slice_tag['slice_id']),$slice_tag['name']));
133 $table->cell($slice_tag['value']);
136 if ($slice_tag['node_id'])
137 $node_text=l_node($slice_tag['node_id'],$slice_tag['node_id']);
138 $table->cell($node_text);
145 //plekit_linetabs ($tabs,"bottom");
148 include 'plc_footer.php';