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 'table.php';
20 require_once 'form.php';
22 // --------------------
23 // recognized URL arguments
24 $pattern=$_GET['pattern'];
31 // --------------------
36 $nodegroup_columns=array("nodegroup_id","groupname","tagname","value","node_ids","tag_type_id");
38 // server-side filtering - set pattern in $_GET for filtering on hostname
40 $nodegroup_filter['groupname']=$pattern;
41 $title .= " matching " . $pattern;
43 $nodegroup_filter['groupname']="*";
47 $nodegroups=$api->GetNodeGroups($nodegroup_filter,$nodegroup_columns);
49 // --------------------
50 drupal_set_title($title);
52 plekit_linetabs($tabs);
54 if ( ! $nodegroups ) {
55 drupal_set_message ('No node group found');
61 $headers['group name']='string';
62 $headers['tag name']='string';
63 $headers['tag value']='string';
64 $headers['# N']='int';
65 $notes []= '# N = number of nodes in the group';
68 if (plc_is_admin()) $headers[plc_delete_icon()]="none";
70 $form=new PlekitForm(l_actions(),NULL);
72 # initial sort on groupname
73 $table=new PlekitTable("nodegroups",$headers,0,array('notes'=>$notes));
76 foreach ($nodegroups as $nodegroup) {
78 $nodegroup_id=$nodegroup['nodegroup_id'];
79 $table->cell (href(l_nodegroup($nodegroup_id),$nodegroup['groupname']));
80 // yes, a nodegroup is not a tag, but knows enough for this to work
81 $table->cell (l_tag_obj($nodegroup));
82 $table->cell ($nodegroup['value']);
83 $table->cell (count($nodegroup['node_ids']));
84 $table->cell ($nodegroup_id);
85 $table->cell ($form->checkbox_html('nodegroup_ids[]',$nodegroup_id));
89 $table->tfoot_start();
92 $table->cell($form->submit_html ("delete-nodegroups","Remove groups"),
93 array('hfill'=>true,'align'=>'right'));
96 // an inline area to add a tag type
99 // build the tagname selector
100 $relevant_tags = $api->GetTagTypes( array("category"=>'*node*'));
101 function selector_argument ($tt) { return array('display'=>$tt['tagname'],"value"=>$tt['tag_type_id']); }
102 $selectors=array_map("selector_argument",$relevant_tags);
103 $tagname_input=$form->select_html("tag_type_id",$selectors,array('label'=>"Tag Name"));
106 $table->cell($form->text_html('groupname',''));
107 $table->cell($tagname_input);
108 $table->cell($form->text_html('value',''));
109 $table->cell($form->submit_html("add-nodegroup","Add"),3);
115 //plekit_linetabs ($tabs,"bottom");
118 include 'plc_footer.php';