private static function getConstraintCondition(ItemTreeBounds $itemTreeBounds, $constraint) { switch ($constraint) { case self::CONDITION_UPLOAD: $uploadId = $itemTreeBounds->getUploadId(); return "upload_fk = {$uploadId}"; case self::CONDITION_RANGE: $left = $itemTreeBounds->getLeft(); $right = $itemTreeBounds->getRight(); return "lft BETWEEN {$left} AND {$right}"; case self::CONDITION_PLAIN_FILES: return '((ufile_mode & (3<<28))=0) AND pfile_fk != 0'; default: throw new \InvalidArgumentException("constraint {$constraint} is not defined"); } }
/** * \brief Given an $Uploadtree_pk, display: * - The histogram for the directory BY LICENSE. * - The file listing for the directory. */ private function showUploadHist(ItemTreeBounds $itemTreeBounds) { $groupId = Auth::getGroupId(); $selectedAgentId = GetParm('agentId', PARM_INTEGER); $tag_pk = GetParm("tag", PARM_INTEGER); $uploadId = $itemTreeBounds->getUploadId(); $scannerAgents = array_keys($this->agentNames); $scanJobProxy = new ScanJobProxy($this->agentDao, $uploadId); $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents); $agentMap = $scanJobProxy->getAgentMap(); $vars = array('agentId' => GetParm('agentId', PARM_INTEGER), 'agentShowURI' => Traceback_uri() . '?mod=' . Traceback_parm(), 'agentMap' => $agentMap, 'scanners' => $scannerVars); $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $selectedAgentId; if (!empty($agentMap)) { $licVars = $this->createLicenseHistogram($itemTreeBounds->getItemId(), $tag_pk, $itemTreeBounds, $selectedAgentIds, $groupId); $vars = array_merge($vars, $licVars); } $this->licenseProjector = new LicenseMap($this->getObject('db.manager'), $groupId, LicenseMap::CONCLUSION, true); $dirVars = $this->countFileListing($itemTreeBounds); $childCount = $dirVars['iTotalRecords']; /*************************************** * Problem: $ChildCount can be zero 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) { return new RedirectResponse("?mod=view-license" . Traceback_parm_keep(array("upload", "item"))); } $vars['licenseUri'] = Traceback_uri() . "?mod=popup-license&rf="; $vars['bulkUri'] = Traceback_uri() . "?mod=popup-license"; return array_merge($vars, $dirVars); }
/** * @param string[][][] &$filesWithLicenses * @param ItemTreeBounds $itemTreeBounds */ protected function addClearingStatus(&$filesWithLicenses, ItemTreeBounds $itemTreeBounds) { $alreadyClearedUploadTreeView = new UploadTreeProxy($itemTreeBounds->getUploadId(), array(UploadTreeProxy::OPT_SKIP_THESE => UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED, UploadTreeProxy::OPT_ITEM_FILTER => "AND (lft BETWEEN " . $itemTreeBounds->getLeft() . " AND " . $itemTreeBounds->getRight() . ")", UploadTreeProxy::OPT_GROUP_ID => $this->groupId), $itemTreeBounds->getUploadTreeTableName(), 'already_cleared_uploadtree' . $itemTreeBounds->getUploadId()); $alreadyClearedUploadTreeView->materialize(); $filesThatShouldStillBeCleared = $alreadyClearedUploadTreeView->getNonArtifactDescendants($itemTreeBounds); $alreadyClearedUploadTreeView->unmaterialize(); $uploadTreeIds = array_keys($filesWithLicenses); foreach ($uploadTreeIds as $uploadTreeId) { $filesWithLicenses[$uploadTreeId]['isCleared'] = false == array_key_exists($uploadTreeId, $filesThatShouldStillBeCleared); } }
/** * @param ItemTreeBounds $itemTreeBounds * @param bool $isFlat plain files from sub*folders instead of folders * @return array */ public function countNonArtifactDescendants(ItemTreeBounds $itemTreeBounds, $isFlat = true) { $stmt = __METHOD__; $sql = "SELECT count(*) FROM " . $itemTreeBounds->getUploadTreeTableName() . " ut " . "WHERE ut.upload_fk=\$1"; $params = array($itemTreeBounds->getUploadId()); if (!$isFlat) { $stmt = __METHOD__ . '.parent'; $params[] = $itemTreeBounds->getItemId(); $sql .= " AND ut.ufile_mode & (1<<28) = 0 AND ut.realparent = \$2"; } else { $params[] = $itemTreeBounds->getLeft(); $params[] = $itemTreeBounds->getRight(); $sql .= " AND ut.ufile_mode & (3<<28) = 0 AND (ut.lft BETWEEN \$2 AND \$3)"; } $descendants = $this->dbManager->getSingleRow($sql, $params); return $descendants['count']; }
/** * @param ItemTreeBounds $itemTreeBounds * @return array */ public function getNonArtifactDescendants(ItemTreeBounds $itemTreeBounds) { $uploadExpr = '$' . (count($this->params) + 1); $lftExpr = '$' . (count($this->params) + 2); $rgtExpr = '$' . (count($this->params) + 3); $dbManager = $GLOBALS['container']->get('db.manager'); $sql = "SELECT u.uploadtree_pk FROM " . $this->getDbViewName() . " u " . "WHERE u.upload_fk={$uploadExpr} AND (u.lft BETWEEN {$lftExpr} AND {$rgtExpr}) AND u.ufile_mode & (3<<28) = 0"; $stmt = __METHOD__ . '.' . $this->getDbViewName(); if (!$this->materialized) { $sql = $this->asCTE() . ' ' . $sql; $stmt .= '.cte'; } $dbManager->prepare($stmt, $sql); $params = array_merge($this->params, array($itemTreeBounds->getUploadId(), $itemTreeBounds->getLeft(), $itemTreeBounds->getRight())); $res = $dbManager->execute($stmt, $params); $descendants = array(); while ($row = $dbManager->fetchArray($res)) { $descendants[$row['uploadtree_pk']] = 1; } $dbManager->freeResult($res); return $descendants; }
public function getLicenseShortnamesContained(ItemTreeBounds $itemTreeBounds, $latestSuccessfulAgentIds = null, $filterLicenses = array('VOID')) { $uploadTreeTableName = $itemTreeBounds->getUploadTreeTableName(); $noLicenseFoundStmt = empty($filterLicenses) ? "" : " AND rf_shortname NOT IN (" . implode(", ", array_map(function ($name) { return "'" . $name . "'"; }, $filterLicenses)) . ")"; $statementName = __METHOD__ . '.' . $uploadTreeTableName; $agentFilter = ''; if (is_array($latestSuccessfulAgentIds)) { $agentIdSet = "{" . implode(',', $latestSuccessfulAgentIds) . "}"; $statementName .= ".{$agentIdSet}"; $agentFilter = " AND agent_fk=ANY('{$agentIdSet}')"; } $this->dbManager->prepare($statementName, "SELECT license_ref.rf_shortname\n FROM license_file JOIN license_ref ON license_file.rf_fk = license_ref.rf_pk\n INNER JOIN {$uploadTreeTableName} uploadTree ON uploadTree.pfile_fk=license_file.pfile_fk\n WHERE upload_fk=\$1\n AND lft BETWEEN \$2 AND \$3\n {$noLicenseFoundStmt} {$agentFilter}\n GROUP BY rf_shortname\n ORDER BY rf_shortname ASC"); $result = $this->dbManager->execute($statementName, array($itemTreeBounds->getUploadId(), $itemTreeBounds->getLeft(), $itemTreeBounds->getRight())); $licenses = array(); while ($row = $this->dbManager->fetchArray($result)) { $licenses[] = $row['rf_shortname']; } $this->dbManager->freeResult($result); return $licenses; }
public function testGetUploadId() { assertThat($this->itemTreeBounds->getUploadId(), is($this->uploadId)); }
/** * @param ItemTreeBounds $item * @param string $hash * @param int $userId * @param string $cpTable */ public function rollbackTable($item, $hash, $userId, $cpTable = 'copyright') { $itemTable = $item->getUploadTreeTableName(); $stmt = __METHOD__ . ".{$cpTable}.{$itemTable}"; $params = array($hash, $item->getLeft(), $item->getRight(), $userId); $sql = "UPDATE {$cpTable} AS cpr SET content = cpa.oldtext, hash = \$1\n FROM " . $cpTable . "_audit as cpa, {$itemTable} AS ut\n WHERE cpr.pfile_fk = ut.pfile_fk\n AND cpr.ct_pk = cpa.ct_fk\n AND md5(cpa.oldtext) = \$1\n AND ( ut.lft BETWEEN \$2 AND \$3 )\n AND cpa.user_fk=\$4"; if ('uploadtree_a' == $item->getUploadTreeTableName()) { $params[] = $item->getUploadId(); $sql .= " AND ut.upload_fk=\$" . count($params); $stmt .= '.upload'; } $this->dbManager->prepare($stmt, "{$sql}"); $resource = $this->dbManager->execute($stmt, $params); $this->dbManager->freeResult($resource); }
/** * @param $tagId * @param ItemTreeBounds $itemTreeBounds * @param $UniqueTagArray * @param $selectedAgentId * @param int $groupId * @param ScanJobProxy $scanJobProxy * @return array */ private function createFileListing($tagId, ItemTreeBounds $itemTreeBounds, &$UniqueTagArray, $selectedAgentId, $groupId, $scanJobProxy) { if (!empty($selectedAgentId)) { $agentName = $this->agentDao->getAgentName($selectedAgentId); $selectedScanners = array($agentName => $selectedAgentId); } else { $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds(); } /** change the license result when selecting one version of nomos */ $uploadId = $itemTreeBounds->getUploadId(); $isFlat = isset($_GET['flatten']); if ($isFlat) { $options = array(UploadTreeProxy::OPT_RANGE => $itemTreeBounds); } else { $options = array(UploadTreeProxy::OPT_REALPARENT => $itemTreeBounds->getItemId()); } $descendantView = new UploadTreeProxy($uploadId, $options, $itemTreeBounds->getUploadTreeTableName(), 'uberItems'); $vars['iTotalDisplayRecords'] = $descendantView->count(); $columnNamesInDatabase = array($isFlat ? 'ufile_name' : 'lft'); $defaultOrder = array(array(0, "asc")); $orderString = $this->getObject('utils.data_tables_utility')->getSortingString($_GET, $columnNamesInDatabase, $defaultOrder); $offset = GetParm('iDisplayStart', PARM_INTEGER); $limit = GetParm('iDisplayLength', PARM_INTEGER); if ($offset) { $orderString .= " OFFSET {$offset}"; } if ($limit) { $orderString .= " LIMIT {$limit}"; } /* Get ALL the items under this Uploadtree_pk */ $sql = $descendantView->getDbViewQuery() . " {$orderString}"; $dbManager = $this->getObject('db.manager'); $dbManager->prepare($stmt = __METHOD__ . $orderString, $sql); $res = $dbManager->execute($stmt, $descendantView->getParams()); $descendants = $dbManager->fetchAll($res); $dbManager->freeResult($res); /* Filter out Children that don't have tag */ if (!empty($tagId)) { TagFilter($descendants, $tagId, $itemTreeBounds->getUploadTreeTableName()); } if (empty($descendants)) { $vars['fileData'] = array(); return $vars; } if ($isFlat) { $firstChild = reset($descendants); $lastChild = end($descendants); $nameRange = array($firstChild['ufile_name'], $lastChild['ufile_name']); } else { $nameRange = array(); } /******* File Listing ************/ $pfileLicenses = array(); foreach ($selectedScanners as $agentName => $agentId) { $licensePerPfile = $this->licenseDao->getLicenseIdPerPfileForAgentId($itemTreeBounds, $agentId, $isFlat, $nameRange); foreach ($licensePerPfile as $pfile => $licenseRow) { foreach ($licenseRow as $licId => $row) { $lic = $this->licenseProjector->getProjectedShortname($licId); $pfileLicenses[$pfile][$lic][$agentName] = $row; } } } $baseUri = Traceback_uri() . '?mod=fileBrowse' . Traceback_parm_keep(array('upload', 'folder', 'show')); $tableData = array(); global $Plugins; $latestSuccessfulAgentIds = $scanJobProxy->getLatestSuccessfulAgentIds(); foreach ($descendants as $child) { if (empty($child)) { continue; } $tableData[] = $this->createFileDataRow($child, $uploadId, $selectedAgentId, $pfileLicenses, $groupId, $baseUri, $UniqueTagArray, $isFlat, $latestSuccessfulAgentIds); } $vars['fileData'] = $tableData; return $vars; }
/** * @param string[][][] $filesWithLicenses * @param ItemTreeBounds $itemTreeBounds */ protected function addScannerResults(&$filesWithLicenses, $itemTreeBounds) { $uploadId = $itemTreeBounds->getUploadId(); $scannerAgents = array_keys($this->agentNames); $scanJobProxy = new ScanJobProxy($this->container->get('dao.agent'), $uploadId); $scanJobProxy->createAgentStatus($scannerAgents); $scannerIds = $scanJobProxy->getLatestSuccessfulAgentIds(); if (empty($scannerIds)) { return; } $selectedScanners = '{' . implode(',', $scannerIds) . '}'; $tableName = $itemTreeBounds->getUploadTreeTableName(); $stmt = __METHOD__ . '.scanner_findings'; $sql = "SELECT uploadtree_pk,rf_fk FROM {$tableName} ut, license_file\n WHERE ut.pfile_fk=license_file.pfile_fk AND rf_fk IS NOT NULL AND agent_fk=any(\$1)"; $param = array($selectedScanners); if ($tableName == 'uploadtree_a') { $param[] = $uploadId; $sql .= " AND upload_fk=\$" . count($param); $stmt .= $tableName; } $sql .= " GROUP BY uploadtree_pk,rf_fk"; $this->dbManager->prepare($stmt, $sql); $res = $this->dbManager->execute($stmt, $param); while ($row = $this->dbManager->fetchArray($res)) { $reportedLicenseId = $this->licenseMap->getProjectedId($row['rf_fk']); $shortName = $this->licenseMap->getProjectedShortname($reportedLicenseId); if ($shortName != 'No_license_found' && $shortName != 'Void') { $filesWithLicenses[$row['uploadtree_pk']]['scanner'][] = $shortName; $this->includedLicenseIds[$reportedLicenseId] = $reportedLicenseId; } } $this->dbManager->freeResult($res); return "licenseInfoInFile determined by Scanners {$selectedScanners}"; }
/** * @param $tagId * @param ItemTreeBounds $itemTreeBounds * @param $UniqueTagArray * @param $selectedAgentId * @param int $groupId * @param ScanJobProxy $scanJobProxy * @return array */ private function createFileListing($tagId, ItemTreeBounds $itemTreeBounds, &$UniqueTagArray, $selectedAgentId, $groupId, $scanJobProxy) { if (!empty($selectedAgentId)) { $agentName = $this->agentDao->getAgentName($selectedAgentId); $selectedScanners = array($agentName => $selectedAgentId); } else { $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds(); } /** change the license result when selecting one version of nomos */ $uploadId = $itemTreeBounds->getUploadId(); $isFlat = isset($_GET['flatten']); if ($isFlat) { $options = array(UploadTreeProxy::OPT_RANGE => $itemTreeBounds); } else { $options = array(UploadTreeProxy::OPT_REALPARENT => $itemTreeBounds->getItemId()); } $searchMap = array(); foreach (explode(' ', GetParm('sSearch', PARM_RAW)) as $pair) { $a = explode(':', $pair); if (count($a) == 1) { $searchMap['head'] = $pair; } else { $searchMap[$a[0]] = $a[1]; } } if (array_key_exists('ext', $searchMap) && strlen($searchMap['ext']) >= 1) { $options[UploadTreeProxy::OPT_EXT] = $searchMap['ext']; } if (array_key_exists('head', $searchMap) && strlen($searchMap['head']) >= 1) { $options[UploadTreeProxy::OPT_HEAD] = $searchMap['head']; } if (($rfId = GetParm('scanFilter', PARM_INTEGER)) > 0) { $options[UploadTreeProxy::OPT_AGENT_SET] = $selectedScanners; $options[UploadTreeProxy::OPT_SCAN_REF] = $rfId; } if (($rfId = GetParm('conFilter', PARM_INTEGER)) > 0) { $options[UploadTreeProxy::OPT_GROUP_ID] = Auth::getGroupId(); $options[UploadTreeProxy::OPT_CONCLUDE_REF] = $rfId; } $openFilter = GetParm('openCBoxFilter', PARM_RAW); if ($openFilter == 'true' || $openFilter == 'checked') { $options[UploadTreeProxy::OPT_AGENT_SET] = $selectedScanners; $options[UploadTreeProxy::OPT_GROUP_ID] = Auth::getGroupId(); $options[UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED] = true; } $descendantView = new UploadTreeProxy($uploadId, $options, $itemTreeBounds->getUploadTreeTableName(), 'uberItems'); $vars['iTotalDisplayRecords'] = $descendantView->count(); $columnNamesInDatabase = array($isFlat ? 'ufile_name' : 'lft'); $defaultOrder = array(array(0, "asc")); $orderString = $this->getObject('utils.data_tables_utility')->getSortingString($_GET, $columnNamesInDatabase, $defaultOrder); $offset = GetParm('iDisplayStart', PARM_INTEGER); $limit = GetParm('iDisplayLength', PARM_INTEGER); if ($offset) { $orderString .= " OFFSET {$offset}"; } if ($limit) { $orderString .= " LIMIT {$limit}"; } /* Get ALL the items under this Uploadtree_pk */ $sql = $descendantView->getDbViewQuery() . " {$orderString}"; $dbManager = $this->getObject('db.manager'); $dbManager->prepare($stmt = __METHOD__ . $orderString, $sql); $res = $dbManager->execute($stmt, $descendantView->getParams()); $descendants = $dbManager->fetchAll($res); $dbManager->freeResult($res); /* Filter out Children that don't have tag */ if (!empty($tagId)) { TagFilter($descendants, $tagId, $itemTreeBounds->getUploadTreeTableName()); } if (empty($descendants)) { $vars['fileData'] = array(); return $vars; } if ($isFlat) { $firstChild = reset($descendants); $lastChild = end($descendants); $nameRange = array($firstChild['ufile_name'], $lastChild['ufile_name']); } else { $nameRange = array(); } /******* File Listing ************/ $pfileLicenses = array(); foreach ($selectedScanners as $agentName => $agentId) { $licensePerPfile = $this->licenseDao->getLicenseIdPerPfileForAgentId($itemTreeBounds, $agentId, $isFlat, $nameRange); foreach ($licensePerPfile as $pfile => $licenseRow) { foreach ($licenseRow as $licId => $row) { $lic = $this->licenseProjector->getProjectedShortname($licId); $pfileLicenses[$pfile][$lic][$agentName] = $row; } } } $alreadyClearedUploadTreeView = new UploadTreeProxy($itemTreeBounds->getUploadId(), $options = array(UploadTreeProxy::OPT_SKIP_THESE => UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED, UploadTreeProxy::OPT_ITEM_FILTER => "AND (lft BETWEEN " . $itemTreeBounds->getLeft() . " AND " . $itemTreeBounds->getRight() . ")", UploadTreeProxy::OPT_GROUP_ID => $groupId), $itemTreeBounds->getUploadTreeTableName(), $viewName = 'already_cleared_uploadtree' . $itemTreeBounds->getUploadId()); $alreadyClearedUploadTreeView->materialize(); if (!$isFlat) { $this->filesThatShouldStillBeCleared = $alreadyClearedUploadTreeView->countMaskedNonArtifactChildren($itemTreeBounds->getItemId()); } else { $this->filesThatShouldStillBeCleared = $alreadyClearedUploadTreeView->getNonArtifactDescendants($itemTreeBounds); } $alreadyClearedUploadTreeView->unmaterialize(); $noLicenseUploadTreeView = new UploadTreeProxy($itemTreeBounds->getUploadId(), $options = array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense", UploadTreeProxy::OPT_ITEM_FILTER => "AND (lft BETWEEN " . $itemTreeBounds->getLeft() . " AND " . $itemTreeBounds->getRight() . ")", UploadTreeProxy::OPT_GROUP_ID => $groupId), $itemTreeBounds->getUploadTreeTableName(), $viewName = 'no_license_uploadtree' . $itemTreeBounds->getUploadId()); $noLicenseUploadTreeView->materialize(); if (!$isFlat) { $this->filesToBeCleared = $noLicenseUploadTreeView->countMaskedNonArtifactChildren($itemTreeBounds->getItemId()); } else { $this->filesToBeCleared = $noLicenseUploadTreeView->getNonArtifactDescendants($itemTreeBounds); } $noLicenseUploadTreeView->unmaterialize(); $allDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId, $isFlat); $editedMappedLicenses = $this->clearingFilter->filterCurrentClearingDecisions($allDecisions); $baseUri = Traceback_uri() . '?mod=license' . Traceback_parm_keep(array('upload', 'folder', 'show')); $tableData = array(); global $Plugins; $ModLicView =& $Plugins[plugin_find_id("view-license")]; $latestSuccessfulAgentIds = $scanJobProxy->getLatestSuccessfulAgentIds(); foreach ($descendants as $child) { if (empty($child)) { continue; } $tableData[] = $this->createFileDataRow($child, $uploadId, $selectedAgentId, $pfileLicenses, $groupId, $editedMappedLicenses, $baseUri, $ModLicView, $UniqueTagArray, $isFlat, $latestSuccessfulAgentIds); } $vars['fileData'] = $tableData; return $vars; }
/** * @param ItemTreeBounds $itemTreeBounds * @param int $groupId * @param int $userId */ protected function markDirectoryAsIrrelevantIfScannerDetected(ItemTreeBounds $itemTreeBounds, $groupId, $userId) { $params = array($itemTreeBounds->getLeft(), $itemTreeBounds->getRight(), $userId, $groupId, DecisionTypes::IRRELEVANT, DecisionScopes::ITEM); $options = array(UploadTreeProxy::OPT_SKIP_THESE => 'noLicense', UploadTreeProxy::OPT_ITEM_FILTER => ' AND (lft BETWEEN $1 AND $2)', UploadTreeProxy::OPT_GROUP_ID => '$4'); $uploadTreeProxy = new UploadTreeProxy($itemTreeBounds->getUploadId(), $options, $itemTreeBounds->getUploadTreeTableName()); $statementName = __METHOD__; $sql = $uploadTreeProxy->asCte() . ' INSERT INTO clearing_decision (uploadtree_fk,pfile_fk,user_fk,group_fk,decision_type,scope) SELECT uploadtree_pk itemid,pfile_fk pfile_id, $3, $4, $5, $6 FROM UploadTreeView'; $this->dbManager->prepare($statementName, $sql); $res = $this->dbManager->execute($statementName, $params); $this->dbManager->freeResult($res); }
/** * @param ItemTreeBounds $itemTreeBounds * @param int $groupId * @param boolean $orderAscending * @return array */ protected function getCurrentSelectedLicensesTableData(ItemTreeBounds $itemTreeBounds, $groupId, $orderAscending) { $uploadTreeId = $itemTreeBounds->getItemId(); $uploadId = $itemTreeBounds->getUploadId(); $uberUri = Traceback_uri() . "?mod=view-license" . Traceback_parm_keep(array('upload', 'folder')); list($addedClearingResults, $removedLicenses) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION); $licenseEventTypes = new ClearingEventTypes(); $mainLicIds = $this->clearingDao->getMainLicenseIds($uploadId, $groupId); $table = array(); /* @var $clearingResult ClearingResult */ foreach ($addedClearingResults as $licenseShortName => $clearingResult) { $licenseId = $clearingResult->getLicenseId(); $types = $this->getAgentInfo($clearingResult, $uberUri, $uploadTreeId); $reportInfo = ""; $comment = ""; if ($clearingResult->hasClearingEvent()) { $licenseDecisionEvent = $clearingResult->getClearingEvent(); $types[] = $this->getEventInfo($licenseDecisionEvent, $uberUri, $uploadTreeId, $licenseEventTypes); $reportInfo = $licenseDecisionEvent->getReportinfo(); $comment = $licenseDecisionEvent->getComment(); } $licenseShortNameWithLink = $this->urlBuilder->getLicenseTextUrl($clearingResult->getLicenseRef()); $actionLink = "<a href=\"javascript:;\" onclick=\"removeLicense({$uploadId}, {$uploadTreeId}, {$licenseId});\"><img class=\"delete\" src=\"images/space_16.png\" alt=\"\"/></a>"; if (in_array($clearingResult->getLicenseId(), $mainLicIds)) { $tooltip = _('This is a main license for the upload. Click to discard selection.'); $actionLink .= " <a href=\"javascript:;\" onclick=\"removeMainLicense({$uploadId}, {$licenseId});\"><img src=\"images/icons/star_filled_16.png\" alt=\"mainLicense\" title=\"{$tooltip}\" border=\"0\"/></a>"; } else { $tooltip = _('Click to select this as a main license for the upload.'); $actionLink .= " <a href=\"javascript:;\" onclick=\"makeMainLicense({$uploadId}, {$licenseId});\"><img src=\"images/icons/star_16.png\" alt=\"noMainLicense\" title=\"{$tooltip}\" border=\"0\"/></a>"; } $reportInfoField = nl2br(htmlspecialchars($reportInfo)); $commentField = nl2br(htmlspecialchars($comment)); $id = "{$uploadTreeId},{$licenseId}"; $table[$licenseShortName] = array('DT_RowId' => $id, '0' => $licenseShortNameWithLink, '1' => implode("<br/>", $types), '2' => $reportInfoField, '3' => $commentField, '4' => $actionLink); } foreach ($removedLicenses as $licenseShortName => $clearingResult) { if ($clearingResult->getAgentDecisionEvents()) { $agents = $this->getAgentInfo($clearingResult, $uberUri, $uploadTreeId); $licenseShortNameWithLink = $this->urlBuilder->getLicenseTextUrl($clearingResult->getLicenseRef()); $licenseId = $clearingResult->getLicenseId(); $actionLink = "<a href=\"javascript:;\" onclick=\"addLicense({$uploadId}, {$uploadTreeId}, {$licenseId});\"><img class=\"add\" src=\"images/space_16.png\" alt=\"\"/></a>"; $filled = in_array($clearingResult->getLicenseId(), $mainLicIds) ? 'filled_' : ''; $actionLink .= ' <img src="images/icons/star_' . $filled . '16.png" alt="mainLicense"/>'; $idArray = array($uploadTreeId, $licenseId); $id = implode(',', $idArray); $table[$licenseShortName] = array('DT_RowId' => $id, 'DT_RowClass' => 'removed', '0' => $licenseShortNameWithLink, '1' => implode("<br/>", $agents), '2' => "-", '3' => "-", '4' => $actionLink); } } $valueTable = array_values($this->sortByKeys($table, $orderAscending)); return $valueTable; }