3 include_once dirname(dirname(__DIR__)) .
"/lib/php/common.php";
4 include_once
"DeleteResponse.php";
5 include_once
"DeleteMessages.php";
17 function TryToDelete($uploadpk, $user_pk, $group_pk, $uploadDao)
19 if (! $uploadDao->isEditable($uploadpk, $group_pk)) {
20 $returnMessage = DeleteMessages::NO_PERMISSION;
24 $rc = DeleteUpload(intval($uploadpk), $user_pk, $group_pk, $uploadDao);
27 $returnMessage = DeleteMessages::SCHEDULING_FAILED;
33 $LinkText = _(
"View Jobs");
34 $returnMessage = DeleteMessages::SUCCESS;
36 " <a href=$URL>$LinkText</a>");
47 function DeleteUpload($uploadpk, $user_pk, $group_pk, $Depends = NULL)
50 $jobpk = JobAddJob($user_pk, $group_pk,
"Delete", $uploadpk);
51 if (empty($jobpk) || ($jobpk < 0)) {
52 $text = _(
"Failed to create job record");
56 $jqargs =
"DELETE UPLOAD $uploadpk";
57 $jobqueuepk =
JobQueueAdd($jobpk,
"delagent", $jqargs, NULL, NULL);
58 if (empty($jobqueuepk)) {
59 $text = _(
"Failed to place delete in job queue");
66 $error_msg = _(
"Is the scheduler running? Your jobs have been added to job queue.");
68 $LinkText = _(
"View Jobs");
69 $msg =
"$error_msg <a href=$URL>$LinkText</a>";
80 function initDeletion($uploadpks)
82 if (
sizeof($uploadpks) <= 0) {
83 return DisplayMessage(
"No uploads selected");
88 $deleteResponse = null;
89 for ($i=0; $i <
sizeof($uploadpks); $i++) {
90 $deleteResponse = TryToDelete(intval($uploadpks[$i]));
92 if ($deleteResponse->getDeleteMessageCode() != DeleteMessages::SUCCESS) {
93 $errorMessages[] = $deleteResponse;
97 if (
sizeof($uploadpks) == 1) {
98 $V .= DisplayMessage($deleteResponse->getDeleteMessageString().$deleteResponse->getAdditionalMessage());
100 $displayMessage =
"";
102 if (in_array(DeleteMessages::SCHEDULING_FAILED, $errorMessages)) {
103 $displayMessage .=
"<br/>Scheduling failed for " .
104 array_count_values($errorMessages)[DeleteMessages::SCHEDULING_FAILED] .
" uploads<br/>";
107 if (in_array(DeleteMessages::NO_PERMISSION, $errorMessages)) {
108 $displayMessage .=
"No permission to delete " .
109 array_count_values($errorMessages)[DeleteMessages::NO_PERMISSION].
" uploads<br/>";
112 $displayMessage .=
"Deletion of " .
113 (
sizeof($uploadpks)-
sizeof($errorMessages)) .
" projects queued";
114 $V .= DisplayMessage($displayMessage);
Traceback_uri()
Get the URI without query to this location.
JobQueueAdd($job_pk, $jq_type, $jq_args, $jq_runonpfile, $Depends, $host=NULL, $jq_cmd_args=NULL)
Insert a jobqueue + jobdepends records.
Handle response from delagent.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.