AddPersonToSite( intval( $person_id ), intval( $site_id ) ); header( "location: " . l_person($person_id)); exit(); } case 'remove-person-from-sites': { $site_ids = $_POST['site_ids']; if ( ! $site_ids) { drupal_set_message("action=$action - No site selected"); return; } foreach ( $site_ids as $site_id ) { $api->DeletePersonFromSite( intval( $person_id ), intval( $site_id ) ); } header( "location: " . l_person($person_id)); exit(); } case 'remove-roles-from-person' : { $role_ids=$_POST['role_ids']; if ( ! $role_ids) { drupal_set_message("action=$action - No role selected"); return; } foreach( $role_ids as $role_id) { $api->DeleteRoleFromPerson( intval( $role_id ), intval( $person_id ) ); } header( "location: " . l_person($person_id)); exit(); } case 'add-role-to-person' : { $role_id=$_POST['role_id']; $api->AddRoleToPerson( intval( $role_id ), intval( $person_id ) ); header( "location: " . l_person($person_id)); exit(); } case 'enable-person' : { $fields = array( "enabled"=>true ); $api->UpdatePerson( intval( $person_id ), $fields ); header( "location: " . l_person($person_id)); exit(); } case 'disable-person' : { $fields = array( "enabled"=>false ); $api->UpdatePerson( intval( $person_id ), $fields ); header( "location: " . l_person($person_id)); exit(); } case 'become-person' : { $plc->BecomePerson (intval($person_id)); header ("location: " . l_persons()); exit(); } case 'delete-person' : { $api->DeletePerson( intval( $person_id ) ); header( "location: " . l_persons() ); exit(); } case 'delete-keys' : { $key_ids=$_POST['key_ids']; if ( ! $key_ids) { drupal_set_message("action=$action - No key selected"); return; } foreach( $key_ids as $key_id ) { $api->DeleteKey( intval( $key_id ) ); } header( "location: " . l_person($person_id)); exit(); } case 'upload-key' : { if ( ! isset( $_FILES['key'] ) ) { drupal_set_message ("action=$action, no key file set"); return; } $key_file= $_FILES['key']['tmp_name']; if ( ! $key_file ) { plc_error("Please select a valid SSH key file to upload"); return; } $fp = fopen( $key_file, "r" ); $key = ""; if( ! $fp ) { plc_error("Unable to open key file $key_file"); return; } // opened the key file, read the one line of contents // The POST operation always creates a file even if the filename // the user specified was garbage. If there was some problem // with the source file, we'll get a zero length read here. $key = fread($fp, filesize($key_file)); fclose($fp); $key_id= $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) ); if ( ! $key_id ) { $error= $api->error(); plc_error("$error"); plc_error("Please verify your SSH file content"); return; } header( "location: " . l_person($person_id)); exit(); } case 'debug': { plc_debug('GET',$_GET); plc_debug('POST',$_POST); plc_debug('FILES',$_FILES); return; } default: { plc_error ("Unknown action $action in person_actions.php"); return; } } ?>