public function deactivate() { $errorMessages = ''; $notifyMessage = ''; $logMessage = ''; $outstr = ''; $ip_address = trim($_SERVER['REMOTE_ADDR']); $app_id = $this->input->get('app_id'); //passed as a parameter $doiValue = $this->input->get('doi'); //passed as a parameter //first up, lets check that this client is permitted to update this doi. $client_id = checkDoisValidClient($ip_address, $app_id); if (!$client_id) { $errorMessages .= $this->doisGetUserMessage("MT009", $doi_id = NULL); header("HTTP/1.0 415 Authentication Error"); } else { if (!checkDoisClientDoi($doiValue, $client_id)) { $errorMessages .= $this->doisGetUserMessage("MT008", $doiValue); header("HTTP/1.0 415 Authentication Error"); } } if (getDoiStatus($doiValue) != "ACTIVE") { $errorMessages .= "DOI " . $doiValue . " is not set to active so cannot deactivate it.<br />"; header("HTTP/1.0 500 Internal Server Error"); } if ($errorMessages == '') { // Update doi information $status = "INACTIVE"; $inactivateResult = setDoiStatus($doiValue, $status); if (!$inactivateResult) { // deactivate the DOI. $response = $this->doisRequest("delete", $doiValue, $urlValue = NULL, $xml = NULL, $client_id); if ($response) { if ($response == gDOIS_RESPONSE_SUCCESS) { // We have successfully deactivated the doi through datacite. $notifyMessage .= $this->doisGetUserMessage("MT003", $doiValue); header("HTTP/1.0 200 OK"); } else { $errorMessages .= $this->doisGetUserMessage("MT010", $doi = NULL); $logMessage = "MT010 " . $response; header("HTTP/1.0 500 Internal Server Error"); } } else { $errorMessages .= $this->doisGetUserMessage("MT005", $doi = NULL); header("HTTP/1.0 500 Internal Server Error"); } } else { $errorMessages .= '<br />' . $inactivateResult; header("HTTP/1.0 500 Internal Server Error"); } } if ($errorMessages) { $outstr = $errorMessages; //We need to log this activity as errorred if ($logMessage) { $errorMessages .= $logMessage; } insertDoiActivity("INACTIVATE", $doiValue, "FAILURE", $client_id, $errorMessages); } if ($notifyMessage) { //We need to log this activity insertDoiActivity("INACTIVATE", $doiValue, "SUCCESS", $client_id, $notifyMessage); $outstr = $notifyMessage; } //we now need to return the result back to the calling program. header('Content-type: text/html'); echo $outstr; }
function deactivate() { // global $api_version; $errorMessages = ''; $notifyMessage = ''; $outstr = ''; $urlValue = ''; $verbosemessage = ''; $client_id = ''; if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { if (isset($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } else { if (isset($_SERVER["REMOTE_ADDR"])) { $ip = $_SERVER["REMOTE_ADDR"]; } else { // Run by command line?? $ip = "127.0.0.1"; } } } $debug = $this->input->get('debug'); if ($debug && $debug == 'true') { $this->debugOn(); } //$app_id = $this->input->get('app_id'); //passed as a parameter $app_id = $this->getAppId(); if (substr($app_id, 0, 4) == 'TEST') { $app_id = substr($app_id, 4, strlen($app_id)); $testing = 'yes'; } $doiValue = $this->input->get('doi'); //passed as a parameter $doiValue = rawurldecode($doiValue); $response_type = $this->input->get('response_type'); //passed as a parameter if (!$response_type) { $response_type = 'string'; } $api_version = $this->input->get('api_version'); if (!$api_version) { $api_version = '1.0'; } if (!$app_id) { $errorMessages = doisGetUserMessage("MT010", $doiValue, $response_type, $app_id, "You must provide an app id to update a doi", $urlValue); } if (!$doiValue) { $errorMessages = doisGetUserMessage("MT010", $doiValue, $response_type, $app_id, "You must provide the doi value to update a doi", $urlValue); } //first up, lets check that this client is permitted to update this doi. if ($errorMessages == '') { $client_id = checkDoisValidClient($ip, $app_id); if ($client_id === false) { $verbosemessage = ''; $errorMessages = doisGetUserMessage("MT009", $doiValue, $response_type, $app_id, $verbosemessage, $urlValue); } else { if (checkDoisClientDoi($doiValue, $client_id) === false) { $verbosemessage = ''; $errorMessages = doisGetUserMessage("MT008", $doiValue, $response_type, $app_id, $verbosemessage, $urlValue); } } } if ($errorMessages == '') { if (getDoiStatus($doiValue) != "ACTIVE") { $verbosemessage = "DOI " . $doiValue . " is not set to active so cannot deactivate it."; $errorMessages = doisGetUserMessage("MT010", $doiValue, $response_type, $app_id, $verbosemessage, $urlValue); } if ($errorMessages == '') { // Update doi information $status = "INACTIVE"; $inactivateResult = setDoiStatus($doiValue, $status); if (!$inactivateResult) { // deactivate the DOI. $response = $this->doisRequest("delete", $doiValue, $urlValue = NULL, $xml = NULL, $client_id); if ($response) { if ($response == gDOIS_RESPONSE_SUCCESS) { // We have successfully deactivated the doi through datacite. $notifyMessage .= doisGetUserMessage("MT003", $doiValue, $response_type, $app_id, $response, $urlValue); } else { $errorMessages .= doisGetUserMessage("MT010", $doi = NULL, $response_type, $app_id, $response, $urlValue); } } else { $errorMessages .= doisGetUserMessage("MT005", $doi = NULL, $response_type, $app_id, $verbosemessage, $urlValue); } } else { $verbosemessage = $inactivateResult; $errorMessages = doisGetUserMessage("MT010", $doiValue, $response_type, $app_id, $verbosemessage, $urlValue); } } } if ($errorMessages) { $outstr = $errorMessages; //We need to log this activity as errorred insertDoiActivity("INACTIVATE", $doiValue, "FAILURE", $client_id, $errorMessages); } if ($notifyMessage) { //We need to log this activity insertDoiActivity("INACTIVATE", $doiValue, "SUCCESS", $client_id, $notifyMessage); $outstr = $notifyMessage; } //we now need to return the result back to the calling program. echo $outstr; }