23 $this->Name =
"bucketbrowser";
24 $this->Title = _(
"Bucket Browser");
25 $this->Dependency = array(
"browse",
"view");
28 parent::__construct();
57 $sql =
"SELECT bucketpool_pk FROM bucketpool limit 1";
60 if (pg_num_rows($result) > 0)
62 pg_free_result($result);
67 $DemoPoolName =
"GPL Demo bucket pool";
68 $sql =
"INSERT INTO bucketpool (bucketpool_name, version, active, description) VALUES ('$DemoPoolName', 1, 'Y', 'Demonstration of a very simple GPL/non-gpl bucket pool')";
71 pg_free_result($result);
74 $sql =
"select bucketpool_pk from bucketpool
75 where bucketpool_name='$DemoPoolName' limit 1";
78 $row = pg_fetch_assoc($result);
79 $bucketpool_pk = $row[
'bucketpool_pk'];
80 pg_free_result($result);
83 $sql =
"INSERT INTO bucketpool (bucketpool_name, version, active, description) VALUES ('$DemoPoolName', 1, 'Y', 'Demonstration of a very simple GPL/non-gpl bucket pool')";
84 $Columns =
"bucket_name, bucket_color, bucket_reportorder, bucket_evalorder, bucketpool_fk, bucket_type, bucket_regex, stopon, applies_to";
85 $sql =
"INSERT INTO bucket_def ($Columns) VALUES ('GPL Licenses (Demo)', 'orange', 50, 50, $bucketpool_pk, 3, '(affero|gpl)', 'N', 'f');
86 INSERT INTO bucket_def ($Columns) VALUES ('non-gpl (Demo)', 'yellow', 50, 1000, $bucketpool_pk, 99, NULL, 'N', 'f')";
89 pg_free_result($result);
103 if (!empty($Item) && !empty($Upload))
105 $menuText =
"Bucket";
108 $tooltipText = _(
"Browse by buckets");
109 $this->microMenu->insert(array(MicroMenu::VIEW_META, MicroMenu::VIEW), $menuText, $menuPosition, $this->
getName(), $URI, $tooltipText);
137 if ($this->
State != PLUGIN_STATE_INVALID) {
140 if ($this->Name !==
"")
143 $this->
State=PLUGIN_STATE_VALID;
147 return($this->
State == PLUGIN_STATE_VALID);
166 $UniqueTagArray = array();
169 $ModLicView = &$Plugins[plugin_find_id(
"view-license")];
173 $sql =
"SELECT lft,rgt,upload_fk FROM $this->uploadtree_tablename
174 WHERE uploadtree_pk = $Uploadtree_pk";
177 if (pg_num_rows($result) < 1)
179 pg_free_result($result);
180 $text = _(
"Invalid URL, nonexistant item");
181 return "<h2>$text $Uploadtree_pk</h2>";
183 $row = pg_fetch_assoc($result);
186 $upload_pk = $row[
"upload_fk"];
187 pg_free_result($result);
192 "onchange=\"addArsGo('newds','selectbdata');\"");
196 return $BucketSelect;
200 $sql =
"select agent_fk, nomosagent_fk, bucketpool_fk from bucket_ars where ars_pk=$ars_pk";
203 $row = pg_fetch_assoc($result);
204 $bucketagent_pk = $row[
"agent_fk"];
205 $nomosagent_pk = $row[
"nomosagent_fk"];
206 $bucketpool_pk = $row[
"bucketpool_fk"];
207 pg_free_result($result);
215 $sql =
"SELECT distinct(bucket_fk) as bucket_pk,
216 count(bucket_fk) as bucketcount, bucket_reportorder
217 from bucket_file, bucket_def,
218 (SELECT distinct(pfile_fk) as PF from $this->uploadtree_tablename
219 where upload_fk=$upload_pk
220 and ((ufile_mode & (1<<28))=0)
221 and ((ufile_mode & (1<<29))=0)
222 and $this->uploadtree_tablename.lft BETWEEN $lft and $rgt) as SS
223 where PF=pfile_fk and agent_fk=$bucketagent_pk
224 and bucket_file.nomosagent_fk=$nomosagent_pk
225 and bucket_pk=bucket_fk
226 and bucketpool_fk=$bucketpool_pk
227 group by bucket_fk,bucket_reportorder
228 order by bucket_reportorder asc";
231 $historows = pg_fetch_all($result);
232 pg_free_result($result);
235 if (!empty($BucketSelect))
237 $action =
Traceback_uri() .
"?mod=bucketbrowser&upload=$upload_pk&item=$Uploadtree_pk";
239 $VLic .=
"<script type='text/javascript'>
240 function addArsGo(formid, selectid )
242 var selectobj = document.getElementById(selectid);
243 var ars_pk = selectobj.options[selectobj.selectedIndex].value;
244 document.getElementById(formid).action='$action'+'&ars='+ars_pk;
245 document.getElementById(formid).submit();
251 $VLic .=
"<form action='$action' id='newds' method='POST'>\n";
252 $VLic .= $BucketSelect;
256 $sql =
"select bucketpool_name, version from bucketpool where bucketpool_pk=$bucketpool_pk";
259 $row = pg_fetch_assoc($result);
260 $bucketpool_name = $row[
'bucketpool_name'];
261 $bucketpool_version = $row[
'version'];
262 pg_free_result($result);
266 $Uniquebucketcount = 0;
268 if (is_array($historows))
270 $text = _(
"Bucket Pool");
271 $VLic .=
"$text: $bucketpool_name v$bucketpool_version<br>";
272 $VLic .=
"<table border=1 width='100%'>\n";
274 $VLic .=
"<tr><th width='10%'>$text</th>";
276 $VLic .=
"<th width='10%'>$text</th>";
278 $VLic .=
"<th align='left'>$text</th></tr>\n";
280 foreach($historows as $bucketrow)
282 $Uniquebucketcount++;
283 $bucket_pk = $bucketrow[
'bucket_pk'];
284 $bucketcount = $bucketrow[
'bucketcount'];
285 $bucket_name = $bucketDefArray[$bucket_pk][
'bucket_name'];
286 $bucket_color = $bucketDefArray[$bucket_pk][
'bucket_color'];
289 $VLic .=
"<tr><td align='right' style='background-color:$bucket_color'>$bucketcount</td>";
292 $VLic .=
"<td align='center'><a href='";
295 $VLic .=
"?mod=list_bucket_files&bapk=$bucketagent_pk&item=$Uploadtree_pk&bpk=$bucket_pk&bp=$bucketpool_pk&napk=$nomosagent_pk" .
"'>$text</a></td>";
298 $VLic .=
"<td align='left'>";
299 $VLic .=
"<a id='$bucket_pk' onclick='FileColor_Get(\"" .
Traceback_uri() .
"?mod=ajax_filebucket&bapk=$bucketagent_pk&item=$Uploadtree_pk&bucket_pk=$bucket_pk\")'";
300 $VLic .=
">$bucket_name </a>";
312 $VLic .=
"</table>\n";
314 $text = _(
"Unique buckets");
315 $VLic .=
"$text: $Uniquebucketcount<br>\n";
323 if (count($Children) == 0)
325 $sql =
"SELECT * FROM $this->uploadtree_tablename WHERE uploadtree_pk = '$Uploadtree_pk'";
328 $row = pg_fetch_assoc($result);
329 pg_free_result($result);
330 if (empty($row) || (
IsDir($row[
'ufile_mode']))) {
348 $VF .=
"<table border=0>";
349 foreach($Children as $C)
360 $IsDir =
Isdir($C[
'ufile_mode']);
364 if (!empty($C[
'pfile_fk']) && !empty($ModLicView))
367 $LinkUri .=
"?mod=view-license&napk=$nomosagent_pk&bapk=$bucketagent_pk&upload=$upload_pk&item=$C[uploadtree_pk]";
379 $LicUri =
"$tmpuri&item=" . $uploadtree_pk;
388 $VF .=
"<tr><td id='$C[uploadtree_pk]' align='left'>";
393 $VF .=
"<a href='$LicUri'>"; $HasHref=1;
394 $VF .=
"<b>"; $HasBold=1;
396 else if (!empty($LinkUri))
398 $VF .=
"<a href='$LinkUri'>"; $HasHref=1;
400 $VF .= $C[
'ufile_name'];
413 $VF .=
"<span style='position:relative;left:1em'>";
416 $bucketDefArray,
",", True);
418 $VF .=
"</td><td valign='top'>";
435 <script type=\"text/javascript\" charset=\"utf-8\">
436 var Lastutpks=''; /* save last list of uploadtree_pk's */
437 var Lastbupk=''; /* save last bucket_pk */
438 var color = '#4bfe78';
439 function FileColor_Reply()
441 if ((FileColor.readyState==4) && (FileColor.status==200))
443 /* remove previous highlighting */
444 var numpks = Lastutpks.length;
445 if (numpks > 0) document.getElementById(Lastbupk).style.backgroundColor='white';
448 document.getElementById(Lastutpks[--numpks]).style.backgroundColor='white';
451 utpklist = FileColor.responseText.split(',');
452 Lastbupk = utpklist.shift();
453 numpks = utpklist.length;
454 Lastutpks = utpklist;
456 /* apply new highlighting */
457 elt = document.getElementById(Lastbupk);
458 if (elt != null) elt.style.backgroundColor=color;
461 document.getElementById(utpklist[--numpks]).style.backgroundColor=color;
483 $V .=
"<table border=0 width='100%'>\n";
484 $V .=
"<tr><td valign='top' width='50%'>$VLic</td><td valign='top'>$VF</td></tr>\n";
501 function TagBucket($upload_pk, $uploadtree_pk, $bucketagent_pk, $bucket_pk, $bucketpool_pk, $nomosagent_pk)
512 $uTime = microtime(
true);
516 $uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
517 if ( !$uploadDao->isAccessible($Upload, Auth::getGroupId()) )
519 $text = _(
"Permission Denied");
520 return "<h2>$text</h2>";
526 return _(
'No item selected');
538 $CacheKey =
"?mod=" . $this->Name .
Traceback_parm_keep(array(
"upload",
"item",
"folder",
"ars")) ;
541 $_SERVER[
'REQUEST_URI'] = preg_replace(
"/&updcache=[0-9]*/",
"",$_SERVER[
'REQUEST_URI']);
542 unset($_GET[
'updcache']);
550 if (!empty($tagbucket))
556 $this->
TagBucket($Upload, $Item, $bucketagent_pk, $bucket_pk, $bucketpool_pk, $nomosagent_pk);
559 $Cached = !empty($V);
562 $V .=
"<font class='text'>\n";
565 if (count($Children) == 0)
572 $Uri = preg_replace(
"/&item=([0-9]*)/",
"",
Traceback());
576 $text = _(
"Loading...");
579 $Time = microtime(
true) - $uTime;
580 $text = _(
"Elapsed time: %.2f seconds");
581 $V .= sprintf(
"<p><small>$text</small>", $Time);
585 $text1 = _(
"Update");
586 echo
" <i>$text</i> <a href=\"$_SERVER[REQUEST_URI]&updcache=1\"> $text1 </a>";
588 else if ($Time > 0.5)
598 $NewPlugin->Initialize();
char * uploadtree_tablename
upload.uploadtree_tablename
This is the Plugin class. All plugins should:
Output()
This function is called when user output is requested. This function is responsible for content....
Contains the constants and helpers for authentication of user.
TagBucket($upload_pk, $uploadtree_pk, $bucketagent_pk, $bucket_pk, $bucketpool_pk, $nomosagent_pk)
Tag a bucket.
RegisterMenus()
Customize submenus.
__construct()
base constructor. Most plugins will just use this
Install()
Create and configure database tables.
Initialize()
This is called before the plugin is used. It should assume that Install() was already run one time (p...
ShowUploadHist($Uploadtree_pk, $Uri)
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
initBucketDefArray($bucketpool_pk)
Initializes array of bucket_def records.
GetFileBuckets_string($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketDefArray, $delimiter, $color)
Get string of $delimiter delimited bucket names for the given inputs. Args are same as GetFileBuckets...
SelectBucketDataset($upload_pk, &$ars_pk, $id="selectbucketdataset", $extra="")
Return a select list showing all the successful bucket runs on a particular $upload_pk.
ReportCacheGet($CacheKey)
This function is used by Output() to see if the requested report is in the report cache.
ReportCachePut($CacheKey, $CacheValue)
This function is used to write a record to the report cache. If the record already exists,...
ReportCachePurgeByKey($CacheKey)
Purge from the report cache the record with $CacheKey.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).
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.
FileListLinks($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray=array(), $uploadtree_tablename="uploadtree", $wantTags=true)
Get list of links: [View][Info][Download]
Traceback_uri()
Get the URI without query to this location.
Traceback()
Get the URI + query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
GetPkgMimetypes()
Get package mimetype.
GetArrayVal($Key, $Arr)
Get the value from a array(map)
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
int IsDir(char *Fname)
Given a filename, is it a directory?