Remote refresh meta tag on final step, in favor of redirection after login
[plewww.git] / planetlab / persons / person.php
index 107219c..0f26168 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-// $Id$
-
 // Require login
 require_once 'plc_login.php';
 
@@ -78,7 +76,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 +84,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 +101,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,
@@ -294,19 +292,22 @@ 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();