48 function __construct()
50 $this->Name =
"list_bucket_files";
51 $this->Title = _(
"List Files for Bucket");
52 $this->Dependency = array(
"nomoslicense");
55 parent::__construct();
71 $URL = $this->Name .
"&bapk=$bucketagent_pk&item=$uploadtree_pk&bpk=$bucket_pk&bp=$bucketpool_pk&napk=$nomosagent_pk&page=-1";
72 $text = _(
"Show All Files");
73 menu_insert($this->Name.
"::Show All",0, $URL, $text);
90 $this->
State=PLUGIN_STATE_VALID;
91 $this->
State=PLUGIN_STATE_READY;
103 if ($this->
State != PLUGIN_STATE_READY) {
117 if (empty($uploadtree_pk) || empty($bucket_pk) || empty($bucketpool_pk))
119 $text = _(
"is missing required parameters.");
120 echo $this->Name .
" $text";
125 $Row =
GetSingleRec(
"uploadtree",
"WHERE uploadtree_pk = $uploadtree_pk");
127 $uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
128 if ( !$uploadDao->isAccessible($Row[
'upload_fk'], Auth::getGroupId()) )
130 $text = _(
"Permission Denied");
131 echo
"<h2>$text item 1</h2>";
146 $sql =
"select bucket_pk, bucket_name from bucket_def where bucketpool_fk=$bucketpool_pk";
147 $result_name = pg_query($PG_CONN, $sql);
149 $bucketNameCache = array();
150 while ($name_row = pg_fetch_assoc($result_name)) {
151 $bucketNameCache[$name_row[
'bucket_pk']] = $name_row[
'bucket_name'];
153 pg_free_result($result_name);
155 switch($this->OutputType)
164 $V .= _(
"The following files are in bucket: '<b>");
165 $V .= $bucketNameCache[$bucket_pk];
167 $text = _(
"Display");
168 $text1 = _(
"excludes");
169 $text2 = _(
"files with these licenses");
170 if (!empty($Excl)) $V .=
"<br>$text <b>$text1</b> $text2: $Excl";
172 $Offset = ($Page <= 0) ? 0 : $Page*$Max;
176 $sql =
"SELECT lft,rgt,upload_fk FROM uploadtree 177 WHERE uploadtree_pk = $uploadtree_pk";
178 $result = pg_query($PG_CONN, $sql);
180 $row = pg_fetch_assoc($result);
183 $upload_pk = $row[
"upload_fk"];
184 pg_free_result($result);
198 $Offset= ($Page < 0) ? 0 : $Page*$Max;
199 $limit = ($Page < 0) ?
"ALL":$Max;
205 $sql =
"select uploadtree.*, bucket_file.nomosagent_fk as nomosagent_fk 206 from uploadtree, bucket_file, bucket_def 207 where upload_fk=$upload_pk and uploadtree.lft between $lft and $rgt 208 and ((ufile_mode & (3<<28)) = 0) 209 and uploadtree.pfile_fk=bucket_file.pfile_fk 210 and agent_fk=$bucketagent_pk 211 and bucket_fk=$bucket_pk 212 and bucketpool_fk=$bucketpool_pk 213 and bucket_pk=bucket_fk 214 and nomosagent_fk=$nomosagent_pk 215 order by uploadtree.ufile_name 216 limit $limit offset $Offset";
217 $fileresult = pg_query($PG_CONN, $sql);
219 $Count = pg_num_rows($fileresult);
221 $file_result_temp = pg_fetch_all($fileresult);
222 $sourted_file_result = array();
225 for($i = 0; $i < $max_num; $i++)
227 $row = $file_result_temp[$i];
228 if (empty($row))
continue;
229 array_push($sourted_file_result, $row);
230 for($j = $i + 1; $j < $max_num; $j++)
232 $row_next = $file_result_temp[$j];
233 if (!empty($row_next) && ($row[
'pfile_fk'] == $row_next[
'pfile_fk']))
235 array_push($sourted_file_result, $row_next);
236 $file_result_temp[$j] = null;
241 if ($Count < (1.25 * $Max)) $Max = $Count;
242 if ($Max < 1) $Max = 1;
245 if (($Count >= $Max) && ($Page >= 0))
247 $VM =
"<P />\n" .
MenuEndlessPage($Page,intval((($Count+$Offset)/$Max))) .
"<P />\n";
256 $baseURL =
"?mod=" . $this->Name .
"&bapk=$bucketagent_pk&item=$uploadtree_pk&bpk=$bucket_pk&bp=$bucketpool_pk&napk=$nomosagent_pk&page=-1";
263 $LinkLast =
"list_bucket_files&bapk=$bucketagent_pk";
268 $V .=
"<tr><th>$text</th><th> ";
269 $ExclArray = explode(
":", $Excl);
274 foreach ($sourted_file_result as $row)
277 $pfile_pk = $row[
'pfile_fk'];
278 $licstring =
GetFileLicenses_string($nomosagent_pk, $row[
'pfile_fk'], $row[
'uploadtree_pk'], $uploadtree_tablename);
279 if (empty($licstring)) $licstring =
'-';
280 $URLlicstring = urlencode($licstring);
284 $URL = $baseURL .
"&excl=".urlencode($Excl).
":".$URLlicstring;
286 $URL = $baseURL .
"&excl=$URLlicstring";
287 $text = _(
"Exclude files with license");
288 $Header =
"<a href=$URL>$text: $licstring.</a>";
290 $ok = !($Excl && in_array($licstring, $ExclArray));
294 $nomosagent_pk = $row[
'nomosagent_fk'];
295 $LinkLast =
"view-license&bapk=$bucketagent_pk&napk=$nomosagent_pk";
297 if ($PrevPfile_pk == $pfile_pk)
299 $V .=
"<div style='margin-left:2em;'>";
305 $V .=
Dir2Browse(
"browse", $row[
'uploadtree_pk'], $LinkLast, $ShowBox, $ShowMicro, ++$RowNum, $Header,
'', $uploadtree_tablename);
309 $V .=
"<td> </td>";
313 $V .=
"<td>$licstring</td></tr>";
314 $V .=
"<tr><td colspan=3><hr></td></tr>";
316 $PrevPfile_pk = $pfile_pk;
318 pg_free_result($fileresult);
324 $Time = time() - $Time;
325 $text = _(
"Elapsed time");
326 $text1 = _(
"seconds");
327 $V .=
"<small>$text: $Time $text1</small>\n";
334 if (!$this->OutputToStdout) {
344 $NewPlugin->Initialize();
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"...
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.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Initialize()
This is called before the plugin is used.
RegisterMenus()
Customize submenus.
GetFileLicenses_string($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree')
Same as GetFileLicenses() but returns license list as a single string.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Output()
This function is called when user output is requested. This function is responsible for content...