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');
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->th_td("Name",$tagname,"tagname");
63 $details->th_td("Category",$category,"category");
64 $details->th_td("Description",$description,"description");
67 // select the option corresponding with min_role_id
68 $selectors = $details->form()->role_selectors($api,"",$min_role_id);
69 $select_field = $details->form()->select_html("min_role_id",$selectors);
70 // xxx would need to turn role_id into role name
71 $details->th_td("Min role",$select_field,"min_role_id",array('input_type'=>'select','value'=>$min_role_id));
73 $details->th_td("Min role",$min_role_id);
76 $details->tr_submit('update-tag-type',"Update tag type");
79 $details->th_td("Used in nodes",count($node_tags));
80 $details->th_td("Used in interfaces",count($interface_tags));
81 $details->th_td("Used in slices",count($slice_tags));
82 $details->th_td("Used in slivers",count($sliver_tags));
87 // common options for tables below
88 $table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'search_width'=>10);
90 // xxx could outline values corresponding to a nodegroup
91 if (count ($node_tags)) {
93 $table=new PlcTable ("tag_nodes",array("Hostname"=>"string","value"=>"string"),0,$table_options);
95 foreach ($node_tags as $node_tag) {
97 $table->cell(href(l_node($node_tag['node_id']),$node_tag['hostname']));
98 $table->cell($node_tag['value']);
104 if (count ($interface_tags)) {
105 plc_section("Interfaces");
106 $table=new PlcTable ("tag_interfaces",array("IP"=>"IPAddress","value"=>"string"),0,$table_options);
108 foreach ($interface_tags as $interface_tag) {
110 $table->cell(href(l_interface($interface_tag['interface_id']),$interface_tag['ip']));
111 $table->cell($interface_tag['value']);
117 // grouping both kinds of slice tags
118 // xxx don't show hostnames yet
119 $slice_tags = array_merge ($slice_tags,$sliver_tags);
120 if (count ($slice_tags)) {
121 plc_section("Slice and sliver tags");
122 $table=new PlcTable ("tag_slices",array("Slice"=>"string","value"=>"string","Node id"=>"int"),0,$table_options);
124 foreach ($slice_tags as $slice_tag) {
126 $table->cell(href(l_slice($slice_tag['slice_id']),$slice_tag['name']));
127 $table->cell($slice_tag['value']);
130 if ($slice_tag['node_id'])
131 $node_text=l_node($slice_tag['node_id'],$slice_tag['node_id']);
132 $table->cell($node_text);
139 include 'plc_footer.php';