/** * @brief Returns uploadname as link for geeky scan * @param $job_pk * @return uploadname **/ function getUploadNameForGeekyScan($job_pk) { $row = $this->showJobsDao->getDataForASingleJob($job_pk); if (empty($row["job_upload_fk"])) { return ''; } if (empty($row['jq_pk'])) { return _("Job history record is no longer available"); } /* get the upload filename */ $uploadFileName = htmlspecialchars($this->uploadDao->getUpload($row['job_upload_fk'])->getFilename()); if (empty($uploadFileName)) { /* upload has been deleted so try to get the job name from the original upload job record */ $jobName = $this->showJobsDao->getJobName($row["job_upload_fk"]); $uploadFileName = "Deleted " . $jobName; } $uploadtree_pk = -1; /* Find the uploadtree_pk for this upload so that it can be used in the browse link */ try { $uploadtree_pk = $this->uploadDao->getUploadParent($row['job_upload_fk']); } catch (Exception $e) { echo $e->getMessage(), "\n"; } /* upload file name link to browse */ $uploadNameLink = "<a title='Click to browse this upload' href='" . Traceback_uri() . "?mod=browse&upload=" . $row['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>" . $uploadFileName . "</a>"; return $uploadNameLink; }
/** * @param $itemId - uploadtree id * @param $uploadId - upload id */ public function getCopyrightList($itemId, $uploadId) { if (empty($itemId)) { $itemId = $this->uploadDao->getUploadParent($uploadId); } if (!$this->selectAgentId($uploadId)) { echo 'no valid copyright agent found'; return; } $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($uploadId); $toprow = $this->uploadDao->getItemTreeBounds($itemId, $uploadtree_tablename); $extraWhere = 'agent_fk=' . $this->agentId . ' AND lft>' . $toprow->getLeft() . ' AND rgt<' . $toprow->getRight(); $allCopyrightEntries = $this->copyrightDao->getAllEntries('copyright', $uploadId, $uploadtree_tablename, empty($this->type) || $this->type == 'all' ? null : $this->type, false, null, $extraWhere); $modeMask = empty($this->includeContainer) ? 3 << 28 : 1 << 28; $sql = "SELECT uploadtree_pk, ufile_name, lft, rgt FROM {$uploadtree_tablename} \n WHERE upload_fk=\$1 AND lft>\$2 AND rgt<\$3 AND (ufile_mode & \$4) = 0\n ORDER BY uploadtree_pk"; $this->dbManager->prepare($outerStmt = __METHOD__ . '.loopThroughAllRecordsInTree', $sql); $outerresult = $this->dbManager->execute($outerStmt, array($toprow->getUploadId(), $toprow->getLeft(), $toprow->getRight(), $modeMask)); while ($row = $this->dbManager->fetchArray($outerresult)) { $this->printRow($row, $uploadtree_tablename, $allCopyrightEntries); //$this->uploadDao->getParentItemBounds($uploadId)->getItemId()); } $this->dbManager->freeResult($outerresult); }
/** * @param int $uploadTreeId * @param int $Folder * @param int $Upload * @return string */ function outputItemHtml($uploadTreeId, $Folder, $Upload) { global $container; $dbManager = $container->get('db.manager'); $show = 'quick'; $html = ''; $uploadtree_tablename = ""; if (!empty($uploadTreeId)) { $sql = "SELECT ufile_mode, upload_fk FROM uploadtree WHERE uploadtree_pk = \$1"; $row = $dbManager->getSingleRow($sql, array($uploadTreeId)); $Upload = $row['upload_fk']; if (!$this->uploadDao->isAccessible($Upload, Auth::getGroupId())) { $this->vars['message'] = _("Permission Denied"); return $this->render('include/base.html.twig'); } if (!Iscontainer($row['ufile_mode'])) { global $Plugins; $View =& $Plugins[plugin_find_id("view")]; if (!empty($View)) { $this->vars['content'] = $View->ShowView(NULL, "browse"); return $this->render('include/base.html.twig'); } } $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($row['upload_fk']); $html .= Dir2Browse($this->Name, $uploadTreeId, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "\n"; } else { if (!empty($Upload)) { $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($Upload); $html .= Dir2BrowseUpload($this->Name, $Upload, NULL, 1, "Browse", $uploadtree_tablename) . "\n"; } } if (empty($Upload)) { $this->vars['show'] = $show; $this->ShowFolder($Folder); return $html; } if (empty($uploadTreeId)) { try { $uploadTreeId = $this->uploadDao->getUploadParent($Upload); } catch (Exception $e) { $this->vars['message'] = $e->getMessage(); return $this->render('include/base.html.twig'); } } $html .= $this->ShowItem($Upload, $uploadTreeId, $show, $Folder, $uploadtree_tablename); $this->vars['content'] = $html; return $this->render('include/base.html.twig'); }
function OutputOpen() { if ($this->State != PLUGIN_STATE_READY) { return 0; } $uploadId = GetParm("upload", PARM_INTEGER); if (empty($uploadId)) { return; } $uploadTreeId = GetParm("item", PARM_INTEGER); if (empty($uploadTreeId)) { $parent = $this->uploadDao->getUploadParent($uploadId); if (!isset($parent)) { $this->invalidParm = true; return; } $item = $this->uploadDao->getNextItem($uploadId, $parent); if ($item === UploadDao::NOT_FOUND) { $this->invalidParm = true; return; } $uploadTreeId = $item->getId(); return new RedirectResponse(Traceback_uri() . '?mod=' . $this->Name . Traceback_parm_keep(array("upload", "show")) . "&item={$uploadTreeId}"); } $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId); $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName); if (Isdir($uploadEntry['ufile_mode']) || Iscontainer($uploadEntry['ufile_mode'])) { $parent = $this->uploadDao->getUploadParent($uploadId); if (!isset($parent)) { $this->invalidParm = true; return; } $item = $this->uploadDao->getNextItem($uploadId, $parent); if ($item === UploadDao::NOT_FOUND) { $this->invalidParm = true; return; } $uploadTreeId = $item->getId(); return new RedirectResponse(Traceback_uri() . '?mod=' . $this->Name . Traceback_parm_keep(array("upload", "show")) . "&item={$uploadTreeId}"); } return parent::OutputOpen(); }
/** @expectedException \Exception * @expectedExceptionMessage Missing upload tree parent for upload */ public function testGetUploadParentFromNonExistingTree() { $this->uploadDao->getUploadParent(34); }
protected function handle(Request $request) { $vars = array(); $uploadId = intval($request->get('upload')); $uploadTreeId = intval($request->get('item')); if (empty($uploadTreeId) || empty($uploadId)) { $text = _("Empty Input"); $vars['message'] = "<h2>{$text}</h2>"; return $this->responseBad($vars); } if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) { $text = _("Permission Denied"); $vars['message'] = "<h2>{$text}</h2>"; return $this->responseBad(); } $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId); $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName); if (Isdir($uploadEntry['ufile_mode']) || Iscontainer($uploadEntry['ufile_mode'])) { $parent = $this->uploadDao->getUploadParent($uploadEntry['upload_fk']); if (!isset($parent)) { return $this->responseBad(); } $uploadTree = $this->uploadDao->getNextItem($uploadEntry['upload_fk'], $parent); if ($uploadTree === UploadDao::NOT_FOUND) { return $this->responseBad(); } $uploadTreeId = $uploadTree->getId(); return new RedirectResponse(Traceback_uri() . '?mod=' . $this->getName() . Traceback_parm_keep(array('show', 'upload')) . "&item={$uploadTreeId}"); } if (empty($uploadTreeId)) { return $this->responseBad('No item selected.'); } $copyrightDecisionMap = $this->decisionTypes->getMap(); $vars['micromenu'] = Dir2Browse($this->modBack, $uploadTreeId, NULL, $showBox = 0, "View", -1, '', '', $uploadTreeTableName); $lastItem = GetParm("lastItem", PARM_INTEGER); $changed = GetParm("changedSomething", PARM_STRING); $userId = Auth::getUserId(); if (!empty($lastItem) && $changed == "true") { $lastUploadEntry = $this->uploadDao->getUploadEntry($lastItem, $uploadTreeTableName); $clearingType = $_POST['clearingTypes']; $description = $_POST['description']; $textFinding = $_POST['textFinding']; $comment = $_POST['comment']; $this->copyrightDao->saveDecision($this->decisionTableName, $lastUploadEntry['pfile_fk'], $userId, $clearingType, $description, $textFinding, $comment); } $scanJobProxy = new ScanJobProxy($this->agentDao, $uploadId); $scanJobProxy->createAgentStatus(array($this->agentName)); $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds(); $highlights = array(); if (array_key_exists($this->agentName, $selectedScanners)) { $latestXpAgentId = $selectedScanners[$this->agentName]; $highlights = $this->copyrightDao->getHighlights($uploadTreeId, $this->tableName, $latestXpAgentId, $this->typeToHighlightTypeMap); } if (count($highlights) < 1) { $vars['message'] = _("No ") . $this->tableName . _(" data is available for this file."); } /* @var $view ui_view */ $view = plugin_find("view"); $theView = $view->getView(null, null, $showHeader = 0, "", $highlights, false, true); list($pageMenu, $textView) = $theView; list($description, $textFinding, $comment, $decisionType) = $this->copyrightDao->getDecision($this->decisionTableName, $uploadEntry['pfile_fk']); $vars['description'] = $description; $vars['textFinding'] = $textFinding; $vars['comment'] = $comment; $vars['itemId'] = $uploadTreeId; $vars['uploadId'] = $uploadId; $vars['pageMenu'] = $pageMenu; $vars['textView'] = $textView; $vars['legendBox'] = $this->legendBox(); $vars['uri'] = Traceback_uri() . "?mod=" . $this->Name; $vars['optionName'] = $this->optionName; $vars['formName'] = "CopyRightForm"; $vars['ajaxAction'] = $this->ajaxAction; $vars['skipOption'] = $this->skipOption; $vars['selectedClearingType'] = $decisionType; $vars['clearingTypes'] = $copyrightDecisionMap; $vars['xptext'] = $this->xptext; $agentId = intval($request->get("agent")); $vars = array_merge($vars, $this->additionalVars($uploadId, $uploadTreeId, $agentId)); return $this->render('ui-cp-view.html.twig', $this->mergeWithDefault($vars)); }