diff --git a/src/www/ui/ui-license-list-files.php b/src/www/ui/ui-license-list-files.php
index e87e0798..45a1de85 100644
--- a/src/www/ui/ui-license-list-files.php
+++ b/src/www/ui/ui-license-list-files.php
@@ -1,311 +1,332 @@
'N', 'monk' => 'M', 'ninka' => 'Nk');
+
+ function __construct()
+ {
+ $this->Name = "license_list_files";
+ $this->Title = TITLE_license_list_files;
+ $this->Dependency = array("browse", "view");
+ $this->DBaccess = PLUGIN_DB_READ;
+ $this->LoginFlag = 0;
+ parent::__construct();
+ $this->dbManager = $GLOBALS['container']->get('db.manager');
+ $this->uploadDao = $GLOBALS['container']->get('dao.upload');
+ $this->licenseDao = $GLOBALS['container']->get('dao.license');
+ $this->agentDao = $GLOBALS['container']->get('dao.agent');
+ }
/**
* \brief Customize submenus.
*/
function RegisterMenus()
{
if ($this->State != PLUGIN_STATE_READY)
{
return (0);
}
// micro-menu
$uploadtree_pk = GetParm("item", PARM_INTEGER);
- $rf_shortname = GetParm("lic", PARM_STRING);
+ $rf_shortname = GetParm("lic", PARM_RAW);
$Excl = GetParm("excl", PARM_RAW);
- $URL = $this->Name . "&item=$uploadtree_pk&lic=$rf_shortname&page=-1";
+ $URL = $this->Name . "&item=$uploadtree_pk&lic=".urlencode($rf_shortname)."&page=-1";
if (!empty($Excl)) $URL .= "&excl=$Excl";
$text = _("Show All Files");
menu_insert($this->Name . "::Show All", 0, $URL, $text);
} // RegisterMenus()
-
/**
* \brief Display the loaded menu and plugins.
*/
function Output()
{
$uploadtree_pk = GetParm("item", PARM_INTEGER);
$rf_shortname = GetParm("lic", PARM_RAW);
$tag_pk = GetParm("tag", PARM_INTEGER);
$Excl = GetParm("excl", PARM_RAW);
$Exclic = GetParm("exclic", PARM_RAW);
if (empty($uploadtree_pk) || empty($rf_shortname))
{
$text = _("is missing required parameters.");
return $this->Name . " $text";
}
$Max = 50;
$Page = GetParm("page", PARM_INTEGER);
if (empty($Page))
{
$Page = 0;
}
// Get upload_pk and $uploadtree_tablename
$UploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk=$uploadtree_pk");
-
- global $container;
- /** @var UploadDao */
- $uploadDao = $container->get('dao.upload');
- $uploadtree_tablename = $uploadDao->getUploadtreeTableName($UploadtreeRec['upload_fk']);
+ $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($UploadtreeRec['upload_fk']);
// micro menus
$V = menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
/* Load licenses */
$Offset = ($Page < 0) ? 0 : $Page * $Max;
$order = "";
$PkgsOnly = false;
// Count is uploadtree recs, not pfiles
$agentId = GetParm('agentId', PARM_INTEGER);
if (empty($agentId))
{
- $agentId = "any";
+ $scannerAgents = array_keys($this->agentNames);
+ $scanJobProxy = new ScanJobProxy($this->agentDao, $UploadtreeRec['upload_fk']);
+ $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
+ $agentId = $scanJobProxy->getLatestSuccessfulAgentIds();
}
$CountArray = $this->countFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk, $tag_pk, $uploadtree_tablename);
if (empty($CountArray))
{
$V .= _(" No files found for license $rf_shortname !\n");
}
else
{
$Count = $CountArray['count'];
$Unique = $CountArray['unique'];
$text = _("files found");
$text2 = _("with license");
- $V .= "$Unique $text $text2 $rf_shortname";
+ $text3 = _("files are unique with same file hash.");
+ $V .= "Total $Count $text $text2 $rf_shortname, $Unique $text3";
if ($Count < $Max) $Max = $Count;
$limit = ($Page < 0) ? "ALL" : $Max;
$order = " order by ufile_name asc";
/** should delete $filesresult yourself */
$filesresult = GetFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk,
$PkgsOnly, $Offset, $limit, $order, $tag_pk, $uploadtree_tablename);
$NumFiles = pg_num_rows($filesresult);
$file_result_temp = pg_fetch_all($filesresult);
$sorted_file_result = array(); // the final file list will display
$max_num = $NumFiles;
/** sorting by ufile_name from DB, then reorder the duplicates indented */
for ($i = 0; $i < $max_num; $i++)
{
$row = $file_result_temp[$i];
if (empty($row)) continue;
array_push($sorted_file_result, $row);
for ($j = $i + 1; $j < $max_num; $j++)
{
$row_next = $file_result_temp[$j];
if (!empty($row_next) && ($row['pfile_fk'] == $row_next['pfile_fk']))
{
array_push($sorted_file_result, $row_next);
$file_result_temp[$j] = null;
}
}
}
$text = _("Display");
$text1 = _("excludes");
$text2 = _("files with these extensions");
if (!empty($Excl)) $V .= "
$text $text1 $text2: $Excl";
$text2 = _("files with these licenses");
if (!empty($Exclic)) $V .= "
$text $text1 $text2: $Exclic";
/* Get the page menu */
if (($Max > 0) && ($Count >= $Max) && ($Page >= 0))
{
$VM = "
$text |  ";
$LastPfilePk = -1;
$ExclArray = explode(":", $Excl);
$ExclicArray = explode(":", $Exclic);
foreach ($sorted_file_result as $row)
{
$pfile_pk = $row['pfile_fk'];
$licstring = GetFileLicenses_string($row['agent_pk'], $pfile_pk, $row['uploadtree_pk'], $uploadtree_tablename);
$URLlicstring = urlencode($licstring);
// Allow user to exclude files with this extension
$FileExt = GetFileExt($row['ufile_name']);
$URL = $baseURL;
if (!empty($Excl))
$URL .= "&excl=$Excl:$FileExt";
else
$URL .= "&excl=$FileExt";
if (!empty($Exclic)) $URL .= "&exclic=" . urlencode($Exclic);
$text = _("Exclude this file type.");
$Header = "$text";
/* Allow user to exclude files with this exact license list */
$URL = $baseURL;
if (!empty($Exclic))
$URL .= "&exclic=" . urlencode($Exclic) . ":" . $URLlicstring;
else
$URL .= "&exclic=$URLlicstring";
if (!empty($Excl)) $URL .= "&excl=$Excl";
$text = _("Exclude files with license");
$Header .= " $text: $licstring."; $excludeByType = $Excl && in_array($FileExt, $ExclArray); $excludeByLicense = $Exclic && in_array($licstring, $ExclicArray); if (!empty($licstring) && !$excludeByType && !$excludeByLicense) { $V .= " | |
---|---|---|
";
/* Tack on pfile to url - information only */
$LinkLastpfile = $LinkLast . "&pfile=$pfile_pk";
if ($LastPfilePk == $pfile_pk)
{
$indent = " ";
$outdent = " ";
} else
{
$indent = "";
$outdent = "";
}
$V .= $indent;
$V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLastpfile, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename);
$V .= $outdent;
$V .= " | ";
$V .= ""; $V .= " | $row[agent_name]: $licstring |