handling toggle parts visible tag: now rely on local storage, so avoid
[plewww.git] / planetlab / persons / person.php
index 4e978af..ea948f9 100644 (file)
@@ -101,7 +101,7 @@ if ($local_peer && $privileges && ! $is_my_account)
                             '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,
@@ -129,7 +129,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);
@@ -169,7 +169,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) {
@@ -205,7 +205,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) );
@@ -257,7 +257,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 ) ) {
@@ -292,26 +292,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 !");