14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Component\HttpFoundation\Response;
19 const NAME =
"ajax_admin_scheduler";
23 function __construct()
25 parent::__construct(self::NAME, array(
26 self::TITLE => _(
"URL"),
37 public function handle(Request $request)
40 $operation = $request->get(
'operation');
42 $vars[
'operation'] = $operation;
44 $content = $this->renderer->load(
'ajax-admin-scheduler.html.twig')->render($vars);
46 'jobList' => $vars[
'jobOptions'] ?? [],
47 'priorityList' => $vars[
'priorityList'] ?? [],
52 if (
'pause' == $operation ||
'restart' == $operation ||
53 'status' == $operation ||
'priority' == $operation) {
55 }
else if (
'verbose' == $operation) {
57 $text2 = _(
"Select a verbosity level");
59 "<br>$text2: <select name='level_list' id='level_list'>$verbose_list_option</select>";
60 $restRes[
'verboseList'] = $verbose_list_option;
61 }
else if (
'agents' == $operation) {
63 $dbManager = $this->
getObject(
'db.manager');
64 $dbManager->prepare($stmt = __METHOD__ .
'.getAgents',
65 'SELECT MAX(agent_pk) agent_id, agent_name FROM agent WHERE agent_enabled GROUP BY agent_name');
66 $res = $dbManager->execute($stmt);
68 while ($row = $dbManager->fetchArray($res)) {
69 $restRes[
'agentList'][] = $row[
'agent_name'];
70 $V .=
"<li>$row[agent_name]</li>";
73 $dbManager->freeResult($res);
76 if ($request->get(
'fromRest')) {
79 return new Response($V, Response::HTTP_OK, array(
'content-type'=>
'text/htm'));
94 if (
'status' == $type ||
'verbose' == $type ||
'priority' == $type) {
96 if (
'priority' != $type) {
97 $job_array[0] =
"scheduler";
100 if (
'pause' == $type) {
103 if (
'restart' == $type) {
115 $verbose_list_option =
"";
119 for ($i = $min; $i <= $max; $i++) {
120 $bitmask= (1<<$i) - 1;
121 $verbose_list_option .=
"<option value='$bitmask'>$i</option>";
122 $restRes[] = $bitmask;
127 return $verbose_list_option;
139 $priority_list = array();
140 for ($i = $min; $i <= $max; $i++) {
141 $priority_list[$i]=$i;
147 return $priority_list;
151 register_plugin(
new AjaxAdminScheduler());
Contains the constants and helpers for authentication of user.
jobListOption($type)
get the job list for the specified operation
verboseListOption($fromRest=false)
get the verbose list: if the value of verbose is 1, set verbose as 1
priorityListOption($fromRest=false)
get the priority list for setting, -20..20
GetJobList($status)
Gets the list of jobqueue records with the requested $status.
GetRunnableJobList()
Get runnable job list, the process is below:
fo_dbManager * dbManager
fo_dbManager object