40 $NoData .=
"<script language='javascript'>\n";
41 $NoData .=
"function Schedule_Reply()\n";
43 $NoData .=
" if ((Schedule.readyState==4) && (Schedule.status==200))\n";
44 $NoData .=
" document.getElementById('msgdiv').innerHTML = Schedule.responseText;\n";
46 $NoData .=
"</script>\n";
48 $NoData .=
"<form name='formy' method='post'>\n";
49 $NoData .=
"<div id='msgdiv'>\n";
50 $NoData .= _(
"No data available.");
51 $NoData .=
"<input type='button' name='scheduleAgent' value='Schedule Agent'";
52 $NoData .=
"onClick='Schedule_Get(\"" .
Traceback_uri() .
"?mod=schedule_agent&upload=$upload_pk&agent=agent_bucket \")'>\n";
53 $NoData .=
"</input>";
54 $NoData .=
"</div> \n";
55 $NoData .=
"</form>\n";
58 $select =
"<select name='$name' id='$id' $extra>";
61 $sql =
"select ars_pk, bucketpool_pk, bucketpool_name, version from bucketpool, bucket_ars where active='Y' and bucketpool_fk=bucketpool_pk and ars_success=True and upload_fk='$upload_pk' order by ars_starttime desc";
64 $NumRows = pg_num_rows($result);
68 $rows = pg_fetch_all($result);
69 pg_free_result($result);
71 $ars_pk = $rows[0][
'ars_pk'];
76 $sql =
"select default_bucketpool_fk from users where user_pk='$_SESSION[UserId]'";
79 $row = pg_fetch_assoc($result);
80 $DefaultBucketpool_pk = $row[
'default_bucketpool_fk'];
81 pg_free_result($result);
85 foreach ($rows as $row) {
86 if ($row[
'bucketpool_pk'] == $DefaultBucketpool_pk) {
87 $ars_pk = $row[
'ars_pk'];
95 foreach ($rows as $row) {
96 $select .=
"<option value='$row[ars_pk]'";
99 $select .=
" SELECTED ";
100 $ars_pk = $row[
"ars_pk"];
101 }
else if ($ars_pk == $row[
'ars_pk']) {
102 $select .=
" SELECTED ";
105 $select .=
">$row[bucketpool_name], v $row[version]\n";
107 $select .=
"</select>";
125 $id =
"default_bucketpool_fk";
127 $select =
"<select name='$name' id='$id' class='ui-render-select2'>";
130 if ($active ==
'Y') {
131 $Where =
"where active='Y'";
135 $sql =
"select * from bucketpool $Where order by bucketpool_name asc,version desc";
139 while ($row = pg_fetch_assoc($result)) {
140 $select .=
"<option value='$row[bucketpool_pk]'";
141 if ($row[
'bucketpool_pk'] == $selected) {
142 $select .=
" SELECTED ";
144 $select .=
">$row[bucketpool_name], v $row[version]</option>\n";
146 $select .=
"</select>";
162 function GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk)
165 $BuckArray = array();
167 if (empty($nomosagent_pk) || empty($bucketagent_pk) || empty($uploadtree_pk)) {
169 "Missing parameter: nomosagent_pk $nomosagent_pk, bucketagent_pk: $bucketagent_pk, uploadtree_pk: $uploadtree_pk<br>",
174 $sql =
"SELECT lft,rgt,upload_fk FROM uploadtree
175 WHERE uploadtree_pk = $uploadtree_pk";
178 if (pg_num_rows($result) < 1) {
179 pg_free_result($result);
182 $row = pg_fetch_assoc($result);
185 $upload_pk = $row[
"upload_fk"];
186 pg_free_result($result);
189 $sql =
"SELECT distinct(bucket_fk) as bucket_pk
190 from bucket_file, bucket_def,
191 (SELECT distinct(pfile_fk) as PF from uploadtree
192 where upload_fk=$upload_pk
193 and ((ufile_mode & (1<<28))=0)
194 and uploadtree.lft BETWEEN $lft and $rgt) as SS
195 where PF=pfile_fk and agent_fk=$bucketagent_pk
196 and bucket_file.nomosagent_fk=$nomosagent_pk
197 and bucket_pk=bucket_fk
198 and bucketpool_fk=$bucketpool_pk";
202 while ($row = pg_fetch_assoc($result)) {
203 $BuckArray[] = $row[
'bucket_pk'];
205 pg_free_result($result);
227 $bucketDefArray, $delimiter, $color)
230 $defrec = current($bucketDefArray);
231 $bucketpool_pk = $defrec[
'bucketpool_fk'];
232 $BuckArray =
GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk);
233 if (empty($BuckArray)) {
238 $BuckNames = array();
239 foreach ($BuckArray as $bucket_pk) {
240 $BuckNames[$bucket_pk] = $bucketDefArray[$bucket_pk][
'bucket_name'];
244 natcasesort($BuckNames);
247 foreach ($BuckNames as $bucket_name) {
251 $outstr .= $delimiter .
" ";
255 $bucket_pk = array_search($bucket_name, $BuckNames);
256 $bucket_color = $bucketDefArray[$bucket_pk][
'bucket_color'];
257 $outstr .=
"<span style='background-color:$bucket_color'>";
258 $outstr .= $bucket_name;
259 $outstr .=
"</span>";
261 $outstr .= $bucket_name;
282 $BuckArray = array();
284 if (empty($bucket_pk) || empty($uploadtree_pk)) {
286 "Missing parameter: bucket_pk: $bucket_pk, uploadtree_pk: $uploadtree_pk<br>",
291 $sql =
"SELECT lft,rgt, upload_fk FROM uploadtree WHERE uploadtree_pk = $uploadtree_pk";
294 if (pg_num_rows($result) < 1) {
295 pg_free_result($result);
298 $row = pg_fetch_assoc($result);
301 $upload_fk = $row[
"upload_fk"];
302 pg_free_result($result);
305 $sql =
"SELECT bucket_fk from bucket_file,
306 (SELECT distinct(pfile_fk) as PF from uploadtree
307 where uploadtree.lft BETWEEN $lft and $rgt and upload_fk='$upload_fk') as SS
308 where PF=pfile_fk and bucket_fk='$bucket_pk' limit 1";
312 if (pg_num_rows($result) == 0) {
317 pg_free_result($result);
334 $sql =
"select * from bucket_def where bucketpool_fk=$bucketpool_pk";
335 $result_name = pg_query(
$PG_CONN, $sql);
337 $bucketDefArray = array();
338 while ($name_row = pg_fetch_assoc($result_name)) {
339 $bucketDefArray[$name_row[
'bucket_pk']] = $name_row;
341 pg_free_result($result_name);
342 return $bucketDefArray;
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
SelectBucketPool($selected, $active='Y')
Return a select list containing all the active bucketpool's.
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.
GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk)
Get all the unique bucket_pk's for a given uploadtree_pk and for a given nomos and bucket agent.
BucketInTree($bucket_pk, $uploadtree_pk)
Check if a bucket_pk is found in a tree for a given nomos and bucket agent.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Traceback_uri()
Get the URI without query to this location.
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN