예제 #1
0
 /**
  * @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;
 }
 /**
  * \brief Given an $Uploadtree_pk, display: 
  *   - The histogram for the directory BY LICENSE.
  *   - The file listing for the directory.
  */
 function ShowUploadHist($Uploadtree_pk, $Uri, $tag_pk)
 {
     global $PG_CONN;
     $VF = "";
     // return values for file listing
     $VLic = "";
     // return values for license histogram
     $V = "";
     // total return value
     $UniqueTagArray = array();
     global $Plugins;
     $ModLicView =& $Plugins[plugin_find_id("view-license")];
     /*******  Get license names and counts  ******/
     /* Find lft and rgt bounds for this $Uploadtree_pk  */
     $sql = "SELECT lft,rgt,upload_fk FROM {$this->uploadtree_tablename}\n              WHERE uploadtree_pk = {$Uploadtree_pk}";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $lft = $row["lft"];
     $rgt = $row["rgt"];
     $upload_pk = $row["upload_fk"];
     pg_free_result($result);
     if (empty($lft)) {
         $text = _("Job unpack/adj2nest hasn't completed.");
         $VLic = "<b>{$text}</b><p>";
         return $VLic;
     }
     /* Find total number of files for this $Uploadtree_pk
      * Exclude artifacts and directories.
      */
     $sql = "SELECT count(*) as count FROM {$this->uploadtree_tablename}\n              WHERE upload_fk = {$upload_pk} \n                    and {$this->uploadtree_tablename}.lft BETWEEN {$lft} and {$rgt}\n                    and ((ufile_mode & (1<<28))=0) \n                    and ((ufile_mode & (1<<29))=0) and pfile_fk!=0";
     //$uTime = microtime(true);
     $result = pg_query($PG_CONN, $sql);
     //printf( "<small>count files Elapsed time: %.2f seconds</small>", microtime(true) - $uTime);  // convert usecs to secs
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $FileCount = $row["count"];
     pg_free_result($result);
     /*  Get the counts for each license under this UploadtreePk*/
     if (empty($tag_pk)) {
         $TagTable = "";
         $TagClause = "";
     } else {
         $TagTable = " right join tag_file on tag_file.pfile_fk=license_file_ref.pfile_fk ";
         $TagClause = " and tag_fk={$tag_pk}";
     }
     /** advanced interface allowing user to select dataset (agent version) */
     $Agent_name = 'nomos';
     $dataset = "nomos_dataset";
     $Agent_pk = GetParm("agent", PARM_STRING);
     /** if do not specify agent, get the latest agent result for this upload */
     if (empty($Agent_pk)) {
         $Agent_pk = LatestAgentpk($upload_pk, "nomos_ars");
     }
     if ($Agent_pk == 0) {
         $text = _("No data available.  Use Jobs > Agents to schedule a license scan.");
         $VLic = "<b>{$text}</b><p>";
         return $VLic;
     }
     /** get nomos select dataset */
     $AgentSelect = AgentSelect($Agent_name, $upload_pk, true, $dataset, $dataset, $Agent_pk, "onchange=\"addArsGo('newds', 'nomos_dataset');\"");
     /** change the nomos license result when selecting one version of nomos */
     if (!empty($AgentSelect)) {
         $action = Traceback_uri() . "?mod=nomoslicense&upload={$upload_pk}&item={$Uploadtree_pk}";
         $VLic .= "<script type='text/javascript'>\n        function addArsGo(formid, selectid)\n        {\n          var selectobj = document.getElementById(selectid);\n          var Agent_pk = selectobj.options[selectobj.selectedIndex].value;\n          document.getElementById(formid).action='{$action}'+'&agent='+Agent_pk;\n          document.getElementById(formid).submit();\n          return;\n        }\n      </script>";
         /* form to select new dataset, show dataset */
         $VLic .= "<form action='{$action}' id='newds' method='POST'>\n";
         $VLic .= $AgentSelect;
         $VLic .= "</form>";
     }
     $orderBy = array('count', 'license_name');
     $ordersql = "liccount desc";
     static $ordercount = 1;
     static $orderlic = 1;
     /** sorting by count/licnese name */
     if (isset($_GET['orderBy']) && in_array($_GET['orderBy'], $orderBy)) {
         $order = $_GET['orderBy'];
         if (isset($_GET['orderc'])) {
             $ordercount = $_GET['orderc'];
         }
         if (isset($_GET['orderl'])) {
             $orderlic = $_GET['orderl'];
         }
         if ('count' == $order && 1 == $ordercount) {
             $ordersql = "liccount desc";
             $ordercount = 0;
         } else {
             if ('count' == $order && 0 == $ordercount) {
                 $ordersql = "liccount ";
                 $ordercount = 1;
             } else {
                 if ('license_name' == $order && 1 == $orderlic) {
                     $ordersql = "rf_shortname ";
                     $orderlic = 0;
                 } else {
                     if ('license_name' == $order && 0 == $orderlic) {
                         $ordersql = "rf_shortname desc";
                         $orderlic = 1;
                     }
                 }
             }
         }
     }
     // Void ARE EXCLUDED FROM LICENSE COUNT
     $sql = "SELECT distinct(SS.rf_shortname) as licname, count(SS.rf_shortname) as liccount, SS.rf_shortname from \n            (SELECT distinct(license_file_ref.pfile_fk), rf_shortname\n            from license_file_ref {$TagTable}\n            right join {$this->uploadtree_tablename} on license_file_ref.pfile_fk={$this->uploadtree_tablename}.pfile_fk \n            where rf_shortname <> 'Void' and upload_fk='{$upload_pk}' and {$this->uploadtree_tablename}.lft BETWEEN {$lft} and {$rgt} \n              and agent_fk={$Agent_pk} {$TagClause} group by license_file_ref.pfile_fk, rf_shortname\n            ) as SS\n            group by rf_shortname order by {$ordersql}";
     //$uTime = microtime(true);
     $result = pg_query($PG_CONN, $sql);
     //$Time = microtime(true) - $uTime;  // convert usecs to secs
     //$text = _("histogram Elapsed time: %.2f seconds");
     //printf( "<small>$text</small>", $Time);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     /* Write license histogram to $VLic  */
     $LicCount = 0;
     $UniqueLicCount = 0;
     $NoLicFound = 0;
     $VLic .= "<table border=1 width='100%' id='lichistogram'>\n";
     $text = _("Count");
     $VLic .= "<tr><th>";
     $VLic .= "<a href=?mod=" . "{$this->Name}" . Traceback_parm_keep(array("upload", "item", "tag", "agent")) . "&orderBy=count&orderc={$ordercount}>{$text}</a>";
     $VLic .= "</th>";
     $text = _("Files");
     $VLic .= "<th width='10%'>{$text}</th>";
     $text = _("License Name");
     $VLic .= "<th>";
     $VLic .= "<a href=?mod=" . "{$this->Name}" . Traceback_parm_keep(array("upload", "item", "tag", "agent")) . "&orderBy=license_name&orderl={$orderlic}>{$text}</a>";
     $VLic .= "</th></tr>\n";
     while ($row = pg_fetch_assoc($result)) {
         $UniqueLicCount++;
         $LicCount += $row['liccount'];
         /*  Count  */
         $VLic .= "<tr><td align='right'>{$row['liccount']}</td>";
         /*  Show  */
         $VLic .= "<td align='center'><a href='";
         $VLic .= Traceback_uri();
         $text = _("Show");
         $tagClause = $tag_pk ? "&tag={$tag_pk}" : "";
         $VLic .= "?mod=list_lic_files&napk={$Agent_pk}&item={$Uploadtree_pk}&lic=" . urlencode($row['rf_shortname']) . $tagClause . "'>{$text}</a></td>";
         /*  License name  */
         $VLic .= "<td align='left'>";
         $rf_shortname = rawurlencode($row['rf_shortname']);
         $VLic .= "<a id='{$rf_shortname}' onclick='FileColor_Get(\"" . Traceback_uri() . "?mod=ajax_filelic&napk={$Agent_pk}&item={$Uploadtree_pk}&lic={$rf_shortname}&ut={$this->uploadtree_tablename}\")'";
         $VLic .= ">{$row['licname']} </a>";
         $VLic .= "</td>";
         $VLic .= "</tr>\n";
         if ($row['licname'] == "No_license_found") {
             $NoLicFound = $row['liccount'];
         }
     }
     $VLic .= "</table>\n";
     $VLic .= "<p>\n";
     $VLic .= _("Hint: Click on the license name to ");
     $text = _("highlight");
     $VLic .= "<span style='background-color:{$this->HighlightColor}'>{$text} </span>";
     $VLic .= _("where the license is found in the file listing.<br>\n");
     $VLic .= "<table border=0 id='licsummary'>";
     $text = _("Unique licenses");
     $VLic .= "<tr><td align=right>{$UniqueLicCount}</td><td>{$text}</td></tr>";
     $NetLic = $LicCount - $NoLicFound;
     $text = _("Licenses found");
     $VLic .= "<tr><td align=right>{$NetLic}</td><td>{$text}</td></tr>";
     $text = _("Files with no licenses");
     $VLic .= "<tr><td align=right>{$NoLicFound}</td><td>{$text}</td></tr>";
     $text = _("Files");
     $VLic .= "<tr><td align=right>{$FileCount}</td><td>{$text}</td></tr>";
     $VLic .= "</table>";
     pg_free_result($result);
     /*******    File Listing     ************/
     /* Get ALL the items under this Uploadtree_pk */
     $Children = GetNonArtifactChildren($Uploadtree_pk, $this->uploadtree_tablename);
     /* Filter out Children that don't have tag */
     if (!empty($tag_pk)) {
         TagFilter($Children, $tag_pk, $this->uploadtree_tablename);
     }
     $ChildCount = 0;
     $ChildLicCount = 0;
     //$uTime = microtime(true);
     if (!empty($Children)) {
         /* For alternating row background colors */
         $RowStyle1 = "style='background-color:#ecfaff'";
         // pale blue
         $RowStyle2 = "style='background-color:#ffffe3'";
         // pale yellow
         $ColorSpanRows = 1;
         // Alternate background color every $ColorSpanRows
         $RowNum = 0;
         $VF .= "<table border=0 id='dirlist'>";
         foreach ($Children as $C) {
             if (empty($C)) {
                 continue;
             }
             $IsDir = Isdir($C['ufile_mode']);
             $IsContainer = Iscontainer($C['ufile_mode']);
             /* Determine the hyperlink for non-containers to view-license  */
             if (!empty($C['pfile_fk']) && !empty($ModLicView)) {
                 $LinkUri = Traceback_uri();
                 $LinkUri .= "?mod=view-license&napk={$Agent_pk}&upload={$upload_pk}&item={$C['uploadtree_pk']}";
             } else {
                 $LinkUri = NULL;
             }
             /* Determine link for containers */
             if (Iscontainer($C['ufile_mode'])) {
                 $uploadtree_pk = DirGetNonArtifact($C['uploadtree_pk'], $this->uploadtree_tablename);
                 $LicUri = "{$Uri}&item=" . $uploadtree_pk;
             } else {
                 $LicUri = NULL;
             }
             /* Populate the output ($VF) - file list */
             /* id of each element is its uploadtree_pk */
             /* Set alternating row background color - repeats every $ColorSpanRows rows */
             $RowStyle = $RowNum++ % (2 * $ColorSpanRows) < $ColorSpanRows ? $RowStyle1 : $RowStyle2;
             $VF .= "<tr {$RowStyle}>";
             $VF .= "<td id='{$C['uploadtree_pk']}' align='left'>";
             $HasHref = 0;
             $HasBold = 0;
             if ($IsContainer) {
                 $VF .= "<a href='{$LicUri}'>";
                 $HasHref = 1;
                 $VF .= "<b>";
                 $HasBold = 1;
             } else {
                 if (!empty($LinkUri)) {
                     $VF .= "<a href='{$LinkUri}'>";
                     $HasHref = 1;
                 }
             }
             $VF .= $C['ufile_name'];
             if ($IsDir) {
                 $VF .= "/";
             }
             if ($HasBold) {
                 $VF .= "</b>";
             }
             if ($HasHref) {
                 $VF .= "</a>";
             }
             /* show licenses under file name */
             $VF .= "<br>";
             $VF .= GetFileLicenses_string($Agent_pk, $C['pfile_fk'], $C['uploadtree_pk'], $this->uploadtree_tablename);
             $VF .= "</td><td valign='top'>";
             /* display file links */
             $VF .= FileListLinks($C['upload_fk'], $C['uploadtree_pk'], $Agent_pk, $C['pfile_fk'], true, $UniqueTagArray, $this->uploadtree_tablename);
             $VF .= "</td>";
             $VF .= "</tr>\n";
             $ChildCount++;
         }
         $VF .= "</table>\n";
     }
     //$Time = microtime(true) - $uTime;  // convert usecs to secs
     //$text = _("Sum of children Elapsed time: %.2f seconds");
     //printf( "<small>$text</small>", $Time);
     /***************************************
          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) {
         $sql = "SELECT * FROM {$this->uploadtree_tablename} WHERE uploadtree_pk = '{$Uploadtree_pk}';";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $row = pg_fetch_assoc($result);
         pg_free_result($result);
         if (IsDir($row['ufile_mode'])) {
             return;
         }
         $ModLicView =& $Plugins[plugin_find_id("view-license")];
         return $ModLicView->Output();
     }
     $V .= ActiveHTTPscript("FileColor");
     /* Add javascript for color highlighting
         This is the response script needed by ActiveHTTPscript
        responseText is license name',' followed by a comma seperated list of uploadtree_pk's */
     $script = "\n      <script type=\"text/javascript\" charset=\"utf-8\">\n        var Lastutpks='';   /* save last list of uploadtree_pk's */\n        var LastLic='';   /* save last License (short) name */\n        var color = '{$this->HighlightColor}';\n        function FileColor_Reply()\n        {\n          if ((FileColor.readyState==4) && (FileColor.status==200))\n          {\n            /* remove previous highlighting */\n            var numpks = Lastutpks.length;\n            if (numpks > 0) document.getElementById(LastLic).style.backgroundColor='white';\n            while (numpks)\n            {\n              document.getElementById(Lastutpks[--numpks]).style.backgroundColor='white';\n            }\n\n            utpklist = FileColor.responseText.split(',');\n            LastLic = utpklist.shift();\n            numpks = utpklist.length;\n            Lastutpks = utpklist;\n\n            /* apply new highlighting */\n            elt = document.getElementById(LastLic);\n            if (elt != null) elt.style.backgroundColor=color;\n            while (numpks)\n            {\n              document.getElementById(utpklist[--numpks]).style.backgroundColor=color;\n            }\n          }\n          return;\n        }\n      </script>\n    ";
     $V .= $script;
     /******  Filters  *******/
     /* Only display the filter pulldown if there are filters available 
      * Currently, this is only tags.
      */
     /** @todo qualify with tag namespace to avoid tag name collisions.  **/
     /* turn $UniqueTagArray into key value pairs ($SelectData) for select list */
     $SelectData = array();
     if (count($UniqueTagArray)) {
         foreach ($UniqueTagArray as $UTA_row) {
             $SelectData[$UTA_row['tag_pk']] = $UTA_row['tag_name'];
         }
         $V .= "Tag filter";
         $myurl = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item"));
         $Options = " id='filterselect' onchange=\"js_url(this.value, '{$myurl}&tag=')\"";
         $V .= Array2SingleSelectTag($SelectData, "tag_ns_pk", $tag_pk, true, false, $Options);
     }
     /****** Combine VF and VLic ********/
     $V .= "<table border=0 width='100%'>\n";
     $V .= "<tr><td valign='top' >{$VLic}</td><td valign='top'>{$VF}</td></tr>\n";
     $V .= "</table>\n";
     $V .= "<hr />\n";
     return $V;
 }
예제 #3
0
 /**
  * @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;
 }