protected function getJobAndJobqueue($groupId, $upload, $addUploads) { $uploadId = $upload->getId(); $readMeOssAgent = plugin_find('agent_readmeoss'); $userId = Auth::getUserId(); $jqCmdArgs = $readMeOssAgent->uploadsAdd($addUploads); $dbManager = $this->getObject('db.manager'); $sql = 'SELECT jq_pk,job_pk FROM jobqueue, job ' . 'WHERE jq_job_fk=job_pk AND jq_type=$1 AND job_group_fk=$4 AND job_user_fk=$3 AND jq_args=$2 AND jq_endtime IS NULL'; $params = array($readMeOssAgent->AgentName, $uploadId, $userId, $groupId); $log = __METHOD__; if ($jqCmdArgs) { $sql .= ' AND jq_cmd_args=$5'; $params[] = $jqCmdArgs; $log .= '.args'; } else { $sql .= ' AND jq_cmd_args IS NULL'; } $scheduled = $dbManager->getSingleRow($sql, $params, $log); if (!empty($scheduled)) { return array($scheduled['job_pk'], $scheduled['jq_pk']); } $jobId = JobAddJob($userId, $groupId, $upload->getFilename(), $uploadId); $error = ""; $jobQueueId = $readMeOssAgent->AgentAdd($jobId, $uploadId, $error, array(), $jqCmdArgs); if ($jobQueueId < 0) { throw new Exception(_("Cannot schedule") . ": " . $error); } return array($jobId, $jobQueueId); }
/** * @param Request $request * @return Response */ protected function handle(Request $request) { $errorMessage = ""; $jobqueueId = -1; $userId = $_SESSION['UserId']; $groupId = $_SESSION['GroupId']; $uploadId = intval($_POST['uploadId']); $agentName = $_POST['agentName']; if ($uploadId > 0) { $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId); $ourPlugin = plugin_find($agentName); $jobqueueId = $ourPlugin->AgentAdd($jobId, $uploadId, $errorMessage, array()); } else { $errorMessage = "bad request"; } ReportCachePurgeAll(); $headers = array('Content-type' => 'text/json'); if (empty($errorMessage) && $jobqueueId > 0) { return new Response(json_encode(array("jqid" => $jobqueueId)), Response::HTTP_OK, $headers); } else { return new Response(json_encode(array("error" => $errorMessage)), Response::HTTP_INTERNAL_SERVER_ERROR, $headers); } }
protected function handle(Request $request) { $uploadId = intval($request->get("upload")); if (empty($uploadId)) { throw new Exception('missing upload id'); } $parmAgentList = MenuHook::getAgentPluginNames("ParmAgents"); $plainAgentList = MenuHook::getAgentPluginNames("Agents"); $agentList = array_merge($plainAgentList, $parmAgentList); $skipAgents = array("agent_unpack", "wget_agent"); $out = ""; $relevantAgents = array(); foreach ($agentList as $agent) { if (array_search($agent, $skipAgents) !== false) { continue; } $plugin = plugin_find($agent); if ($plugin->AgentHasResults($uploadId) != 1 && $this->jobNotYetScheduled($plugin->AgentName, $uploadId)) { $out .= "<option value='" . $agent . "'>"; $out .= htmlentities($plugin->Title); $out .= "</option>\n"; $relevantAgents[$agent] = $plugin->Title; } } $out = '<select multiple size="10" id="agents" name="agents[]">' . $out . '</select>'; return new Response($out, Response::HTTP_OK, array('Content-Type' => 'text/plain')); }
/** * @param array $vars * @return string */ public function renderContent(&$vars) { $renderer = $GLOBALS['container']->get('twig.environment'); $vars['isNinkaInstalled'] = false; if ($ninkaUi = plugin_find('agent_ninka')) { $vars['isNinkaInstalled'] = $ninkaUi->isNinkaInstalled(); } return $renderer->loadTemplate('agent_decider.html.twig')->render($vars); }
/** * @overwrite * @param int $uploadId * @param int $uploadTreeId * @param int $agentId * @return array */ protected function additionalVars($uploadId, $uploadTreeId, $agentId) { if (empty($agentId)) { $agentMap = $this->agentDao->getLatestAgentResultForUpload($uploadId, array('copyright')); $agentId = array_key_exists('copyright', $agentMap) ? $agentMap['copyright'] : 0; } $modCopyrightHist = plugin_find('copyright-hist'); $filter = ''; list($output, $tableVars) = $modCopyrightHist->getTableForSingleType('statement', _("Copyright"), $uploadId, $uploadTreeId, $filter, $agentId); $vars = array('statement' => $tableVars, 'content' => "{$output}\n", 'script' => '<script>$(document).ready(function() { tableCopyright = createTablestatement(); } );</script>'); return $vars; }
protected function postUploadAddJobs(Request $request, $fileName, $uploadId, $jobId = null, $wgetDependency = false) { $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); if ($jobId === null) { $jobId = JobAddJob($userId, $groupId, $fileName, $uploadId); } $dummy = ""; $adj2nestDependencies = array(); if ($wgetDependency) { $adj2nestDependencies = array(array('name' => 'agent_unpack', AgentPlugin::PRE_JOB_QUEUE => array('wget_agent'))); } $adj2nestplugin = \plugin_find('agent_adj2nest'); $adj2nestplugin->AgentAdd($jobId, $uploadId, $dummy, $adj2nestDependencies); $checkedAgents = checkedAgents(); AgentSchedule($jobId, $uploadId, $checkedAgents); $errorMsg = ''; $parmAgentList = MenuHook::getAgentPluginNames("ParmAgents"); $plainAgentList = MenuHook::getAgentPluginNames("Agents"); $agentList = array_merge($plainAgentList, $parmAgentList); foreach ($parmAgentList as $parmAgent) { $agent = plugin_find($parmAgent); $agent->scheduleAgent($jobId, $uploadId, $errorMsg, $request, $agentList); } $status = GetRunnableJobList(); $message = empty($status) ? _("Is the scheduler running? ") : ""; $jobUrl = Traceback_uri() . "?mod=showjobs&upload={$uploadId}"; $message .= _("The file") . " " . $fileName . " " . _("has been uploaded. It is") . ' <a href=' . $jobUrl . '>upload #' . $uploadId . "</a>.\n"; if ($request->get('public') == self::PUBLIC_GROUPS) { $this->getObject('dao.upload.permission')->makeAccessibleToAllGroupsOf($uploadId, $userId); } return $message; }
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)); }
/** * \brief Queue an agent. This is a simple version of AgentAdd() that can be * used by multiple plugins that only use upload_pk as jqargs. * Before queuing, check if agent needs to be queued. It doesn't need to be queued if: * - It is already queued * - It has already been run by the latest agent version * * \param $plugin caller plugin object * \param $job_pk * \param $upload_pk * \param $ErrorMsg - error message on failure * \param $Dependencies - array of named dependencies. Each array element is the plugin name. * For example, array(agent_adj2nest, agent_pkgagent). * Typically, this will just be array(agent_adj2nest). * \param $jqargs (optional) jobqueue.jq_args * * \returns * - jq_pk Successfully queued * - 0 Not queued, latest version of agent has previously run successfully * - -1 Not queued, error, error string in $ErrorMsg **/ function CommonAgentAdd($plugin, $job_pk, $upload_pk, &$ErrorMsg, $Dependencies, $jqargs = "", $jq_cmd_args = NULL) { global $Plugins; $Deps = array(); $DependsEmpty = array(); /* check if the latest agent has already been run */ if ($plugin->AgentHasResults($upload_pk) == 1) { return 0; } /* if it is already scheduled, then return success */ if (($jq_pk = IsAlreadyScheduled($job_pk, $plugin->AgentName, $upload_pk)) != 0) { return $jq_pk; } /* queue up dependencies */ foreach ($Dependencies as $Dependency) { if (is_array($Dependency)) { $PluginName = $Dependency['name']; $DepArgs = $Dependency['args']; } else { $PluginName = $Dependency; $DepArgs = null; } $DepPlugin = plugin_find($PluginName); if ($DepPlugin === null) { $ErrorMsg = "Invalid plugin name: {$PluginName}, (CommonAgentAdd())"; return -1; } if (($Deps[] = $DepPlugin->AgentAdd($job_pk, $upload_pk, $ErrorMsg, $DependsEmpty, $DepArgs)) == -1) { return -1; } } /* schedule AgentName */ if (empty($jqargs)) { $jqargs = $upload_pk; } $jq_pk = JobQueueAdd($job_pk, $plugin->AgentName, $jqargs, "", $Deps, NULL, $jq_cmd_args); if (empty($jq_pk)) { $ErrorMsg = _("Failed to insert agent {$plugin->AgentName} into job queue. jqargs: {$jqargs}"); return -1; } /* Tell the scheduler to check the queue. */ $success = fo_communicate_with_scheduler("database", $output, $error_msg); if (!$success) { $ErrorMsg = $error_msg . "\n" . $output; } return $jq_pk; }
/** * @param int $jobId * @param int $uploadId * @param &string $errorMsg * @param mixed $dependency * @return int */ protected function implicitAgentAdd($jobId, $uploadId, &$errorMsg, $dependency) { if (is_array($dependency)) { $pluginName = $dependency['name']; $depArgs = array_key_exists('args', $dependency) ? $dependency['args'] : null; $preJq = array_key_exists(self::PRE_JOB_QUEUE, $dependency) ? $dependency[self::PRE_JOB_QUEUE] : array(); } else { $pluginName = $dependency; $depArgs = null; $preJq = array(); } $depPlugin = plugin_find($pluginName); if (!$depPlugin) { $errorMsg = "Invalid plugin name: {$pluginName}, (implicitAgentAdd())"; return -1; } return $depPlugin->AgentAdd($jobId, $uploadId, $errorMsg, $preJq, $depArgs); }
function doEdit($userId, $groupId, $itemId) { $licenses = GetParm("licenseNumbersToBeSubmitted", PARM_RAW); $removed = $_POST['removed'] === 't' || $_POST['removed'] === 'true'; $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId); $uploadId = $itemTreeBounds->getUploadId(); $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId); if (isset($licenses)) { if (!is_array($licenses)) { return $this->errorJson("bad license array"); } foreach ($licenses as $licenseId) { if (intval($licenseId) <= 0) { return $this->errorJson("bad license"); } $this->clearingDao->insertClearingEvent($itemId, $userId, $groupId, $licenseId, $removed, ClearingEventTypes::USER, $reportInfo = '', $comment = '', $jobId); } } /** @var agent_fodecider $deciderPlugin */ $deciderPlugin = plugin_find("agent_deciderjob"); $conflictStrategyId = null; $errorMsg = ""; $jq_pk = $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId); /** after changing one license, purge all the report cache */ ReportCachePurgeAll(); //Todo: Change sql statement of fossology/src/buckets/agent/leaf.c line 124 to take the newest valid license, then uncomment this line // $this->ChangeBuckets(); // change bucket accordingly if (empty($errorMsg) && $jq_pk > 0) { return new JsonResponse(array("jqid" => $jq_pk)); } else { return $this->errorJson($errorMsg, 500); } }
/** * \brief search in available plugins and return all agents * * \return Plugin[] list of checked agent plugins, mapped by name */ function listAgents() { $agents = array(); $agentList = menu_find("Agents", $Depth); if (!empty($agentList)) { foreach ($agentList as $agentItem) { /* The URI below contains the agent name e.g agent_license, this is not be confused with the Name attribute in the class, for example, the Name attribute for agent_license is: Schedule License Analysis */ $agentPlugin = plugin_find($agentItem->URI); if (empty($agentPlugin)) { continue; } $name = htmlentities($agentPlugin->Name); $agents[$name] = $agentPlugin; } } return $agents; }
private function getJobQueueId($uploadTreeId) { $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId); $uploadId = intval($uploadEntry['upload_fk']); if ($uploadId <= 0) { throw new Exception('permission denied'); } $bulkScope = filter_input(INPUT_POST, 'bulkScope'); switch ($bulkScope) { case 'u': $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($uploadId); $row = $this->dbManager->getSingleRow("SELECT uploadtree_pk FROM {$uploadTreeTable} WHERE upload_fk = \$1 ORDER BY uploadtree_pk LIMIT 1", array($uploadId), __METHOD__ . "adam" . $uploadTreeTable); $uploadTreeId = $row['uploadtree_pk']; break; case 'f': if (!Isdir($uploadEntry['ufile_mode']) && !Iscontainer($uploadEntry['ufile_mode']) && !Isartifact($uploadEntry['ufile_mode'])) { $uploadTreeId = $uploadEntry['parent'] ?: $uploadTreeId; } break; default: throw new InvalidArgumentException('bad scope request'); } $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); $refText = filter_input(INPUT_POST, 'refText'); $action = filter_input(INPUT_POST, 'bulkAction'); $licenseId = GetParm('licenseId', PARM_INTEGER); $removing = $action === 'remove'; $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseId, $removing, $refText); if ($bulkId <= 0) { throw new Exception('cannot insert bulk reference'); } $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $job_pk = JobAddJob($userId, $groupId, $uploadName, $uploadId); /** @var DeciderJobAgentPlugin $deciderPlugin */ $deciderPlugin = plugin_find("agent_deciderjob"); $dependecies = array(array('name' => 'agent_monk_bulk', 'args' => $bulkId)); $conflictStrategyId = intval(filter_input(INPUT_POST, 'forceDecision')); $errorMsg = ''; $jqId = $deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies, $conflictStrategyId); if (!empty($errorMsg)) { throw new Exception(str_replace('<br>', "\n", $errorMsg)); } return $jqId; }
/** * @brief Add an upload to multiple agents. * @param int $uploadId * @param string[] $agentsToStart - list of agents * @return NULL on success, error message string on failure */ private function agentsAdd($uploadId, $agentsToStart, Request $request) { if (!is_array($agentsToStart)) { return "bad parameters"; } if (!$uploadId) { return "agent-add.php AgentsAdd(): No upload_pk specified"; } /* @var $upload Upload */ $upload = $GLOBALS['container']->get('dao.upload')->getUpload($uploadId); if ($upload === null) { return _("Upload") . " " . $uploadId . " " . _("not found"); } $agents = array(); $parmAgentList = MenuHook::getAgentPluginNames("ParmAgents"); $plainAgentList = MenuHook::getAgentPluginNames("Agents"); $agentList = array_merge($plainAgentList, $parmAgentList); foreach ($agentList as $agentName) { if (in_array($agentName, $agentsToStart)) { $agents[$agentName] = plugin_find($agentName); } } if (count($agents) == 0) { return _("no valid agent specified"); } $jobId = JobAddJob(Auth::getUserId(), Auth::getGroupId(), $upload->getFilename(), $uploadId); $errorMsg = ''; foreach ($parmAgentList as $parmAgent) { $agent = plugin_find($parmAgent); $agent->scheduleAgent($jobId, $uploadId, $errorMsg, $request); } foreach ($agents as &$agent) { $rv = $agent->AgentAdd($jobId, $uploadId, $errorMsg, array()); if ($rv == -1) { return $errorMsg; } } return null; }
private function suggestLicenseId($str) { /* @var $monkOneShotPlugin \Fossology\Monk\UI\Oneshot */ $monkOneShotPlugin = plugin_find("oneshot-monk"); if (null !== $monkOneShotPlugin) { return $monkOneShotPlugin->scanMonkRendered($str); } else { return array(array(), $str); } }
// Database connection /* Set SYSCONFDIR and set global (for backward compatibility) */ $SysConf = bootstrap(); global $container; /** @var TimingLogger $logger */ $timingLogger = $container->get("log.timing"); $timingLogger->logWithStartTime("bootstrap", $startTime); /* Initialize global system configuration variables $SysConfig[] */ $timingLogger->tic(); ConfigInit($SYSCONFDIR, $SysConf); $timingLogger->toc("setup init"); $timingLogger->tic(); plugin_load(); plugin_preinstall(); plugin_postinstall(); $timingLogger->toc("setup plugins"); $plugin = plugin_find(GetParm("mod", PARM_STRING) ?: HomePage::NAME); if ($plugin) { $timingLogger->tic(); $plugin->execute(); $timingLogger->toc("plugin execution"); } else { $linkUri = Traceback_uri() . "?mod=auth"; $errorText = _("Module unavailable or your login session timed out."); print "{$errorText} <P />"; $linkText = _("Click here to continue."); print "<a href=\"{$linkUri}\">{$linkText}</a>"; } plugin_unload(); $container->get("db.manager")->flushStats(); return 0;
/** * * @param int $uploadTreeId * @param Request $request * @return int $jobQueueId */ private function getJobQueueId($uploadTreeId, Request $request) { $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId); $uploadId = intval($uploadEntry['upload_fk']); $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); if ($uploadId <= 0 || !$this->uploadDao->isAccessible($uploadId, $groupId)) { throw new Exception('permission denied'); } $bulkScope = $request->get('bulkScope'); switch ($bulkScope) { case 'u': $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($uploadId); $topBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTable); $uploadTreeId = $topBounds->getItemId(); break; case 'f': if (!Isdir($uploadEntry['ufile_mode']) && !Iscontainer($uploadEntry['ufile_mode']) && !Isartifact($uploadEntry['ufile_mode'])) { $uploadTreeId = $uploadEntry['parent'] ?: $uploadTreeId; } break; default: throw new InvalidArgumentException('bad scope request'); } $refText = $request->get('refText'); $actions = $request->get('bulkAction'); $licenseRemovals = array(); foreach ($actions as $licenseAction) { $licenseRemovals[$licenseAction['licenseId']] = $licenseAction['action'] == 'remove'; } $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText); if ($bulkId <= 0) { throw new Exception('cannot insert bulk reference'); } $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $job_pk = JobAddJob($userId, $groupId, $uploadName, $uploadId); /** @var DeciderJobAgentPlugin $deciderPlugin */ $deciderPlugin = plugin_find("agent_deciderjob"); $dependecies = array(array('name' => 'agent_monk_bulk', 'args' => $bulkId)); $conflictStrategyId = intval($request->get('forceDecision')); $errorMsg = ''; $jqId = $deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies, $conflictStrategyId); if (!empty($errorMsg)) { throw new Exception(str_replace('<br>', "\n", $errorMsg)); } return $jqId; }
/** * @param array $vars * @return string */ public function renderFoot(&$vars) { $reuserPlugin = plugin_find('plugin_reuser'); return $reuserPlugin->renderFoot($vars); }
/** * \brief Given an $Uploadtree_pk, display: \n * (1) The histogram for the directory BY LICENSE. \n * (2) The file listing for the directory. * * \param $Uploadtree_pk * \param $Uri * \param $filter * \param $uploadtree_tablename * \param $Agent_pk - agent id */ protected function ShowUploadHist($upload_pk, $Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk) { list($ChildCount, $VF) = $this->getFileListing($Uploadtree_pk, $Uri, $uploadtree_tablename, $Agent_pk, $upload_pk); $this->vars['childcount'] = $ChildCount; $this->vars['fileListing'] = $VF; //TODO /*************************************** Problem: $ChildCount can be zero! This happens if you have a container that does not unpack to a directory. For example: file.gz extracts to archive.txt that contains a license. Same problem seen with .pdf and .Z files. Solution: if $ChildCount == 0, then just view the license! $ChildCount can also be zero if the directory is empty. ***************************************/ if ($ChildCount == 0) { $isADirectory = $this->isADirectory($Uploadtree_pk); if ($isADirectory) { return; } $ModLicView = plugin_find($this->viewName); return $ModLicView->execute(); } return $this->fillTables($upload_pk, $Uploadtree_pk, $filter, $Agent_pk, $VF); }
private function insertPermission($groupId, $uploadId, $permission, $uploadList) { $fileName = false; foreach ($uploadList as $uploadEntry) { if ($uploadEntry['upload_pk']) { $fileName = $uploadEntry['name']; } } if (empty($fileName)) { throw new \Exception('This upload is missing or inaccessible'); } $reuseBit = $permission & self::MOD_REUSE; if ($reuseBit) { $jobId = \JobAddJob(Auth::getUserId(), $groupId, $fileName, $uploadId); $reuserAgent = \plugin_find('agent_reuser'); $request = new Request(array('uploadToReuse' => "{$uploadId}," . Auth::getGroupId(), 'groupId' => $groupId)); $reuserAgent->scheduleAgent($jobId, $uploadId, $errorMsg, $request); if (!empty($errorMsg)) { throw new Exception($errorMsg); } $permission ^= $reuseBit; } $this->uploadPermDao->insertPermission($uploadId, $groupId, $permission); }