Exemplo n.º 1
0
 private function checkDecisionScopes()
 {
     $decScopes = new DecisionScopes();
     $scopeMap = $decScopes->getMap();
     $this->errors += $this->checkDatabaseEnum($tablename = 'clearing_decision', 'scope', $scopeMap);
     $decTypes = new DecisionTypes();
     $typeMap = $decTypes->getExtendedMap();
     $this->errors += $this->checkDatabaseEnum($tablename = 'clearing_decision', 'decision_type', $typeMap);
 }
Exemplo n.º 2
0
 protected function setUp()
 {
     global $container;
     $this->highlightDao = M::mock(HighlightDao::classname());
     $container->shouldReceive('get')->withArgs(array('dao.highlight'))->andReturn($this->highlightDao);
     $container->shouldReceive('get')->withArgs(array('dao.upload'))->andReturn(M::mock(UploadDao::classname()));
     $container->shouldReceive('get')->withArgs(array('dao.clearing'))->andReturn(M::mock(ClearingDao::classname()));
     $container->shouldReceive('get')->withArgs(array('decision.types'))->andReturn(M::mock(DecisionTypes::classname()));
     $container->shouldReceive('get')->withArgs(array('businessrules.clearing_decision_processor'))->andReturn(M::mock(ClearingDecisionProcessor::classname()));
     $container->shouldReceive('get')->withArgs(array('businessrules.agent_license_event_processor'))->andReturn(M::mock(AgentLicenseEventProcessor::classname()));
     $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
 }
Exemplo n.º 3
0
 /**
  * @param ClearingDecision[] $clearingDecWithLicenses
  * @return array
  */
 private function getClearingHistory($clearingDecWithLicenses)
 {
     $table = array();
     $scope = new DecisionScopes();
     foreach ($clearingDecWithLicenses as $clearingDecision) {
         $licenseOutputs = array();
         foreach ($clearingDecision->getClearingLicenses() as $lic) {
             $shortName = $lic->getShortName();
             $licenseOutputs[$shortName] = $lic->isRemoved() ? "<span style=\"color:red\">{$shortName}</span>" : $shortName;
         }
         ksort($licenseOutputs, SORT_STRING);
         $row = array('date' => $clearingDecision->getTimeStamp(), 'username' => $clearingDecision->getUserName(), 'scope' => $scope->getTypeName($clearingDecision->getScope()), 'type' => $this->decisionTypes->getTypeName($clearingDecision->getType()), 'licenses' => implode(", ", $licenseOutputs));
         $table[] = $row;
     }
     return $table;
 }
Exemplo n.º 4
0
 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));
 }