39 $this->Name =
"list_bucket_files";
40 $this->Title = _(
"List Files for Bucket");
41 $this->Dependency = array(
"nomoslicense");
44 parent::__construct();
60 $URL = $this->Name .
"&bapk=$bucketagent_pk&item=$uploadtree_pk&bpk=$bucket_pk&bp=$bucketpool_pk&napk=$nomosagent_pk&page=-1";
61 $text = _(
"Show All Files");
62 menu_insert($this->Name.
"::Show All",0, $URL, $text);
79 $this->
State=PLUGIN_STATE_READY;
90 if ($this->
State != PLUGIN_STATE_READY) {
104 if (empty($uploadtree_pk) || empty($bucket_pk) || empty($bucketpool_pk))
106 $text = _(
"is missing required parameters.");
107 echo $this->Name .
" $text";
112 $Row =
GetSingleRec(
"uploadtree",
"WHERE uploadtree_pk = $uploadtree_pk");
114 $uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
115 if ( !$uploadDao->isAccessible($Row[
'upload_fk'], Auth::getGroupId()) )
117 $text = _(
"Permission Denied");
118 echo
"<h2>$text item 1</h2>";
133 $sql =
"select bucket_pk, bucket_name from bucket_def where bucketpool_fk=$bucketpool_pk";
134 $result_name = pg_query(
$PG_CONN, $sql);
136 $bucketNameCache = array();
137 while ($name_row = pg_fetch_assoc($result_name)) {
138 $bucketNameCache[$name_row[
'bucket_pk']] = $name_row[
'bucket_name'];
140 pg_free_result($result_name);
142 switch($this->OutputType)
151 $V .= _(
"The following files are in bucket: '<b>");
152 $V .= $bucketNameCache[$bucket_pk];
154 $text = _(
"Display");
155 $text1 = _(
"excludes");
156 $text2 = _(
"files with these licenses");
157 if (!empty($Excl)) $V .=
"<br>$text <b>$text1</b> $text2: $Excl";
159 $Offset = ($Page <= 0) ? 0 : $Page*$Max;
163 $sql =
"SELECT lft,rgt,upload_fk FROM uploadtree
164 WHERE uploadtree_pk = $uploadtree_pk";
167 $row = pg_fetch_assoc($result);
170 $upload_pk = $row[
"upload_fk"];
171 pg_free_result($result);
185 $Offset= ($Page < 0) ? 0 : $Page*$Max;
186 $limit = ($Page < 0) ?
"ALL":$Max;
192 $sql =
"select uploadtree.*, bucket_file.nomosagent_fk as nomosagent_fk
193 from uploadtree, bucket_file, bucket_def
194 where upload_fk=$upload_pk and uploadtree.lft between $lft and $rgt
195 and ((ufile_mode & (3<<28)) = 0)
196 and uploadtree.pfile_fk=bucket_file.pfile_fk
197 and agent_fk=$bucketagent_pk
198 and bucket_fk=$bucket_pk
199 and bucketpool_fk=$bucketpool_pk
200 and bucket_pk=bucket_fk
201 and nomosagent_fk=$nomosagent_pk
202 order by uploadtree.ufile_name
203 limit $limit offset $Offset";
204 $fileresult = pg_query(
$PG_CONN, $sql);
206 $Count = pg_num_rows($fileresult);
208 $file_result_temp = pg_fetch_all($fileresult);
209 $sourted_file_result = array();
212 for($i = 0; $i < $max_num; $i++)
214 $row = $file_result_temp[$i];
215 if (empty($row))
continue;
216 $sourted_file_result[] = $row;
217 for($j = $i + 1; $j < $max_num; $j++)
219 $row_next = $file_result_temp[$j];
220 if (!empty($row_next) && ($row[
'pfile_fk'] == $row_next[
'pfile_fk']))
222 $sourted_file_result[] = $row_next;
223 $file_result_temp[$j] =
null;
228 if ($Count < (1.25 * $Max)) $Max = $Count;
229 if ($Max < 1) $Max = 1;
232 if (($Count >= $Max) && ($Page >= 0))
234 $VM =
"<P />\n" .
MenuEndlessPage($Page,intval((($Count+$Offset)/$Max))) .
"<P />\n";
243 $baseURL =
"?mod=" . $this->Name .
"&bapk=$bucketagent_pk&item=$uploadtree_pk&bpk=$bucket_pk&bp=$bucketpool_pk&napk=$nomosagent_pk&page=-1";
250 $LinkLast =
"list_bucket_files&bapk=$bucketagent_pk";
255 $V .=
"<tr><th>$text</th><th> ";
256 $ExclArray = explode(
":", $Excl);
261 foreach ($sourted_file_result as $row)
264 $pfile_pk = $row[
'pfile_fk'];
265 $licstring =
GetFileLicenses_string($nomosagent_pk, $row[
'pfile_fk'], $row[
'uploadtree_pk'], $uploadtree_tablename);
266 if (empty($licstring)) $licstring =
'-';
267 $URLlicstring = urlencode($licstring);
271 $URL = $baseURL .
"&excl=".urlencode($Excl).
":".$URLlicstring;
273 $URL = $baseURL .
"&excl=$URLlicstring";
274 $text = _(
"Exclude files with license");
275 $Header =
"<a href=$URL>$text: $licstring.</a>";
277 $ok = !($Excl && in_array($licstring, $ExclArray));
281 $nomosagent_pk = $row[
'nomosagent_fk'];
282 $LinkLast =
"view-license&bapk=$bucketagent_pk&napk=$nomosagent_pk";
284 if ($PrevPfile_pk == $pfile_pk)
286 $V .=
"<div style='margin-left:2em;'>";
292 $V .=
Dir2Browse(
"browse", $row[
'uploadtree_pk'], $LinkLast, $ShowBox, $ShowMicro, ++$RowNum, $Header,
'', $uploadtree_tablename);
296 $V .=
"<td> </td>";
300 $V .=
"<td>$licstring</td></tr>";
301 $V .=
"<tr><td colspan=3><hr></td></tr>";
303 $PrevPfile_pk = $pfile_pk;
305 pg_free_result($fileresult);
311 $Time = time() - $Time;
312 $text = _(
"Elapsed time");
313 $text1 = _(
"seconds");
314 $V .=
"<small>$text: $Time $text1</small>\n";
321 if (!$this->OutputToStdout) {
331 $NewPlugin->Initialize();
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.
__construct()
base constructor. Most plugins will just use this
RegisterMenus()
Customize submenus.
Initialize()
This is called before the plugin is used.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
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.
GetFileLicenses_string($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree')
Same as GetFileLicenses() but returns license list as a single string.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
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