51 $NoData .=
"<script language='javascript'>\n";
52 $NoData .=
"function Schedule_Reply()\n";
54 $NoData .=
" if ((Schedule.readyState==4) && (Schedule.status==200))\n";
55 $NoData .=
" document.getElementById('msgdiv').innerHTML = Schedule.responseText;\n";
57 $NoData .=
"</script>\n";
59 $NoData .=
"<form name='formy' method='post'>\n";
60 $NoData .=
"<div id='msgdiv'>\n";
61 $NoData .= _(
"No data available.");
62 $NoData .=
"<input type='button' name='scheduleAgent' value='Schedule Agent'";
63 $NoData .=
"onClick='Schedule_Get(\"" .
Traceback_uri() .
"?mod=schedule_agent&upload=$upload_pk&agent=agent_bucket \")'>\n";
64 $NoData .=
"</input>";
65 $NoData .=
"</div> \n";
66 $NoData .=
"</form>\n";
69 $select =
"<select name='$name' id='$id' $extra>";
72 $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";
73 $result = pg_query($PG_CONN, $sql);
75 $NumRows = pg_num_rows($result);
79 $rows = pg_fetch_all($result);
80 pg_free_result($result);
82 $ars_pk = $rows[0][
'ars_pk'];
87 $sql =
"select default_bucketpool_fk from users where user_pk='$_SESSION[UserId]'";
88 $result = pg_query($PG_CONN, $sql);
90 $row = pg_fetch_assoc($result);
91 $DefaultBucketpool_pk = $row[
'default_bucketpool_fk'];
92 pg_free_result($result);
96 foreach ($rows as $row) {
97 if ($row[
'bucketpool_pk'] == $DefaultBucketpool_pk) {
98 $ars_pk = $row[
'ars_pk'];
106 foreach ($rows as $row) {
107 $select .=
"<option value='$row[ars_pk]'";
109 if (empty($ars_pk)) {
110 $select .=
" SELECTED ";
111 $ars_pk = $row[
"ars_pk"];
112 }
else if ($ars_pk == $row[
'ars_pk']) {
113 $select .=
" SELECTED ";
116 $select .=
">$row[bucketpool_name], v $row[version]\n";
118 $select .=
"</select>";
136 $id =
"default_bucketpool_fk";
138 $select =
"<select name='$name' id='$id' class='ui-render-select2'>";
141 if ($active ==
'Y') {
142 $Where =
"where active='Y'";
146 $sql =
"select * from bucketpool $Where order by bucketpool_name asc,version desc";
147 $result = pg_query($PG_CONN, $sql);
150 while ($row = pg_fetch_assoc($result)) {
151 $select .=
"<option value='$row[bucketpool_pk]'";
152 if ($row[
'bucketpool_pk'] == $selected) {
153 $select .=
" SELECTED ";
155 $select .=
">$row[bucketpool_name], v $row[version]</option>\n";
157 $select .=
"</select>";
173 function GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk)
176 $BuckArray = array();
178 if (empty($nomosagent_pk) || empty($bucketagent_pk) || empty($uploadtree_pk)) {
180 "Missing parameter: nomosagent_pk $nomosagent_pk, bucketagent_pk: $bucketagent_pk, uploadtree_pk: $uploadtree_pk<br>",
185 $sql =
"SELECT lft,rgt,upload_fk FROM uploadtree 186 WHERE uploadtree_pk = $uploadtree_pk";
187 $result = pg_query($PG_CONN, $sql);
189 if (pg_num_rows($result) < 1) {
190 pg_free_result($result);
193 $row = pg_fetch_assoc($result);
196 $upload_pk = $row[
"upload_fk"];
197 pg_free_result($result);
200 $sql =
"SELECT distinct(bucket_fk) as bucket_pk 201 from bucket_file, bucket_def, 202 (SELECT distinct(pfile_fk) as PF from uploadtree 203 where upload_fk=$upload_pk 204 and ((ufile_mode & (1<<28))=0) 205 and uploadtree.lft BETWEEN $lft and $rgt) as SS 206 where PF=pfile_fk and agent_fk=$bucketagent_pk 207 and bucket_file.nomosagent_fk=$nomosagent_pk 208 and bucket_pk=bucket_fk 209 and bucketpool_fk=$bucketpool_pk";
211 $result = pg_query($PG_CONN, $sql);
213 while ($row = pg_fetch_assoc($result)) {
214 $BuckArray[] = $row[
'bucket_pk'];
216 pg_free_result($result);
238 $bucketDefArray, $delimiter, $color)
241 $defrec = current($bucketDefArray);
242 $bucketpool_pk = $defrec[
'bucketpool_fk'];
243 $BuckArray =
GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk);
244 if (empty($BuckArray)) {
249 $BuckNames = array();
250 foreach ($BuckArray as $bucket_pk) {
251 $BuckNames[$bucket_pk] = $bucketDefArray[$bucket_pk][
'bucket_name'];
255 natcasesort($BuckNames);
258 foreach ($BuckNames as $bucket_name) {
262 $outstr .= $delimiter .
" ";
266 $bucket_pk = array_search($bucket_name, $BuckNames);
267 $bucket_color = $bucketDefArray[$bucket_pk][
'bucket_color'];
268 $outstr .=
"<span style='background-color:$bucket_color'>";
269 $outstr .= $bucket_name;
270 $outstr .=
"</span>";
272 $outstr .= $bucket_name;
293 $BuckArray = array();
295 if (empty($bucket_pk) || empty($uploadtree_pk)) {
297 "Missing parameter: bucket_pk: $bucket_pk, uploadtree_pk: $uploadtree_pk<br>",
302 $sql =
"SELECT lft,rgt, upload_fk FROM uploadtree WHERE uploadtree_pk = $uploadtree_pk";
303 $result = pg_query($PG_CONN, $sql);
305 if (pg_num_rows($result) < 1) {
306 pg_free_result($result);
309 $row = pg_fetch_assoc($result);
312 $upload_fk = $row[
"upload_fk"];
313 pg_free_result($result);
316 $sql =
"SELECT bucket_fk from bucket_file, 317 (SELECT distinct(pfile_fk) as PF from uploadtree 318 where uploadtree.lft BETWEEN $lft and $rgt and upload_fk='$upload_fk') as SS 319 where PF=pfile_fk and bucket_fk='$bucket_pk' limit 1";
321 $result = pg_query($PG_CONN, $sql);
323 if (pg_num_rows($result) == 0) {
328 pg_free_result($result);
345 $sql =
"select * from bucket_def where bucketpool_fk=$bucketpool_pk";
346 $result_name = pg_query($PG_CONN, $sql);
348 $bucketDefArray = array();
349 while ($name_row = pg_fetch_assoc($result_name)) {
350 $bucketDefArray[$name_row[
'bucket_pk']] = $name_row;
352 pg_free_result($result_name);
353 return $bucketDefArray;
SelectBucketPool($selected, $active='Y')
Return a select list containing all the active bucketpool's.
Traceback_uri()
Get the URI without query to this location.
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...
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
BucketInTree($bucket_pk, $uploadtree_pk)
Check if a bucket_pk is found in a tree for a given nomos and bucket agent.
SelectBucketDataset($upload_pk, &$ars_pk, $id="selectbucketdataset", $extra="")
Return a select list showing all the successful bucket runs on a particular $upload_pk.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
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...
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.