/** * @param int $folderId * @param int $trustGroupId * @return UploadProgress[] */ protected function prepareFolderUploads($folderId, $trustGroupId = null) { if (empty($trustGroupId)) { $trustGroupId = Auth::getGroupId(); } $folderUploads = $this->folderDao->getFolderUploads($folderId, $trustGroupId); $uploadsById = array(); foreach ($folderUploads as $uploadProgress) { $key = $uploadProgress->getId() . ',' . $uploadProgress->getGroupId(); $display = $uploadProgress->getFilename() . _(" from ") . date("Y-m-d H:i", $uploadProgress->getTimestamp()) . ' (' . $uploadProgress->getStatusString() . ')'; $uploadsById[$key] = $display; } return $uploadsById; }
public function Output() { $groupId = Auth::getGroupId(); $rootFolder = $this->folderDao->getRootFolder(Auth::getUserId()); $folderStructure = $this->folderDao->getFolderStructure($rootFolder->getId()); $V = ""; $folder_pk = GetParm('folder', PARM_INTEGER); if (empty($folder_pk)) { $folder_pk = $rootFolder->getId(); } $NewName = GetArrayVal("newname", $_POST); $NewDesc = GetArrayVal("newdesc", $_POST); $upload_pk = GetArrayVal("upload_pk", $_POST); if (empty($upload_pk)) { $upload_pk = GetParm('upload', PARM_INTEGER); } /* Check Upload permission */ if (!empty($upload_pk) && !$this->uploadDao->isEditable($upload_pk, $groupId)) { $text = _("Permission Denied"); return "<h2>{$text}</h2>"; } $rc = $this->UpdateUploadProperties($upload_pk, $NewName, $NewDesc); if ($rc == 0) { $text = _("Nothing to Change"); $this->vars['message'] = $text; } else { if ($rc == 1) { $text = _("Upload Properties successfully changed"); $this->vars['message'] = $text; } } $this->vars['folderStructure'] = $folderStructure; $this->vars['folderId'] = $folder_pk; $this->vars['baseUri'] = $Uri = Traceback_uri() . "?mod=" . $this->Name . "&folder="; $folderUploads = $this->folderDao->getFolderUploads($folder_pk, $groupId); $uploadsById = array(); /* @var $uploadProgress UploadProgress */ foreach ($folderUploads as $uploadProgress) { if ($uploadProgress->getGroupId() != $groupId) { continue; } if (!$this->uploadDao->isEditable($uploadProgress->getId(), $groupId)) { continue; } $display = $uploadProgress->getFilename() . _(" from ") . date("Y-m-d H:i", $uploadProgress->getTimestamp()); $uploadsById[$uploadProgress->getId()] = $display; } $this->vars['uploadList'] = $uploadsById; if (empty($upload_pk)) { reset($uploadsById); $upload_pk = key($uploadsById); } $this->vars['uploadId'] = $upload_pk; if ($upload_pk) { $upload = $this->uploadDao->getUpload($upload_pk); if (empty($upload)) { $this->vars['message'] = _("Missing upload."); return 0; } } else { $upload = null; } $baseFolderUri = $this->vars['baseUri'] . "{$folder_pk}&upload="; $this->vars['uploadAction'] = "onchange=\"js_url(this.value, '{$baseFolderUri}')\""; $this->vars['uploadFilename'] = $upload ? $upload->getFilename() : ''; $this->vars['uploadDesc'] = $upload ? $upload->getDescription() : ''; $this->vars['content'] = $V; return $this->render('admin_upload_edit.html.twig'); }