4 use Symfony\Component\HttpFoundation\Response;
19 define(
"TITLE_AJAX_SCHEDULE_AGENT", _(
"Schedule agent"));
30 $this->Name =
"schedule_agent";
31 $this->Title = TITLE_AJAX_SCHEDULE_AGENT;
33 parent::__construct();
34 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
46 if (empty($UploadPk) || empty($Agent)) {
47 return new Response(
'missing parameter', Response::HTTP_BAD_REQUEST,
48 array(
'Content-type' =>
'text/plain'));
50 $upload = $this->uploadDao->getUpload($UploadPk);
51 if ($upload ===
null) {
52 $errMsg = __FILE__ .
":" . __LINE__ .
" " . _(
"Upload") .
" " . $UploadPk .
54 return new Response($errMsg, Response::HTTP_BAD_REQUEST,
55 array(
'Content-type' =>
'text/plain'));
57 $ShortName = $upload->getFilename();
58 $user_pk = Auth::getUserId();
59 $group_pk = Auth::getGroupId();
60 $job_pk = JobAddJob($user_pk, $group_pk, $ShortName, $UploadPk);
62 $Dependencies = array();
63 $P = &$Plugins[plugin_find_id($Agent)];
64 $rv = $P->AgentAdd($job_pk, $UploadPk, $ErrorMsg, $Dependencies);
66 $text = _(
"Scheduling of Agent(s) failed: ");
67 return new Response($text . $rv . $ErrorMsg, Response::HTTP_BAD_REQUEST,
68 array(
'Content-type' =>
'text/plain'));
75 $scheduler_msg .= _(
"Is the scheduler running? ");
80 $text = _(
"Your jobs have been added to job queue.");
81 $LinkText = _(
"View Jobs");
82 $msg =
"$scheduler_msg".
"$text <a href=$URL>$LinkText</a>";
83 $this->vars[
'message'] = $msg;
84 return new Response($msg, Response::HTTP_OK, array(
'Content-type'=>
'text/plain'));
89 $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.
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.