X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=planetlab%2Fcommon%2Fadminsearch.php;h=354b17900127954f1341978ed0acfb4c5f11d626;hb=33cb593b9a4b448da73478e3e11d1d3191d8c1b2;hp=c72fbbd2021ade61f796538039ba90299d08521e;hpb=232e3e3ce1e8f07de912ba0d5302b03bfe71f283;p=plewww.git diff --git a/planetlab/common/adminsearch.php b/planetlab/common/adminsearch.php index c72fbbd..354b179 100644 --- a/planetlab/common/adminsearch.php +++ b/planetlab/common/adminsearch.php @@ -18,6 +18,7 @@ include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; require_once 'plc_objects.php'; +require_once 'plc_peers.php'; require_once 'table.php'; require_once 'form.php'; require_once 'toggle.php'; @@ -32,7 +33,11 @@ if ( ! plc_is_admin()) { $pattern=""; if (isset($_GET['pattern'])) { $pattern=$_GET['pattern']; } if (isset($_POST['pattern'])) { $pattern=$_POST['pattern']; } -$tokens=split(" ",$pattern); + +$tokens=explode(" ",$pattern); +function token_filter ($t) { $t = trim($t); if (empty($t)) return false; return true; } +$tokens=array_filter($tokens, "token_filter"); + //////////////////// // from a single search form, extract all tokens entered @@ -51,9 +56,12 @@ function display_form ($pattern) { $toggle->start(); print <<< EOF

-This form searches for any entry in the database matching a name fragment, or token.
-Specifically it searches for persons, slices, sites and nodes.
-You can specify a space-separated list of tokens, all entries matching any token would then get listed. +This form searches for any entry in the database +(among persons, slices, +sites and nodes) +matching a name fragment, or token.
+You can specify a space-separated list of tokens, all entries matching +any token would then get listed.

EOF; print "
"; @@ -77,14 +85,21 @@ function generic_search ($type,$field,$tokens) { global $api; $results=array(); $methodname='Get'.$type; + /* + This was broken after 598e1e840b55262fd40c6d1700148e4f0b508065 change in plcapi. + We no longer generate a list of methods but let the api (php) object pass them through. + if ( ! method_exists($api,$methodname)) { plc_error("generic_search failed with methodname=$methodname"); return $results; } + */ foreach ($tokens as $token) { $filter=array($field=>token_pattern($token)); - $results = - array_merge ($results,$api->$methodname($filter)); + $new_results = $api->$methodname($filter); + if (is_array($new_results)) { + $results = array_merge ($results, $new_results); + } } return $results; } @@ -123,6 +138,9 @@ function plc_node_link ($node_id) {global $nodes_hash; return l_node_obj($nodes_ global $table_options; $table_options = array('notes_area'=>false); +global $peers; +$peers = new Peers ($api); + function display_persons ($persons,$visible) { if ( ! $persons) return; @@ -130,16 +148,19 @@ function display_persons ($persons,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'email'=>'string', 'sites'=>'string', 'slices'=>'string', 'roles'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('persons',$headers,1,$table_options); $table->start(); foreach ($persons as $person) { $table->row_start(); $table->cell($person['person_id']); + $peers->cell($table,$person['peer_id']); $table->cell(l_person_obj($person)); $table->cell(plc_vertical_table(array_map("plc_site_link",$person['site_ids']))); $table->cell(plc_vertical_table(array_map("plc_slice_link",$person['slice_ids']))); @@ -157,16 +178,19 @@ function display_slices ($slices,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'name'=>'string', 'site'=>'string', 'persons'=>'string', 'N'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('slices',$headers,1,$table_options); $table->start(); foreach ($slices as $slice) { $table->row_start(); $table->cell($slice['slice_id']); + $peers->cell($table,$slice['peer_id']); $table->cell(l_slice_obj($slice)); global $sites_hash; $site=$sites_hash[$slice['site_id']]; @@ -188,17 +212,20 @@ function display_sites ($sites,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'name'=>'string', 'url'=>'string', 'persons'=>'string', 'slices'=>'string', 'nodes'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('sites',$headers,1,$table_options); $table->start(); foreach ($sites as $site) { $table->row_start(); $table->cell($site['site_id']); + $peers->cell($table,$site['peer_id']); $table->cell(l_site_obj($site)); $table->cell(href($site['url'],$site['url'])); $table->cell(plc_vertical_table(array_map("plc_person_link",$site['person_ids']))); @@ -217,15 +244,18 @@ function display_nodes ($nodes,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'hostname'=>'string', 'site'=>'string', 'slices'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('nodes',$headers,1,$table_options); $table->start(); foreach ($nodes as $node) { $table->row_start(); $table->cell($node['node_id']); + $peers->cell($table,$node['peer_id']); $table->cell(l_node_obj($node)); global $sites_hash; $site=$sites_hash[$node['site_id']];