admins can change nodes to reservable/regular in the node page
[plewww.git] / planetlab / common / actions.php
index 9950d5b..8c4beab 100644 (file)
@@ -5,7 +5,8 @@ require_once 'plc_login.php';
 
 // Get session and API handles
 require_once 'plc_session.php';
-global $plc, $api;
+require_once 'plc_api.php';
+global $plc, $api, $adm;
 
 //print header
 require_once 'plc_drupal.php';
@@ -48,7 +49,7 @@ $known_actions []= "node-boot-state";
 $known_actions []= "delete-node";      
 //     expects:        node_id
 $known_actions []= "update-node";      
-//     expects:        node_id, hostname, model
+//     expects:        node_id, hostname, model, node_type
 $known_actions []= "attach-pcu";
 //     expects:        node_id, pcu_id, port (pcu_id <0 means detach)
 $known_actions []= "reboot-node-with-pcu";
@@ -348,8 +349,9 @@ switch ($action) {
    $node_id=intval($_POST['node_id']);
    $hostname= $_POST['hostname'];
    $model= $_POST['model'];
+   $node_type= $_POST['node_type'];
 
-   $fields= array( "hostname"=>$hostname, "model"=>$model );
+   $fields= array( "hostname"=>$hostname, "model"=>$model, "node_type"=>$node_type );
    $api->UpdateNode( $node_id, $fields );
    $error= $api->error();
 
@@ -393,8 +395,10 @@ switch ($action) {
  case 'reboot-node-with-pcu': {
    $node_id=intval($_POST['node_id']);
    $hostname= $_POST['hostname'];
+   $test = $_POST['test'];
+   settype($test, "boolean");
 
-   $ret = $api->RebootNodeWithPCU( $node_id );
+   $ret = $api->RebootNodeWithPCU( $node_id, $test );
    $error= $api->error();
 
    if( empty( $error ) ) {
@@ -634,7 +638,7 @@ Our support team will be glad to answer any question that you might have.
      }
    }
    if ($success) {
-     $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
+     $adm->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
      drupal_set_message ("Deleted $counter person(s)");
    }
    else
@@ -674,7 +678,7 @@ Our support team will be glad to answer any question that you might have.
      }
    }
    if ($success) {
-     $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
+     $adm->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
      drupal_set_message ("Added $counter person(s)");
    }
    else
@@ -714,7 +718,7 @@ Our support team will be glad to answer any question that you might have.
    $slice_id = intval ($_POST['slice_id']);    
    $previous_initscript=$_POST['previous-initscript'];
    $initscript=$_POST['initscript'];
-   $previous_initscript_code=$_POST['previous-initscript-code'];
+   $previous_initscript_code=html_entity_decode($_POST['previous-initscript-code']);
    $initscript_code=$_POST['initscript-code'];
 
    $changes=FALSE;