Setting tag plewww-4.3-67
[plewww.git] / planetlab / sites / pcu.php
index 3f5c229..1ec3089 100644 (file)
@@ -15,7 +15,6 @@ include 'plc_header.php';
 
 // Common functions
 require_once 'plc_functions.php';
-require_once 'plc_sorts.php';
 
 // find person roles
 $_person= $plc->person;
@@ -34,7 +33,8 @@ if( !$_GET['id'] ) {
     $pcu_id= $api->AddPCU( $site_id, $fields );
     
     if( $pcu_id != 0 ) {
-      header( "location: /db/sites/pcu.php?id=$pcu_id" );
+      // xxx is l_pcu defined & effective ?
+      plc_redirect( l_pcu($pcu_id));
       exit();
     } else {
       $error= $api->error();
@@ -67,8 +67,7 @@ if( !$_GET['id'] ) {
     
     $api->DeleteNodeFromPCU( intval( $rem_id ), $pcu_id );
     
-    header( "Location: /db/sites/pcu.php?id=$pcu_id" );
-    exit();
+    plc_redirect (l_pcu ($pcu_id));
     
   }
   
@@ -84,11 +83,16 @@ if( !$_GET['id'] ) {
     
     $api->UpdatePCU( $pcu_id, array( "protocol"=>$protocol, "hostname"=>$hostname, "model"=>$model, "password"=>$password, "notes"=>$notes, "ip"=>$ipaddress ) );
                
-    header( "Location: /db/sites/pcu.php?id=$pcu_id" );
-    exit();
+    plc_redirect (l_pcu($pcu_id));
                
   }
        
+  if( in_array( 10, $_roles) ) {
+      $is_admin= true;
+  } else {
+      $is_admin = false;
+  }
+
   if( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) || ( in_array( 40, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) )
     $pcu_controller= true;
 
@@ -130,12 +134,13 @@ if( !$_GET['id'] ) {
     echo "</td></tr>\n
          <tr><th>Model: </th><td>";
   
-  if( $pcu_controller )
+  // NOTE: in general, this value should not be edited, so only allow admins.
+  if( $pcu_controller && $is_admin )
     echo "<input type=text name='model' value='";
                
   echo $pcu_info[0]['model'];
   
-  if( $pcu_controller )
+  if( $pcu_controller && $is_admin )
     echo "'>";
   
   echo "</td></tr>\n