/** * @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 $uploadId * @param $itemId * @param $direction * @return Item|null */ public function getItemByDirection($uploadId, $itemId, $direction, $options) { $uploadTreeTableName = $this->getUploadtreeTableName($uploadId); $originItem = $this->getUploadEntry($itemId, $uploadTreeTableName); $originLft = $originItem['lft']; $options[UploadTreeProxy::OPT_ITEM_FILTER] = " AND ut.ufile_mode & (3<<28) = 0"; $uploadTreeViewName = 'items2care'; if ($direction == self::DIR_FWD) { $uploadTreeViewName .= 'fwd'; $options[UploadTreeProxy::OPT_ITEM_FILTER] .= " AND lft>\$1"; $order = 'ASC'; } else { $uploadTreeViewName .= 'bwd'; $options[UploadTreeProxy::OPT_ITEM_FILTER] .= " AND lft<\$1"; $order = 'DESC'; } $uploadTreeView = new UploadTreeProxy($uploadId, $options, $uploadTreeTableName, $uploadTreeViewName); $statementName = __METHOD__ . ".{$uploadTreeViewName}."; $query = $uploadTreeView->getDbViewQuery() . " ORDER BY lft {$order}"; $newItemRow = $this->dbManager->getSingleRow("{$query} LIMIT 1", array($originLft), $statementName); if ($newItemRow) { return $this->createItem($newItemRow, $uploadTreeTableName); } else { return self::NOT_FOUND; } }
/** * @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; }