/** * \brief Display the tagging page. * @param string $action * @param int $ShowHeader */ function ShowTaggingPage($action, $ShowHeader = 0) { $V = ""; $Upload = GetParm("upload", PARM_INTEGER); $Item = GetParm("item", PARM_INTEGER); if (empty($Item) || empty($Upload)) { return; } /********************************** Display micro header **********************************/ if ($ShowHeader) { $V .= Dir2Browse("browse", $Item, NULL, 1, "Browse"); } $V .= $this->ShowExistTags($Upload, $Item); $V .= $this->ShowAjaxPage(); if ($action == 'edit') { $V .= $this->ShowEditTagPage($Upload, $Item); } else { /* Show create tag page */ if ($this->uploadDao->isEditable($Upload, Auth::getGroupId())) { $V .= $this->ShowCreateTagPage($Upload, $Item); } else { $nopermtext = _("You do not have permission to tag this upload."); $V .= $nopermtext; } } return $V; }
protected function isContentMovable($content, $newParentId) { if ($content['parent_fk'] == $newParentId) { return false; } $newParent = $this->dbManager->getSingleRow('SELECT * FROM folder WHERE folder_pk=$1', array($newParentId), __METHOD__ . '.getParent'); if (empty($newParent)) { throw new \Exception('invalid parent folder'); } if ($content['foldercontents_mode'] == self::MODE_FOLDER) { if ($this->isInFolderTree($content['child_id'], $newParentId)) { throw new \Exception("action would cause a cycle"); } } elseif ($content['foldercontents_mode'] == self::MODE_UPLOAD) { $uploadId = $content['child_id']; if (!$this->uploadDao->isEditable($uploadId, Auth::getGroupId())) { throw new \Exception('permission to upload denied'); } } return true; }
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'); }
/** * @brief extends standard Output to handle empty uploads */ function Output() { if ($this->invalidParm) { $this->vars['content'] = 'This upload contains no files!<br><a href="' . Traceback_uri() . '?mod=browse">Go back to browse view</a>'; return $this->render("include/base.html.twig"); } $uploadId = GetParm("upload", PARM_INTEGER); if (empty($uploadId)) { return new Response("", Response::HTTP_BAD_REQUEST); } $uploadTreeId = GetParm("item", PARM_INTEGER); if (empty($uploadTreeId)) { return new Response("", Response::HTTP_BAD_REQUEST); } $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); $lastItem = GetParm("lastItem", PARM_INTEGER); if (!empty($lastItem)) { $this->updateLastItem($userId, $groupId, $lastItem); } $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId); $itemTreeBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId, $uploadTreeTableName); $this->vars['micromenu'] = Dir2Browse('license', $uploadTreeId, NULL, $showBox = 0, "View", -1, '', '', $uploadTreeTableName); global $Plugins; /** @var ui_view $view */ $view =& $Plugins[plugin_find_id("view")]; $licenseId = GetParm("licenseId", PARM_INTEGER); $selectedAgentId = GetParm("agentId", PARM_INTEGER); $highlightId = GetParm("highlightId", PARM_INTEGER); $clearingId = GetParm("clearingId", PARM_INTEGER); if ($clearingId !== null) { $highlightId = -1; } else { if ($highlightId !== null) { $clearingId = -1; } } $baseUri = Traceback_uri(); $this->vars['baseuri'] = $baseUri; $this->vars['uri'] = $baseUri . "?mod=" . $this->Name . Traceback_parm_keep(array('upload', 'folder')); $this->vars['bulkHistoryHighlightUri'] = $this->vars['uri']; $this->vars['optionName'] = "skipFile"; $this->vars['formName'] = "uiClearingForm"; $this->vars['ajaxAction'] = "setNextPrev"; $highlights = $this->getSelectedHighlighting($itemTreeBounds, $licenseId, $selectedAgentId, $highlightId, $clearingId, $uploadId); $isSingleFile = !$itemTreeBounds->containsFiles(); $hasWritePermission = $this->uploadDao->isEditable($uploadId, $groupId); $clearingDecisions = null; if ($isSingleFile || $hasWritePermission) { $clearingDecisions = $this->clearingDao->getFileClearings($itemTreeBounds, $groupId, false); } if ($isSingleFile && $hasWritePermission) { $this->vars['bulkUri'] = Traceback_uri() . "?mod=popup-license"; $licenseArray = $this->licenseDao->getLicenseArray($groupId); // $clearingDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId); list($addedResults, $removedResults) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION); if (count($addedResults) + count($removedResults) > 0) { array_unshift($licenseArray, array('id' => 0, 'fullname' => '', 'shortname' => '------')); } /** @var ClearingResult $result */ foreach ($removedResults as $result) { array_unshift($licenseArray, array('id' => $result->getLicenseId(), 'fullname' => $result->getLicenseFullName(), 'shortname' => $result->getLicenseShortName())); } /** @var ClearingResult $result */ foreach ($addedResults as $result) { array_unshift($licenseArray, array('id' => $result->getLicenseId(), 'fullname' => $result->getLicenseFullName(), 'shortname' => $result->getLicenseShortName())); } $this->vars['licenseArray'] = $licenseArray; } elseif ($isSingleFile) { $this->vars['auditDenied'] = true; } $clearingHistory = array(); $selectedClearingType = false; if ($hasWritePermission) { $clearingHistory = $this->getClearingHistory($clearingDecisions); } if (count($clearingHistory) > 0) { $selectedClearingType = $this->decisionTypes->getTypeByName($clearingHistory[0]['type']); } $bulkHistory = $this->clearingDao->getBulkHistory($itemTreeBounds, $groupId); $ModBack = GetParm("modback", PARM_STRING) ?: "license"; list($pageMenu, $textView) = $view->getView(NULL, $ModBack, 0, "", $highlights, false, true); $this->vars['uploadId'] = $uploadId; $this->vars['itemId'] = $uploadTreeId; $this->vars['pageMenu'] = $pageMenu; $this->vars['textView'] = $textView; $this->vars['legendData'] = $this->highlightRenderer->getLegendData($selectedAgentId || $clearingId); $this->vars['clearingTypes'] = $this->decisionTypes->getMap(); $this->vars['selectedClearingType'] = $selectedClearingType; $this->vars['tmpClearingType'] = $this->clearingDao->isDecisionWip($uploadTreeId, $groupId); $this->vars['clearingHistory'] = $clearingHistory; $this->vars['bulkHistory'] = $bulkHistory; $noLicenseUploadTreeView = new UploadTreeProxy($uploadId, $options = array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense", UploadTreeProxy::OPT_GROUP_ID => $groupId), $uploadTreeTableName, $viewName = 'no_license_uploadtree' . $uploadId); $filesOfInterest = $noLicenseUploadTreeView->count(); $nonClearedUploadTreeView = new UploadTreeProxy($uploadId, $options = array(UploadTreeProxy::OPT_SKIP_THESE => "alreadyCleared", UploadTreeProxy::OPT_GROUP_ID => $groupId), $uploadTreeTableName, $viewName = 'already_cleared_uploadtree' . $uploadId); $filesToBeCleared = $nonClearedUploadTreeView->count(); $filesAlreadyCleared = $filesOfInterest - $filesToBeCleared; $this->vars['message'] = _("Cleared") . ": {$filesAlreadyCleared}/{$filesOfInterest}"; return $this->render("ui-clearing-view.html.twig"); }
public function Output() { $page = ""; $uploadPk = GetParm('upload', PARM_INTEGER); if (empty($uploadPk)) { $uploadPk = -1; } elseif ($uploadPk > 0) { if (!$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) { $this->vars['message'] = _("Permission Denied"); return; } } $this->vars['uploadId'] = $uploadPk; /* Process any actions */ $action = GetParm("action", PARM_STRING); $page = GetParm('page', PARM_INTEGER) ?: 0; if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_WRITE && !empty($action)) { $jq_pk = GetParm("jobid", PARM_INTEGER); $uploadPk = GetParm("upload", PARM_INTEGER); if (!($uploadPk === -1 && ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_ADMIN || $this->jobDao->hasActionPermissionsOnJob($jq_pk, Auth::getUserId(), Auth::getGroupId()))) && !$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) { $this->vars['message'] = _("Permission Denied to perform action"); } else { $thisURL = Traceback_uri() . "?mod=" . $this->Name . "&upload={$uploadPk}"; switch ($action) { case 'pause': if (empty($jq_pk)) { break; } $command = "pause {$jq_pk}"; $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info); if ($rv == false) { $this->vars['errorInfo'] = _("Unable to pause job.") . " " . $response_from_scheduler . $error_info; } echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>"; break; case 'restart': if (empty($jq_pk)) { break; } $command = "restart {$jq_pk}"; $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info); if ($rv == false) { $this->vars['errorInfo'] = _("Unable to restart job.") . " " . $response_from_scheduler . $error_info; } echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>"; break; case 'cancel': if (empty($jq_pk)) { break; } $Msg = "\"" . _("Killed by") . " " . $_SESSION[Auth::USER_NAME] . "\""; $command = "kill {$jq_pk} {$Msg}"; $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info); if ($rv == false) { $this->vars['errorInfo'] = _("Unable to cancel job.") . $response_from_scheduler . $error_info; } echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>"; break; } } } $job = GetParm('job', PARM_INTEGER); if (!empty($job)) { $this->vars['jobId'] = $job; $this->vars['uploadName'] = $this->getUploadNameForGeekyScan($job); } else { $allusersval = GetParm("allusers", PARM_INTEGER); if (!$allusersval) { $allusersval = 0; } $this->vars['allusersval'] = $allusersval; if (!$page) { $page = 0; } $this->vars['page'] = $page; $this->vars['clockTime'] = $this->getTimeToRefresh(); $this->vars['allusersdiv'] = menu_to_1html(menu_find($this->Name, $MenuDepth), 0); $this->vars['injectedFoot'] = GetParm("injectedFoot", PARM_TEXT); $this->vars['message'] = GetParm("injectedMessage", PARM_TEXT); } }