31 define(
"TITLE_COPYRIGHT_LIST", _(
"List Files for Copyright/Email/URL"));
45 function __construct()
47 $this->Name =
"copyright-list";
48 $this->Title = TITLE_COPYRIGHT_LIST;
49 $this->Version =
"1.0";
50 $this->Dependency = array(
"copyright-hist",
"ecc-hist");
55 parent::__construct();
57 $this->
dbManager = $container->get(
'db.manager');
58 $this->uploadDao = $container->get(
'dao.upload');
67 if ($this->
State != PLUGIN_STATE_READY) {
78 $URL = $this->Name .
"&agent=$agent_pk&item=$uploadtree_pk&hash=$hash&type=$type&page=-1";
80 $URL .=
"&excl=$Excl";
82 $text = _(
"Show All Files");
83 menu_insert($this->Name.
"::Show All",0, $URL, $text);
97 function GetRows($Uploadtree_pk, $Agent_pk, &$upload_pk, $hash, $type, $tableName)
100 $row = $this->uploadDao->getUploadEntry($Uploadtree_pk);
103 $upload_pk = $row[
"upload_fk"];
106 if ($type ==
"copyFindings") {
107 $sql =
"SELECT textfinding AS content, '$type' AS type, uploadtree_pk, ufile_name, PF 109 (SELECT uploadtree_pk, pfile_fk AS PF, ufile_name FROM uploadtree 111 AND uploadtree.lft BETWEEN $2 AND $3) AS SS 112 WHERE PF=pfile_fk AND hash=$4 ORDER BY uploadtree_pk";
114 $upload_pk, $lft, $rgt, $hash
118 $sql =
"SELECT content, type, uploadtree_pk, ufile_name, PF 120 (SELECT uploadtree_pk, pfile_fk AS PF, ufile_name FROM uploadtree 122 AND uploadtree.lft BETWEEN $2 AND $3) AS SS 123 WHERE PF=pfile_fk AND agent_fk=$4 AND hash=$5 AND type=$6 ORDER BY uploadtree_pk";
125 $upload_pk, $lft, $rgt, $Agent_pk, $hash, $type
128 $statement = __METHOD__.$tableName;
129 $this->
dbManager->prepare($statement, $sql);
130 $result = $this->
dbManager->execute($statement,$params);
132 $rows = $this->
dbManager->fetchAll($result);
149 $NumRows = count($rows);
151 $ExclArray = explode(
":", $excl);
156 $NoLicStr =
"No_license_found";
157 $VoidLicStr =
"Void";
160 $sql =
"select rf_pk from license_ref where rf_shortname IN ($1, $2)";
161 $statement = __METHOD__.
"NoLicenseFoundORVoid";
162 $this->
dbManager->prepare($statement, $sql);
163 $result = $this->
dbManager->execute($statement,array(
"$NoLicStr",
"$VoidLicStr"));
164 $rf_rows = $this->
dbManager->fetchAll($result);
165 if(!empty($rf_rows)){
166 foreach($rf_rows as $row)
168 if (!empty($rf_clause)) { $rf_clause .=
" or ";
170 $rf_clause .=
" rf_fk=$row[rf_pk]";
176 for($RowIdx = 0; $RowIdx < $NumRows; $RowIdx++)
178 $row = $rows[$RowIdx];
182 $FileExt =
GetFileExt($rows[$RowIdx][
'ufile_name']);
183 if (in_array($FileExt, $ExclArray))
185 unset($rows[$RowIdx]);
191 if (($filter ==
"nolic") and ($rf_clause))
194 $sql =
"select rf_fk from license_file where ($rf_clause) and pfile_fk=$1";
195 $statement = __METHOD__.
"CheckForNoLicenseFound";
196 $this->
dbManager->prepare($statement, $sql);
197 $result = $this->
dbManager->execute($statement,array(
"{$row['pf']}"));
198 $FoundRows = $this->
dbManager->fetchAll($result);
199 if (empty($FoundRows))
201 unset($rows[$RowIdx]);
209 foreach ($rows as $row) {
215 $NumRows = count($rows2);
217 for($RowIdx = 0; $RowIdx < $NumRows; $RowIdx++)
225 if ($rows2[$RowIdx-1][
'uploadtree_pk'] == $rows2[$RowIdx][
'uploadtree_pk']) {
226 unset($rows2[$RowIdx-1]);
232 usort($rows2,
'copyright_namecmp');
244 if ($this->
State != PLUGIN_STATE_READY) {
248 return parent::OutputOpen();
257 if ($this->
State != PLUGIN_STATE_READY) {
262 $Time = microtime(
true);
272 if (empty($uploadtree_pk) || empty($hash) || empty($type) || empty($agent_pk))
274 $this->vars[
'pageContent'] = $this->Name . _(
" is missing required parameters");
279 $Row = $this->uploadDao->getUploadEntry($uploadtree_pk);
280 if (!$this->uploadDao->isAccessible($Row[
'upload_fk'], Auth::getGroupId()))
282 $this->vars[
'pageContent'] =
"<h2>" . _(
"Permission Denied") .
"</h2>";
287 if (empty($Page) || $Page == -1) {
291 list($tableName,$modBack,$viewName) = $this->
getTableName($type);
295 $allRows = $this->
GetRows($uploadtree_pk, $agent_pk, $upload_pk, $hash, $type, $tableName);
296 $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($upload_pk);
305 $RowCount = count($rows);
309 $Content = htmlentities($rows[0][
'content']);
310 $Offset = ($Page < 0) ? 0 : $Page*$Max;
313 $text1 = _(
"unique");
314 $text3 = _(
"copyright");
329 $TypeStr = _(
"export restriction");
332 $TypeStr = _(
"Keyword Analysis");
335 $TypeStr = _(
"User Findings");
337 $OutBuf .=
"$NumInstances $TypeStr instances found in $RowCount $text";
339 $OutBuf .=
": <b>$Content</b>";
341 $text = _(
"Display excludes files with these extensions");
342 if (!empty($excl)) { $OutBuf .=
"<br>$text: $excl";
346 if (($RowCount >= $Max) && ($Page >= 0))
348 $PagingMenu =
"<P />\n" .
MenuPage($Page, intval($RowCount / $Max)) .
"<P />\n";
349 $OutBuf .= $PagingMenu;
357 $LinkLast =
"$viewName&agent=$agent_pk";
361 $baseURL =
"?mod=" . $this->Name .
"&agent=$agent_pk&item=$uploadtree_pk&hash=$hash&type=$type&page=-1";
365 foreach($rows as $row)
368 if ($RowNum < $Offset) {
371 if ($RowNum > $Offset + $Max) {
378 $URL = $baseURL .
"&excl=$FileExt";
380 $URL = $baseURL .
"&excl=$excl:$FileExt";
383 $text = _(
"Exclude this file type");
384 $Header =
"<a href=$URL>$text.</a>";
389 $ExclArray = explode(
":", $excl);
390 if (in_array($FileExt, $ExclArray)) {
397 $OutBuf .=
Dir2Browse($modBack, $row[
'uploadtree_pk'], $LinkLast,
398 $ShowBox, $ShowMicro, $RowNum, $Header,
'', $uploadtree_tablename);
404 $OutBuf .= _(
"No files found");
407 if (!empty($PagingMenu)) {
408 $OutBuf .= $PagingMenu .
"\n";
411 $Time = microtime(
true) - $Time;
412 $text = _(
"Elapsed time");
413 $text1 = _(
"seconds");
414 $OutBuf .= sprintf(
"<small>$text: %.2f $text1</small>\n", $Time);
416 $this->vars[
'pageContent'] = $OutBuf;
426 return 'copyrightlist.html.twig';
440 $modBack =
"ecc-hist";
441 $viewName =
"ecc-view";
444 $tableName =
"keyword";
445 $modBack =
"keyword-hist";
446 $viewName =
"keyword-view";
449 $tableName =
"copyright";
450 $modBack =
"copyright-hist";
451 $viewName =
"copyright-view";
453 case "copyFindings" :
454 $tableName =
"copyright_decision";
455 $modBack =
"copyright-hist";
456 $viewName =
"copyright-view";
459 $tableName =
"author";
460 $modBack =
"email-hist";
461 $viewName =
"copyright-view";
463 return array($tableName, $modBack,$viewName);
468 $NewPlugin->Initialize();
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
GetRows($Uploadtree_pk, $Agent_pk, &$upload_pk, $hash, $type, $tableName)
Get statement rows for a specified set.
GetFileExt($fname)
Get File Extension (text after last period)
GetRequestedRows($rows, $excl, &$NumRows, $filter)
Remove unwanted rows by hash and type and exclusions and filter.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
getTableName($type)
Get the table name, mod, and view based on type.
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
Output()
This function is called when user output is requested. This function is responsible for content...