29 define(
"TITLE_AJAX_SCHEDULE_AGENT", _(
"Schedule agent"));
37 function __construct()
39 $this->Name =
"schedule_agent";
40 $this->Title = TITLE_AJAX_SCHEDULE_AGENT;
42 parent::__construct();
55 if (empty($UploadPk) || empty($Agent)) {
56 return new Response(
'missing parameter', Response::HTTP_BAD_REQUEST,
57 array(
'Content-type' =>
'text/plain'));
59 $sql =
"SELECT upload_pk, upload_filename FROM upload WHERE upload_pk = '$UploadPk'";
60 $result = pg_query($PG_CONN, $sql);
62 if (pg_num_rows($result) < 1) {
63 $errMsg = __FILE__ .
":" . __LINE__ .
" " . _(
"Upload") .
" " . $UploadPk .
65 return new Response($errMsg, Response::HTTP_BAD_REQUEST,
66 array(
'Content-type' =>
'text/plain'));
68 $UploadRow = pg_fetch_assoc($result);
69 $ShortName = $UploadRow[
'upload_filename'];
70 pg_free_result($result);
72 $user_pk = Auth::getUserId();
73 $group_pk = Auth::getGroupId();
74 $job_pk = JobAddJob($user_pk, $group_pk, $ShortName, $UploadPk);
76 $Dependencies = array();
77 $P = &$Plugins[plugin_find_id($Agent)];
78 $rv = $P->AgentAdd($job_pk, $UploadPk, $ErrorMsg, $Dependencies);
80 $text = _(
"Scheduling of Agent(s) failed: ");
81 return new Response($text . $rv . $ErrorMsg, Response::HTTP_BAD_REQUEST,
82 array(
'Content-type' =>
'text/plain'));
89 $scheduler_msg .= _(
"Is the scheduler running? ");
94 $text = _(
"Your jobs have been added to job queue.");
95 $LinkText = _(
"View Jobs");
96 $msg =
"$scheduler_msg".
"$text <a href=$URL>$LinkText</a>";
97 $this->vars[
'message'] = $msg;
98 return new Response($msg, Response::HTTP_OK, array(
'Content-type'=>
'text/plain'));
103 $NewPlugin->Initialize();
GetRunnableJobList()
Get runnable job list, the process is below:
Traceback_uri()
Get the URI without query to this location.
#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:
Output()
Display the loaded menu and plugins.
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.