4 use Symfony\Component\HttpFoundation\Response;
18 define(
"TITLE_AJAX_SCHEDULE_AGENT", _(
"Schedule agent"));
28 $this->Name =
"schedule_agent";
29 $this->Title = TITLE_AJAX_SCHEDULE_AGENT;
31 parent::__construct();
44 if (empty($UploadPk) || empty($Agent)) {
45 return new Response(
'missing parameter', Response::HTTP_BAD_REQUEST,
46 array(
'Content-type' =>
'text/plain'));
48 $sql =
"SELECT upload_pk, upload_filename FROM upload WHERE upload_pk = '$UploadPk'";
51 if (pg_num_rows($result) < 1) {
52 $errMsg = __FILE__ .
":" . __LINE__ .
" " . _(
"Upload") .
" " . $UploadPk .
54 return new Response($errMsg, Response::HTTP_BAD_REQUEST,
55 array(
'Content-type' =>
'text/plain'));
57 $UploadRow = pg_fetch_assoc($result);
58 $ShortName = $UploadRow[
'upload_filename'];
59 pg_free_result($result);
61 $user_pk = Auth::getUserId();
62 $group_pk = Auth::getGroupId();
63 $job_pk = JobAddJob($user_pk, $group_pk, $ShortName, $UploadPk);
65 $Dependencies = array();
66 $P = &$Plugins[plugin_find_id($Agent)];
67 $rv = $P->AgentAdd($job_pk, $UploadPk, $ErrorMsg, $Dependencies);
69 $text = _(
"Scheduling of Agent(s) failed: ");
70 return new Response($text . $rv . $ErrorMsg, Response::HTTP_BAD_REQUEST,
71 array(
'Content-type' =>
'text/plain'));
78 $scheduler_msg .= _(
"Is the scheduler running? ");
83 $text = _(
"Your jobs have been added to job queue.");
84 $LinkText = _(
"View Jobs");
85 $msg =
"$scheduler_msg".
"$text <a href=$URL>$LinkText</a>";
86 $this->vars[
'message'] = $msg;
87 return new Response($msg, Response::HTTP_OK, array(
'Content-type'=>
'text/plain'));
92 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
__construct()
base constructor. Most plugins will just use this
Output()
Display the loaded menu and plugins.
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.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
GetRunnableJobList()
Get runnable job list, the process is below:
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN