fix: when created slice doesn't have any nodes and/or users associated
[plewww.git] / planetlab / slices / slice.php
index de6098e..c58fdc2 100644 (file)
@@ -129,7 +129,7 @@ EOF;
     $selectors = array();
     foreach ( array ( 1 => "One more week", 
                      2 => "Two more weeks", 
-                     3 => "Two more weeks", 
+                     3 => "Three more weeks", 
                      4 => "One more month" ) as $weeks => $text ) {
       $candidate_exp = $current_exp + $weeks*$WEEK;
       if ( $candidate_exp < $max_exp) {
@@ -183,7 +183,7 @@ if ($am_in_slice) {
   drupal_set_title("Slice " . $name);
 }
 
-$privileges = ( $local_peer && (plc_is_admin()  || $am_in_slice));
+$privileges = ( $local_peer && (plc_is_admin()  || plc_is_pi() || $am_in_slice));
 
 $tabs=array();
 $tabs [] = tab_nodes_slice($slice_id);
@@ -195,7 +195,7 @@ if ($privileges) {
                          'method'=>'post',
                          'values'=>array('action'=>'delete-slice','slice_id'=>$slice_id),
                          'bubble'=>"Delete slice $name",
-                         'confirm'=>'Are you sure to delete $name');
+                         'confirm'=>"Are you sure to delete slice $name");
 
   $tabs["Events"]=array_merge(tablook_event(),
                              array('url'=>l_event("Slice","slice",$slice_id),
@@ -267,7 +267,9 @@ $persons=$api->GetPersons(array('person_id'=>$slice['person_ids']));
 // just propose to add everyone else, 
 // as regular persons can see only a fraction of the db anyway
 if (empty($persons))
-    $potential_persons=$api->GetPersons();
+    $potential_persons=$api->GetPersons(
+        array(),
+        array('email','person_id','first_name','last_name','roles'));
 else
     $potential_persons=
         $api->GetPersons(array('~person_id'=>$slice['person_ids'],'peer_id'=>NULL),
@@ -341,7 +343,7 @@ if ($privileges) {
     $headers['first']='string';
     $headers['last']='string';
     $headers['R']='string';
-    $headers['Add']="none";
+    $headers['+']="none";
     $options = array('notes_area'=>false,
                     'search_width'=>15,
                     'pagesize'=>8);
@@ -379,7 +381,8 @@ $toggle->end();
 $node_columns = array('hostname','node_id','arch');
 $nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),$node_columns);
 if (empty($nodes))
-    $potential_nodes=$api->GetNodes();
+    $potential_nodes=$api->GetNodes(array(),
+                                    $node_columns);
 else
     $potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),$node_columns);
 $count=count($nodes);
@@ -398,6 +401,7 @@ $toggle_nodes=new PlekitToggle('my-slice-nodes-current',
 $toggle_nodes->start();
 
 $headers=array();
+$headers['peer']='string';
 $headers['hostname']='string';
 $headers['arch']='string';
 if ($privileges) $headers[plc_delete_icon()]="none";
@@ -412,6 +416,7 @@ $form->start();
 $table->start();
 if ($nodes) foreach ($nodes as $node) {
   $table->row_start();
+  $peers->cell($table,$node['peer_id']);
   $table->cell(l_node_obj($node));
   $table->cell($node['arch']);
   if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
@@ -444,9 +449,10 @@ if ($privileges) {
     echo "<p class='not-relevant'>No node to add</p>";
   } else {
     $headers=array();
+    $headers['peer']='string';
     $headers['hostname']='string';
     $headers['arch']='string';
-    $headers['Add']="none";
+    $headers['+']="none";
     
     $table=new PlekitTable('add_nodes',$headers,'1', $table_options);
     $form=new PlekitForm(l_actions(),
@@ -455,6 +461,7 @@ if ($privileges) {
     $table->start();
     if ($potential_nodes) foreach ($potential_nodes as $node) {
        $table->row_start();
+       $peers->cell($table,$node['peer_id']);
        $table->cell(l_node_obj($node));
        $table->cell($node['arch']);
        $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));