+ case 'update-person': {
+ $person_id=$_POST['person_id'];
+ // attempt to update this person
+ $first_name= $_POST['first_name'];
+ $last_name= $_POST['last_name'];
+ $title= $_POST['title'];
+ $email= $_POST['email'];
+ $phone= $_POST['phone'];
+ $url= $_POST['url'];
+ $bio= str_replace("\r", "", $_POST['bio']);
+ $password1= $_POST['password1'];
+ $password2= $_POST['password2'];
+
+ if( $password1 != $password2 ) {
+ drupal_set_error ("The passwords do not match");
+ plc_redirect(l_person($person_id));
+ }
+
+ $update_vals= array();
+ $update_vals['first_name']= $first_name;
+ $update_vals['last_name']= $last_name;
+ $update_vals['title']= $title;
+ $update_vals['email']= $email;
+ $update_vals['phone']= $phone;
+ $update_vals['url']= $url;
+ $update_vals['bio']= $bio;
+
+ if( $password1 != "" )
+ $update_vals['password']= $password1;
+
+ $rc= $api->UpdatePerson( intval( $person_id ), $update_vals);
+
+ if ( $rc == 1 ) {
+ drupal_set_message("$first_name $last_name updated");
+ } else {
+ drupal_set_error ("Could not update person $person_id" . $api->error());
+ }
+ plc_redirect(l_person($person_id));
+ break;
+ }
+
+//////////////////////////////////////////////////////////// nodes
+ case 'node-boot-state': {
+ $node_id=intval($_POST['node_id']);
+ $boot_state=$_POST['boot_state'];
+ $result=$api->UpdateNode( $node_id, array( "boot_state" => $boot_state ) );
+ if ($result==1) {
+ drupal_set_message("boot state updated");
+ plc_redirect (l_node($node_id));
+ } else {
+ drupal_set_error("Could not set boot_state '$boot_state'");
+ }
+ break;
+ }
+
+ case 'delete-node': {
+ $node_id=intval($_POST['node_id']);
+ $result=$api->DeleteNode( intval( $node_id ) );
+ if ($api==1) {
+ drupal_set_message("Node $node_id deleted");
+ plc_redirect (l_nodes());
+ } else {
+ drupal_set_error ("Could not delete node $node_id");
+ }
+ break;
+ }
+
+ case 'update-node': {
+ $hostname= $_POST['hostname'];
+ $model= $_POST['model'];
+
+ $fields= array( "hostname"=>$hostname, "model"=>$model );
+ $api->UpdateNode( intval( $node_id ), $fields );
+ $error= $api->error();
+
+ if( empty( $error ) ) {
+ drupal_set_message("Update node $hostname");
+ plc_redirect(l_node($node_id));
+ } else {
+ drupal_set_error($error);
+ }
+ break;
+ }
+
+//////////////////////////////////////////////////////////// sites
+ case 'delete-site': {
+ $site_id = intval($_POST['site_id']);
+ if ($api->DeleteSite($site_id) ==1)
+ drupal_set_message ("Site $site_id deleted");
+ else
+ drupal_set_error("Failed to delete site $site_id");
+ plc_redirect (l_sites());
+ }
+
+ case 'expire-all-slices-in-site': {
+ // xxx todo
+ drupal_set_message("action $action not implemented in actions.php -- need tweaks and test");
+ return;
+
+ //// old code from sites/expire.php
+ $sites = $api->GetSites( array( intval( $site_id )));
+ $site=$sites[0];
+ // xxx why not 'now?'
+ $expiration= strtotime( $_POST['expires'] );
+ // loop through all slices for site
+ foreach ($site['slice_ids'] as $slice_id) {
+ $api->UpdateSlice( $slice_id, array( "expires" => $expiration ) );
+ }
+ // update site to not allow slice creation or renewal
+ $api->UpdateSite( $site_id, array( "max_slices" => 0 )) ;
+ plc_redirect (l_site($site_id));
+ }
+
+//////////////////////////////////////////////////////////// tags
+