X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fpersons%2Fperson.php;h=c3eea4ba75436c6d0efc3667c6fb5280792e8df9;hb=1808442881002384b18ea43434c56faad81b31f9;hp=11bcd15b2e24c583035e9eefa4406aa63fe5399e;hpb=affa7b7ae6c08a5499398a6e11c3ca01708e93a4;p=plewww.git
diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php
index 11bcd15..c3eea4b 100644
--- a/planetlab/persons/person.php
+++ b/planetlab/persons/person.php
@@ -64,21 +64,16 @@ $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;
$peers = new Peers ($api);
-$local_peer = $peers->block_start ($peer_id);
$is_my_account = plc_my_person_id() == $person_id;
$privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
$tabs=array();
+$tabs []= tab_persons();
-// 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)
if ($enabled)
@@ -120,29 +115,48 @@ if ( $privileges)
'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');
-
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");
-$enabled_text="Enabled";
-if ( ! $enabled ) $enabled_text = plc_warning_text("Disabled");
-
-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_line("Peer",$peers->peer_link($peer_id));
-plc_details_end();
+$enabled_label="Yes";
+if ( ! $enabled ) $enabled_label = plc_warning_html("Disabled");
+
+$can_update = (plc_is_admin() && $local_peer) || $is_my_account;
+$details = new PlcDetails($can_update);
+
+$details->form_start(l_actions(),array("action"=>"update-person",
+ "person_id"=>$person_id));
+$details->start();
+
+
+$details->th_td("Title",$title,"title",array('width'=>5));
+$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");
+$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();
//////////////////// slices
plc_section('Slices');
@@ -157,21 +171,22 @@ if( ! $slices) {
$table_options['search_area']=false;
$table_options['pagesize_area']=false;
}
- plc_table_start("person_slices",$headers,1,$table_options);
+ $table=new PlcTable ("person_slices",$headers,1,$table_options);
+ $table->start();
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();
+ $table->row_start();
+ $table->cell(l_slice_t($slice_id,$slice_name));
+ $table->row_end();
}
- plc_table_end("person_slices");
+ $table->end();
}
// we don't set 'action', but use the submit button name instead
-plc_form_start(l_actions(),
- array("person_id"=>$person_id,));
+$form=new PlcForm(l_actions(), array("person_id"=>$person_id));
+$form->start();
//////////////////// keys
plc_section ("Keys");
@@ -181,44 +196,47 @@ 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";
+if ($can_manage_keys) $headers[plc_delete_icon()]="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);
+$table=new PlcTable("person_keys",$headers,"1",$table_options);
+$table->start();
if ($keys) foreach ($keys as $key) {
$key_id=$key['key_id'];
- plc_table_row_start();
- plc_table_cell ($key['key_type']);
- plc_table_cell(wordwrap( $key['key'], 60, "
\n", 1 ));
+ $table->row_start();
+ $table->cell ($key['key_type']);
+ $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();
+ $table->cell ($form->checkbox_html('key_ids[]',$key_id));
+ $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");
+ $table->tfoot_start();
// no need to remove if there's no key
- if ($keys)
- $footers[]="