brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / persons / person.php
index 3d95265..24e5cfb 100644 (file)
@@ -22,7 +22,7 @@ require_once 'toggle.php';
 
 // -------------------- 
 // recognized URL arguments
-$person_id=intval($_GET['id']);
+$person_id=intval(get_array($_GET, 'id'));
 if ( ! $person_id ) { 
   plc_error('Malformed URL - id not set'); 
   return;
@@ -62,8 +62,16 @@ $hrn=$person['hrn'];
 
 // gets more data from API calls
 $site_columns=array( "site_id", "name", "login_base" );
-$sites= $api->GetSites( $site_ids, $site_columns);
-$slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" ) );
+if ($site_ids) {
+       $sites= $api->GetSites( $site_ids, $site_columns);
+} else {
+       $sites = array();
+}
+if ($slice_ids) {
+       $slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" ) );
+} else {
+       $slices = array();
+}
 $keys= $api->GetKeys( $key_ids );
 
 drupal_set_title("Details for account " . $first_name . " " . $last_name);
@@ -305,8 +313,12 @@ if ($local_peer) {
         // 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 
+       if ($person_site_ids) {
+               $relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids, '-SORT'=>'name'), $site_columns);
+       } else {
+               $relevant_sites= $api->GetSites( array("peer_id"=>NULL, '-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")).