40 const NAME =
"admin_upload_delete";
48 function __construct()
50 parent::__construct(self::NAME, array(
51 self::TITLE => _(
"Delete Uploaded File"),
52 self::MENU_LIST =>
"Organize::Uploads::Delete Uploaded File",
54 self::REQUIRES_LOGIN =>
true 58 $this->uploadDao = $container->get(
'dao.upload');
59 $this->folderDao = $container->get(
'dao.folder');
68 private function delete($uploadpk)
73 $jobpk = JobAddJob($user_pk, $group_pk,
"Delete", $uploadpk);
74 if (empty($jobpk) || ($jobpk < 0)) {
75 return _(
"Failed to create job record");
78 $jqargs =
"DELETE UPLOAD $uploadpk";
79 $jobqueuepk =
JobQueueAdd($jobpk,
"delagent", $jqargs, null, null);
80 if (empty($jobqueuepk)) {
81 return _(
"Failed to place delete in job queue");
87 $error_msg = _(
"Is the scheduler running? Your jobs have been added to job queue.");
89 $LinkText = _(
"View Jobs");
90 return "$error_msg <a href=\"$URL\">$LinkText</a>";
99 protected function handle(Request $request)
103 $uploadpks = $request->get(
'uploads');
104 $folderId = $request->get(
'folder');
106 if (!empty($uploadpks)) {
107 $vars[
'message'] = $this->
initDeletion($uploadpks, $folderId);
115 $uploadList = array();
117 foreach ($folderList as $L) {
119 if (!empty($L[
'upload_desc'])) {
120 $desc .=
" (" . $L[
'upload_desc'] .
")";
122 if (!empty($L[
'upload_ts'])) {
123 $desc .=
" :: " . substr($L[
'upload_ts'], 0, 19);
125 $uploadList[$L[
'upload_pk']] = $desc;
127 $vars[
'uploadList'] = $uploadList;
129 return $this->
render(
'admin_upload_delete.html.twig', $this->mergeWithDefault($vars));
141 if (
sizeof($uploadpks) <= 0) {
142 return _(
"No uploads selected");
146 $deleteResponse = null;
147 foreach ($uploadpks as $uploadPk) {
148 $deleteResponse = $this->
TryToDelete(intval($uploadPk), $folderId);
151 $errorMessages[] = $deleteResponse;
155 if (
sizeof($uploadpks) == 1) {
156 return $deleteResponse->getDeleteMessageString().$deleteResponse->getAdditionalMessage();
159 $displayMessage =
"";
160 $countErrorMessages = array_count_values(array_filter($errorMessages));
162 $displayMessage .=
"<br/>Scheduling failed for " .
167 $displayMessage .=
"No permission to delete " .
171 $displayMessage .=
"Deletion of " .
172 (
sizeof($uploadpks) -
sizeof($errorMessages)) .
" projects queued";
173 return DisplayMessage($displayMessage);
189 if (!empty($this->folderDao->isRemovableContent($uploadpk,2))) {
190 $this->folderDao->removeContentById($uploadpk, $folderId);
194 $rc = $this->
delete(intval($uploadpk));
204 $LinkText = _(
"View Jobs");
207 " <a href=$URL>$LinkText</a>");
Traceback_uri()
Get the URI without query to this location.
static getUserId()
Get the current user's id.
UI namespace for delagent.
FolderListOption($ParentFolder, $Depth, $IncludeTop=1, $SelectId=-1, $linkParent=false, $OldParent=0)
Create the folder tree, using OPTION tags.
FolderListUploads_perm($ParentFolder, $perm)
Returns an array of uploads in a folder.
render($templateName, $vars=null, $headers=null)
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
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.
GetUserRootFolder()
Get the top-of-tree folder_pk for the current user. Fail if there is no user session.
UI plugin to delete uploaded files.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.
initDeletion($uploadpks, $folderId)
starts deletion and handles error messages
TryToDelete($uploadpk, $folderId)
Given a folder_pk, try to add a job after checking permissions.
static getGroupId()
Get the current user's group id.