nodes can set tags, tags and nodegroups are mostly OK
[plewww.git] / planetlab / persons / person.php
index 87b6827..832a540 100644 (file)
@@ -15,6 +15,7 @@ include 'plc_header.php';
 
 // Common functions
 require_once 'plc_functions.php';
+require_once 'plc_peers.php';
 require_once 'plc_minitabs.php';
 require_once 'plc_tables.php';
 require_once 'plc_details.php';
@@ -63,10 +64,10 @@ $slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" ) );
 $keys= $api->GetKeys( $key_ids );
 
 drupal_set_title("Details for account " . $first_name . " " . $last_name);
+$local_peer = ! $peer_id;
 
-$plc_hash=plc_peer_global_hash($api);
+$peers = new Peers ($api);
 
-$local_peer = plc_peer_block_start ($peer_hash,$peer_id);
 $is_my_account = plc_my_person_id() == $person_id;
 $privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
 
@@ -117,8 +118,7 @@ if ( $privileges)
   $tabs['Events'] = array('url'=>l_events(),
                          'values'=>array('type'=>'Person','person'=>$person_id),
                          'bubble'=>"Events about $first_name $last_name",
-                         'image'=>'/planetlab/icons/event.png',
-                         'height'=>18);
+                         'image'=>'/planetlab/icons/event.png','height'=>18);
 
 // Back button
 $tabs['All Users'] = array ('url'=>l_persons(),
@@ -126,6 +126,8 @@ $tabs['All Users'] = array ('url'=>l_persons(),
 
 plc_tabs($tabs);
     
+$peers->block_start ($peer_id);
+
 if ($local_peer && $privileges && ! $enabled ) 
   drupal_set_message ("$first_name $last_name is not enabled yet, you can enable her/him with the 'Enable' button below");
 
@@ -141,6 +143,7 @@ plc_details_line("URL",$url);
 plc_details_line("Phone",$phone);
 plc_details_line("Title",$title);
 plc_details_line("Bio",wordwrap($bio,50,"<br/>"));
+plc_details_line("Peer",$peers->peer_link($peer_id));
 plc_details_end();
 
 //////////////////// slices
@@ -150,7 +153,12 @@ if( ! $slices) {
   plc_warning ("User has no slice");
  } else {
   $headers=array('Slice name'=>'string');
-  $table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'pagesize'=>999, 'search_width'=>10);
+  $reasonable_page=5;
+  $table_options = array('notes_area'=>false,"search_width"=>10,'pagesize'=>$reasonable_page);
+  if (count ($slices) <= $reasonable_page) {
+    $table_options['search_area']=false;
+    $table_options['pagesize_area']=false;
+  }
   plc_table_start("person_slices",$headers,1,$table_options);
 
   foreach( $slices as $slice ) {
@@ -164,11 +172,7 @@ if( ! $slices) {
  }
 
 // we don't set 'action', but use the submit button name instead
-plc_form_start(l_actions(),
-              array("person_id"=>$person_id,
-                    // uncomment this to run the 'debug' action 
-                    //"action"=>"debug",
-                    ));
+plc_form_start(l_actions(), array("person_id"=>$person_id,));
 
 //////////////////// keys
 plc_section ("Keys");
@@ -188,7 +192,7 @@ plc_table_start("person_keys",$headers,"1",$table_options);
     
 if ($keys) foreach ($keys as $key) {
   $key_id=$key['key_id'];
-  plc_table_row_start($key_id);
+  plc_table_row_start();
   plc_table_cell ($key['key_type']);
   plc_table_cell(wordwrap( $key['key'], 60, "<br />\n", 1 ));
   if ($can_manage_keys) 
@@ -247,6 +251,7 @@ if ($can_manage_sites) {
   // add a site : the button
   $add_site_right_area=plc_form_submit_text("add-person-to-site","Add in site");
   // get list of local sites that the person is not in
+  function get_site_id ($site) { return $site['site_id'];}
   $person_site_ids=array_map("get_site_id",$sites);
   $relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids), $site_columns);
 
@@ -257,9 +262,9 @@ if ($can_manage_sites) {
   $add_site_left_area=plc_form_select_text("site_id",$selector,"Choose a site to add");
   $add_site_area = $add_site_left_area . $add_site_right_area;
   if ($sites) 
-    $footers[]="<td colspan=3 style='text-align:right'> $remove_sites_area </td>";
+    $footers[]=plc_table_td_text ($remove_sites_area,3,"right");
   // add a new site
-  $footers []="<td colspan=3 style='text-align:right'> $add_site_area </td>";
+  $footers []= plc_table_td_text ($add_site_right_area,3,"right");
  }
 plc_table_end("person_sites",array("footers"=>$footers));
 
@@ -315,7 +320,7 @@ plc_table_end("person_roles",array("footers"=>$footers));
 
 //////////////////////////////
 plc_form_end();
-plc_peer_block_end();
+$peers->block_end($peer_id);
   
 // Print footer
 include 'plc_footer.php';