X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fpersons%2Fperson.php;h=3d952658997044cab0f5b5af9e2d92afd152b82c;hb=9a748ac0c230720e6dd9281df441c4d746d6569f;hp=107219c62164c96a021103eeaa0456bf48abc018;hpb=fa425f537d2e4aced1a2362672791aed274dd903;p=plewww.git diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 107219c..3d95265 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -1,7 +1,5 @@ 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"); @@ -57,6 +58,7 @@ $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" ); @@ -78,7 +80,7 @@ $tabs=array(); // enable / disable // become -if (plc_is_admin() && ! $is_my_account && $local_peer) +if (plc_is_admin() && ! $is_my_account && $local_peer && $enabled) $tabs['Become'] = array('method'=>'POST', 'url'=>l_actions(), 'values'=>array('action'=>'become-person', @@ -86,7 +88,7 @@ if (plc_is_admin() && ! $is_my_account && $local_peer) 'bubble'=>"Become $first_name $last_name", 'confirm'=>"Are you sure you want to become $first_name $last_name"); -if ($local_peer && $privileges) +if ($local_peer && $privileges && ! $is_my_account) if ($enabled) $tabs['Disable'] = array ('method'=>'POST', 'url'=>l_actions(), @@ -103,7 +105,7 @@ if ($local_peer && $privileges) 'confirm'=>"Are you sure you want to enable $first_name $last_name"); // delete -if ($local_peer && $privileges && $local_peer) +if ($local_peer && $privileges && $local_peer && ! $is_my_account) $tabs['Delete'] = array ('method'=>'POST', 'url'=>l_actions(), 'values'=> array ('person_id'=>$person_id, @@ -131,7 +133,7 @@ $can_update = (plc_is_admin() && $local_peer) || $is_my_account; $toggle = new PlekitToggle ('person',"Details", array('bubble'=>'Display and modify details for that account', - 'visible'=>get_arg('show_details',true))); + 'visible'=>get_arg('show_details'))); $toggle->start(); $details = new PlekitDetails($can_update); @@ -145,6 +147,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)); @@ -171,7 +175,7 @@ $toggle->end(); if ($local_peer) { $slices_title=count_english_warning($slices,'slice'); $toggle=new PlekitToggle ('slices',$slices_title, - array('visible'=>get_arg('show_slices',false))); + array('visible'=>get_arg('show_slices'))); $toggle->start(); if( ! $slices) { @@ -207,7 +211,7 @@ $form->start(); //////////////////// keys if ($local_peer) { $keys_title = count_english_warning($keys,'key'); - $toggle=new PlekitToggle ('keys',$keys_title,array('visible'=>get_arg('show_keys',false))); + $toggle=new PlekitToggle ('keys',$keys_title,array('visible'=>get_arg('show_keys'))); $toggle->start(); $can_manage_keys = ( $local_peer && ( plc_is_admin() || $is_my_account) ); @@ -259,7 +263,7 @@ if ($local_peer) { if ($local_peer) { $sites_title = count_english_warning($sites,'site'); $toggle=new PlekitToggle('sites',$sites_title, - array('visible'=>get_arg('show_sites',false))); + array('visible'=>get_arg('show_sites'))); $toggle->start(); if (empty( $sites ) ) { @@ -294,26 +298,29 @@ if ($local_peer) { $table->row_end(); } - $table->row_start(); - - // 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 - 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")). - $form->submit_html("add-person-to-site","Add in site"), - array('hfill'=>true,'align'=>'right')); - $table->row_end(); + if (plc_is_admin()) + { + // NOTE: only admins can add users to different sites. + $table->row_start(); + // 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 + 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")). + $form->submit_html("add-person-to-site","Add in site"), + array('hfill'=>true,'align'=>'right')); + $table->row_end(); + } } $table->end(); $toggle->end(); } //////////////////// roles if ($local_peer) { - $toggle=new PlekitToggle ('roles',count_english($roles,"role"),array('visible'=>get_arg('show_roles',false))); + $toggle=new PlekitToggle ('roles',count_english($roles,"role"),array('visible'=>get_arg('show_roles'))); $toggle->start(); if (! $roles) plc_warning ("This user has no role !"); @@ -356,11 +363,11 @@ if ($local_peer) { // add // compute the roles that can be added if (plc_is_admin()) - // all roles - $exclude_role_ids=array(); + // all roles, except 'node' that does not make sense for a person + $exclude_role_ids=array(50); else - // all roles except admin and pi - $exclude_role_ids=array(10,20); + // all roles except admin and pi, and node to avoid confusing people + $exclude_role_ids=array(10,20,50); $possible_roles = roles_except($api->GetRoles(),$exclude_role_ids); $roles_to_add = roles_except ($possible_roles,$role_ids); if ( $roles_to_add ) { @@ -378,6 +385,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);