add an admin option to update the site:enabled field on the site view page.
[plewww.git] / planetlab / common / actions.php
index 010be21..c05d0b0 100644 (file)
@@ -184,7 +184,7 @@ switch ($action) {
 
  case 'become-person' : {
    $plc->BecomePerson (intval($person_id));
-   plc_redirect (l_persons());
+   plc_redirect (l_person(intval($person_id)));
  }
 
  case 'delete-person' : {
@@ -240,7 +240,7 @@ switch ($action) {
    
    $key_id = $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) );
    
-   if ( $key_id == 1) 
+   if ( $key_id >= 1) 
      drupal_set_message ("New key added");
    else
      drupal_set_error("Could not add key, please verify your SSH file content\n" . $api->error());
@@ -434,6 +434,9 @@ switch ($action) {
      $fields['login_base'] = $_POST['login_base'];
    if ($_POST['max_slices']) 
      $fields['max_slices'] = intval($_POST['max_slices']);
+   if (isset($_POST['enabled'])) {
+     $fields['enabled'] = (bool)$_POST['enabled'];
+   }
    
    $retcod=$api->UpdateSite( intval( $site_id ), $fields );
    if ($retcod == 1) 
@@ -448,12 +451,11 @@ switch ($action) {
 //////////////////////////////////////////////////////////// slices
  case 'delete-slice': {
    $slice_id = $_POST['slice_id'];
-   $api->DeleteSlice( intval( $slice_id ) );
-   $error= $api->error();
-   if( empty( $error ) ) {
-       drupal_set_message("Deleted slice $slice_id");
+   if ($api->DeleteSlice( intval( $slice_id )) == 1 ) {
+     drupal_set_message("Slice $slice_id deleted");
+     plc_redirect(l_slices());
    } else {
-       drupal_set_error($error);
+     drupal_set_error("Could not delete slice $slice_id " . $api->error());
    }
    break;
  }
@@ -601,8 +603,11 @@ switch ($action) {
    if ($result)
      drupal_set_message ("Added slice tag.");
    else 
-     drupal_set_error("Could not add slice tag");
-   plc_redirect(l_slice($slice_id) . "&show_tags=true" );
+       drupal_set_error("Could not add slice tag");
+   if ($_POST['sliver_action'])
+       plc_redirect(l_sliver($node_id,$slice_id));
+   else
+       plc_redirect(l_slice($slice_id) . "&show_tags=true" );
    break;
  }