remove extraneous exec bits
[plewww.git] / planetlab / persons / person.php
index 5b74a7f..663608c 100644 (file)
@@ -30,7 +30,10 @@ if ( ! $person_id ) {
 
 ////////////////////
 // Get all columns as we focus on only one entry
-$persons= $api->GetPersons( array($person_id));
+// we need to mention them explicitly because we want hrn that is a tag..
+$columns=array('enabled','first_name','last_name','email','url','phone','title','bio','peer_id',
+              'role_ids','roles','site_ids','slice_ids','key_ids','hrn');
+$persons= $api->GetPersons( array($person_id), $columns);
 
 if (empty($persons)) {
   drupal_set_message ("Person " . $person_id . " not found");
@@ -55,11 +58,20 @@ $roles= $person['roles'];
 $site_ids= $person['site_ids'];
 $slice_ids= $person['slice_ids'];
 $key_ids= $person['key_ids'];
+$hrn=$person['hrn'];
 
 // gets more data from API calls
 $site_columns=array( "site_id", "name", "login_base" );
-$sites= $api->GetSites( $site_ids, $site_columns);
-$slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" ) );
+if ($site_ids) {
+       $sites= $api->GetSites( $site_ids, $site_columns);
+} else {
+       $sites = array();
+}
+if ($slice_ids) {
+       $slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" ) );
+} else {
+       $slices = array();
+}
 $keys= $api->GetKeys( $key_ids );
 
 drupal_set_title("Details for account " . $first_name . " " . $last_name);
@@ -143,6 +155,8 @@ $details->th_td("Title",$title,"title",array('width'=>10));
 $details->th_td("First Name",$first_name,"first_name");
 $details->th_td("Last Name",$last_name,"last_name");
 $details->th_td(href("mailto:$email","Email"),$email,"email",array("width"=>30));
+if ($hrn) $details->th_td("SFA hrn",$hrn);
+else $details->tr("SFA hrn not set","center");
 $details->th_td("Phone",$phone,"phone");
 $details->th_td("URL",$url,"url",array('width'=>40));
 $details->th_td("Bio",$bio,"bio",array('input_type'=>'textarea','height'=>4));
@@ -299,8 +313,12 @@ if ($local_peer) {
         // 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, '-SORT'=>'name'), $site_columns);
-        // xxx cannot use onchange=submit() - would need to somehow pass action name 
+       if ($person_site_ids) {
+               $relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids, '-SORT'=>'name'), $site_columns);
+       } else {
+               $relevant_sites= $api->GetSites( array("peer_id"=>NULL, '-SORT'=>'name'), $site_columns);
+       }
+       // xxx cannot use onchange=submit() - would need to somehow pass action name 
         function site_selector($site) { return array('display'=>$site['name'],"value"=>$site['site_id']); }
         $selectors = array_map ("site_selector",$relevant_sites);
         $table->cell ($form->select_html("site_id",$selectors,array('label'=>"Choose a site to add")).
@@ -379,6 +397,65 @@ if ($local_peer) {
   $toggle->end();
  }
 
+//////////////////////////////////////////////////////////// Tags
+// tags section
+if ($local_peer) {
+  $tags=$api->GetPersonTags (array('person_id'=>$person_id));
+  function get_tagname ($tag) { return $tag['tagname'];}
+  // xxx looks like tech-only see an error here, 
+  // might be that GetPersonTags is not accessible or something
+  $tagnames = array_map ("get_tagname",$tags);
+  
+  $toggle = new PlekitToggle ('tags',count_english($tags,'tag'),
+                             array('bubble'=>'Inspect and set tags on that person',
+                                   'visible'=>get_arg('show_tags')));
+  $toggle->start();
+
+  $headers=array("Name"=>"string",
+                "Value"=>"string",
+                );
+  if (plc_is_admin()) $headers[plc_delete_icon()]="none";
+  
+  $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
+  $table=new PlekitTable("person_tags",$headers,0,$table_options);
+  $table->start();
+  if ($tags) foreach ($tags as $tag) {
+      $table->row_start();
+      $table->cell(l_tag_obj($tag));
+      $table->cell($tag['value']);
+      // the remove checkbox
+      if (plc_is_admin()) $table->cell ($form->checkbox_html('person_tag_ids[]',$tag['person_tag_id']));
+      $table->row_end();
+    }
+  
+  if ($privileges) {
+    $table->tfoot_start();
+
+    // remove tag 
+    $table->row_start();
+    $table->cell($form->submit_html("delete-person-tags","Remove Tags"),
+                // use the whole columns and right adjust
+                array('hfill'=>true,'align'=>'right'));
+    $table->row_end();
+
+    // set tag area
+    $table->row_start();
+    // get list of tag names in the person/* category    
+    $all_tags= $api->GetTagTypes( array ("category"=>"person*","-SORT"=>"tagname"), array("tagname","tag_type_id"));
+    // xxx cannot use onchange=submit() - would need to somehow pass action name 
+    function tag_selector ($tag) { return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']); }
+    $selector=array_map("tag_selector",$all_tags);
+    $table->cell($form->select_html("tag_type_id",$selector,array('label'=>"Choose")));
+    $table->cell($form->text_html("value","",array('width'=>8)));
+    $table->cell($form->submit_html("set-tag-on-person","Set Tag"),array('columns'=>2,'align'=>'left'));
+    $table->row_end();
+  }
+  
+  $table->end();
+  $toggle->end();
+
+}
+
 //////////////////////////////
 $form->end();
 $peers->block_end($peer_id);