X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fpersons%2Fperson.php;h=0f26168fd897164683d286d91bd95c221ed14aac;hb=a8fb1ae7c741148c7ad46c74784f4f8b4699199e;hp=87b68274735f8a8c0f8f67a37cf5c36add58b07a;hpb=7350273c7234b154c15b422e7dda2822cd9deb66;p=plewww.git
diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php
index 87b6827..0f26168 100644
--- a/planetlab/persons/person.php
+++ b/planetlab/persons/person.php
@@ -1,7 +1,5 @@
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);
+if (count($site_ids))
+ $site_id = $site_ids[0];
$is_my_account = plc_my_person_id() == $person_id;
-$privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
+$privileges = plc_is_admin () || ( plc_in_site($site_ids[0]) && plc_is_pi());
$tabs=array();
-// update
-if ($privileges || $is_my_account)
- $tabs['Update'] = array('url'=>'/db/persons/update.php',
- 'values'=>array('id'=>$person_id),
- 'bubble'=>"Update $first_name $last_name");
-
// enable / disable
-if ($local_peer && $privileges)
+// become
+if (plc_is_admin() && ! $is_my_account && $local_peer && $enabled)
+ $tabs['Become'] = array('method'=>'POST',
+ 'url'=>l_actions(),
+ 'values'=>array('action'=>'become-person',
+ 'person_id'=>$person_id),
+ 'bubble'=>"Become $first_name $last_name",
+ 'confirm'=>"Are you sure you want to become $first_name $last_name");
+
+if ($local_peer && $privileges && ! $is_my_account)
if ($enabled)
$tabs['Disable'] = array ('method'=>'POST',
'url'=>l_actions(),
@@ -95,17 +100,8 @@ if ($local_peer && $privileges)
'bubble'=>"Enable $first_name $last_name",
'confirm'=>"Are you sure you want to enable $first_name $last_name");
-// become
-if (plc_is_admin() && ! $is_my_account)
- $tabs['Become'] = array('method'=>'POST',
- 'url'=>l_actions(),
- 'values'=>array('action'=>'become-person',
- 'person_id'=>$person_id),
- 'bubble'=>"Become $first_name $last_name",
- 'confirm'=>"Are you sure you want to su $first_name $last_name");
-
// delete
-if ($local_peer && $privileges)
+if ($local_peer && $privileges && $local_peer && ! $is_my_account)
$tabs['Delete'] = array ('method'=>'POST',
'url'=>l_actions(),
'values'=> array ('person_id'=>$person_id,
@@ -117,208 +113,279 @@ 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);
-
-// Back button
-$tabs['All Users'] = array ('url'=>l_persons(),
- 'bubble'=>'Back to the Users page');
+ 'image'=>'/planetlab/icons/event.png','height'=>18);
-plc_tabs($tabs);
+plekit_linetabs($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");
-$enabled_text="Enabled";
-if ( ! $enabled ) $enabled_text = plc_warning_text("Disabled");
+$enabled_label="Yes";
+if ( ! $enabled ) $enabled_label = plc_warning_html("Disabled");
+
+$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)));
+$toggle->start();
+
+$details = new PlekitDetails($can_update);
+
+$details->form_start(l_actions(),array("action"=>"update-person",
+ "person_id"=>$person_id));
+$details->start();
-plc_details_start();
-plc_details_line("Enabled",$enabled_text);
-plc_details_line("First Name",$first_name);
-plc_details_line("Last Name",$last_name);
-plc_details_line("Email",href("mailto:$email",$email));
-plc_details_line("URL",$url);
-plc_details_line("Phone",$phone);
-plc_details_line("Title",$title);
-plc_details_line("Bio",wordwrap($bio,50,"
"));
-plc_details_end();
+
+$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));
+$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));
+
+// xxx need to check that this is working
+if ($can_update) {
+ $details->th_td("Password","","password1",array('input_type'=>'password'));
+ $details->th_td("Repeat","","password2",array('input_type'=>'password'));
+ $details->tr_submit("submit","Update Account");
+ $details->space();
+ }
+
+$details->th_td("Enabled",$enabled_label);
+if ( ! $local_peer ) {
+ $details->th_td("Peer",$peers->peer_link($peer_id));
+ $details->space();
+ }
+
+$details->end();
+$details->form_end();
+$toggle->end();
//////////////////// slices
-plc_section('Slices');
-
-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);
- plc_table_start("person_slices",$headers,1,$table_options);
-
- foreach( $slices as $slice ) {
- $slice_name= $slice['name'];
- $slice_id= $slice['slice_id'];
- plc_table_row_start();
- plc_table_cell(l_slice_t($slice_id,$slice_name));
- plc_table_row_end();
+if ($local_peer) {
+ $slices_title=count_english_warning($slices,'slice');
+ $toggle=new PlekitToggle ('slices',$slices_title,
+ array('visible'=>get_arg('show_slices',false)));
+ $toggle->start();
+
+ if( ! $slices) {
+ plc_warning ("User has no slice");
+ } else {
+ $headers=array('Slice name'=>'string');
+ $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;
+ }
+ $table=new PlekitTable ("person_slices",$headers,1,$table_options);
+ $table->start();
+
+ foreach( $slices as $slice ) {
+ $slice_name= $slice['name'];
+ $slice_id= $slice['slice_id'];
+ $table->row_start();
+ $table->cell(l_slice_t($slice_id,$slice_name));
+ $table->row_end();
+ }
+ $table->end();
}
- plc_table_end("person_slices");
+ $toggle->end();
}
+////////////////////////////////////////
// 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",
- ));
+$form=new PlekitForm(l_actions(), array("person_id"=>$person_id));
+$form->start();
//////////////////// keys
-plc_section ("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->start();
-$can_manage_keys = ( $local_peer && ( plc_is_admin() || $is_my_account) );
-if ( empty( $key_ids ) ) {
- plc_warning("This user has no known key");
- }
-
-// headers
-$headers=array("Type"=>"string",
- "Key"=>"string");
-if ($can_manage_keys) $headers['Remove']="none";
-// table overall options
-$table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false);
-plc_table_start("person_keys",$headers,"1",$table_options);
+ $can_manage_keys = ( $local_peer && ( plc_is_admin() || $is_my_account) );
+ if ( empty( $key_ids ) ) {
+ plc_warning("This user has no known key");
+ }
+
+ $headers=array("Type"=>"string",
+ "Key"=>"string");
+ if ($can_manage_keys) $headers[plc_delete_icon()]="none";
+ // table overall options
+ $table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false);
+ $table=new PlekitTable("person_keys",$headers,"1",$table_options);
+ $table->start();
-if ($keys) foreach ($keys as $key) {
- $key_id=$key['key_id'];
- plc_table_row_start($key_id);
- plc_table_cell ($key['key_type']);
- plc_table_cell(wordwrap( $key['key'], 60, "
\n", 1 ));
- if ($can_manage_keys)
- plc_table_cell (plc_form_checkbox_text('key_ids[]',$key_id));
- plc_table_row_end();
-}
-// the footer area is used for displaying key-management buttons
-$footers=array();
-// add the 'remove keys' button and key upload areas as the table footer
-if ($can_manage_keys) {
- $remove_keys_area=plc_form_submit_text ("delete-keys","Remove keys");
- $upload_key_left_area= plc_form_label_text("key","Upload new key") . plc_form_file_text("key",60);
- $upload_key_right_area=plc_form_submit_text("upload-key","Upload key");
- // no need to remove if there's no key
- if ($keys)
- $footers[]="