ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCronManagerGUI Class Reference

Class ilCronManagerGUI. More...

+ Collaboration diagram for ilCronManagerGUI:

Public Member Functions

 executeCommand ()
 
 render ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 initEditForm ($a_job_id)
 
 update ()
 
 run ()
 
 confirmedRun ()
 
 activate ()
 
 confirmedActivate ()
 
 deactivate ()
 
 confirmedDeactivate ()
 
 reset ()
 
 confirmedReset ()
 
 addToExternalSettingsForm ($a_form_id)
 

Protected Member Functions

 getMultiActionData ()
 

Detailed Description

Class ilCronManagerGUI.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Id
class.ilObjFolderGUI.php 25134 2010-08-13 14:22:11Z smeyer

ilCronManagerGUI:

Definition at line 16 of file class.ilCronManagerGUI.php.

Member Function Documentation

◆ activate()

ilCronManagerGUI::activate ( )

Definition at line 215 of file class.ilCronManagerGUI.php.

216  {
217  $this->confirm("activate");
218  }

◆ addToExternalSettingsForm()

ilCronManagerGUI::addToExternalSettingsForm (   $a_form_id)

Definition at line 362 of file class.ilCronManagerGUI.php.

References $data, array, ilCronManager\getCronJobData(), and ilCronManager\getJobInstance().

363  {
364  $fields = array();
365 
367  foreach ($data as $item) {
369  $item["job_id"],
370  $item["component"],
371  $item["class"],
372  $item["path"]
373  );
374 
375  if (method_exists($job, "addToExternalSettingsForm")) {
376  $job->addToExternalSettingsForm($a_form_id, $fields, $item["job_status"]);
377  }
378  }
379 
380  if (sizeof($fields)) {
381  return array("cron_jobs"=>array("jumpToCronJobs", $fields));
382  }
383  }
static getJobInstance($a_id, $a_component, $a_class, $a_path=null)
Get job instance (by job data)
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ confirmedActivate()

ilCronManagerGUI::confirmedActivate ( )

Definition at line 220 of file class.ilCronManagerGUI.php.

References $ilCtrl, $lng, ilCronManager\activateJob(), getMultiActionData(), ilCronManager\isJobInactive(), ilCronManager\resetJob(), and ilUtil\sendSuccess().

221  {
222  global $ilCtrl, $lng;
223 
224  $jobs = $this->getMultiActionData();
225  if ($jobs) {
226  foreach ($jobs as $job) {
227  if (ilCronManager::isJobInactive($job->getId())) {
229  ilCronManager::activateJob($job, true);
230  }
231  }
232 
233  ilUtil::sendSuccess($lng->txt("cron_action_activate_success"), true);
234  }
235 
236  $ilCtrl->redirect($this, "render");
237  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static activateJob(ilCronJob $a_job, $a_manual=false)
Activate cron job.
static isJobInactive($a_job_id)
Check if given job is currently inactive.
static resetJob(ilCronJob $a_job)
Reset job.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

Definition at line 244 of file class.ilCronManagerGUI.php.

References $ilCtrl, $lng, ilCronManager\deactivateJob(), getMultiActionData(), ilCronManager\isJobActive(), and ilUtil\sendSuccess().

245  {
246  global $ilCtrl, $lng;
247 
248  $jobs = $this->getMultiActionData();
249  if ($jobs) {
250  foreach ($jobs as $job) {
251  if (ilCronManager::isJobActive($job->getId())) {
252  ilCronManager::deactivateJob($job, true);
253  }
254  }
255 
256  ilUtil::sendSuccess($lng->txt("cron_action_deactivate_success"), true);
257  }
258 
259  $ilCtrl->redirect($this, "render");
260  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static deactivateJob(ilCronJob $a_job, $a_manual=false)
Deactivate cron job.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
static isJobActive($a_job_id)
Check if given job is currently active.
+ Here is the call graph for this function:

◆ confirmedReset()

ilCronManagerGUI::confirmedReset ( )

Definition at line 267 of file class.ilCronManagerGUI.php.

References $ilCtrl, $lng, getMultiActionData(), ilCronManager\isJobActive(), ilCronManager\resetJob(), and ilUtil\sendSuccess().

268  {
269  global $ilCtrl, $lng;
270 
271  $jobs = $this->getMultiActionData();
272  if ($jobs) {
273  foreach ($jobs as $job) {
274  if (ilCronManager::isJobActive($job->getId())) {
276  }
277  }
278  ilUtil::sendSuccess($lng->txt("cron_action_reset_success"), true);
279  }
280 
281  $ilCtrl->redirect($this, "render");
282  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static resetJob(ilCronJob $a_job)
Reset job.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
static isJobActive($a_job_id)
Check if given job is currently active.
+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

Definition at line 199 of file class.ilCronManagerGUI.php.

References $_GET, $ilCtrl, $lng, ilCronManager\runJobManual(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

200  {
201  global $ilCtrl, $lng;
202 
203  $job_id = $_GET["jid"];
204  if ($job_id) {
205  if (ilCronManager::runJobManual($job_id)) {
206  ilUtil::sendSuccess($lng->txt("cron_action_run_success"), true);
207  } else {
208  ilUtil::sendFailure($lng->txt("cron_action_run_fail"), true);
209  }
210  }
211 
212  $ilCtrl->redirect($this, "render");
213  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static runJobManual($a_job_id)
Run single job manually.
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ deactivate()

ilCronManagerGUI::deactivate ( )

Definition at line 239 of file class.ilCronManagerGUI.php.

240  {
241  $this->confirm("deactivate");
242  }

◆ edit()

ilCronManagerGUI::edit ( ilPropertyFormGUI  $a_form = null)

Definition at line 46 of file class.ilCronManagerGUI.php.

References $id, $ilCtrl, $tpl, and initEditForm().

Referenced by update().

47  {
48  global $ilCtrl, $tpl;
49 
50  $id = $_REQUEST["jid"];
51  if (!$id) {
52  $ilCtrl->redirect($this, "render");
53  }
54 
55  if (!$a_form) {
56  $a_form = $this->initEditForm($id);
57  }
58 
59  $tpl->setContent($a_form->getHTML());
60  }
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCronManagerGUI::executeCommand ( )

Definition at line 18 of file class.ilCronManagerGUI.php.

References $ilCtrl, and $lng.

19  {
20  global $ilCtrl, $lng;
21 
22  $lng->loadLanguageModule("cron");
23 
24  $cmd = $ilCtrl->getCmd("render");
25  $this->$cmd();
26 
27  return true;
28  }
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

Definition at line 284 of file class.ilCronManagerGUI.php.

References $ilCtrl, $lng, $res, $title, $tpl, array, ilCronManager\getJobInstanceById(), and ilUtil\sendFailure().

Referenced by confirmedActivate(), confirmedDeactivate(), and confirmedReset().

285  {
286  $res = array();
287 
288  if ($_REQUEST["jid"]) {
289  $job_id = trim($_REQUEST["jid"]);
290  $job = ilCronManager::getJobInstanceById($job_id);
291  if ($job) {
292  $res[$job_id] = $job;
293  }
294  } elseif (is_array($_REQUEST["mjid"])) {
295  foreach ($_REQUEST["mjid"] as $job_id) {
296  $job = ilCronManager::getJobInstanceById($job_id);
297  if ($job) {
298  $res[$job_id] = $job;
299  }
300  }
301  }
302 
303  return $res;
304  }
foreach($_POST as $key=> $value) $res
static getJobInstanceById($a_job_id)
Get job instance (by job id)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initEditForm()

ilCronManagerGUI::initEditForm (   $a_job_id)

Definition at line 62 of file class.ilCronManagerGUI.php.

References $data, $form, $ilCtrl, $lng, $type, ilCronManager\getCronJobData(), ilCronManager\getJobInstanceById(), ilCronJob\SCHEDULE_TYPE_DAILY, ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_IN_HOURS, ilCronJob\SCHEDULE_TYPE_IN_MINUTES, ilCronJob\SCHEDULE_TYPE_MONTHLY, ilCronJob\SCHEDULE_TYPE_QUARTERLY, ilCronJob\SCHEDULE_TYPE_WEEKLY, ilCronJob\SCHEDULE_TYPE_YEARLY, and ilFormPropertyGUI\setRequired().

Referenced by edit(), and update().

63  {
64  global $ilCtrl, $lng;
65 
66  $job = ilCronManager::getJobInstanceById($a_job_id);
67  if (!$job) {
68  $ilCtrl->redirect($this, "render");
69  }
70 
71  $ilCtrl->setParameter($this, "jid", $a_job_id);
72 
73  $data = array_pop(ilCronManager::getCronJobData($job->getId()));
74 
75  include_once("Services/Cron/classes/class.ilCronJob.php");
76  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
77  $form = new ilPropertyFormGUI();
78  $form->setFormAction($ilCtrl->getFormAction($this, "update"));
79  $form->setTitle($lng->txt("cron_action_edit") . ': "' . $job->getTitle() . '"');
80 
81  if ($job->hasFlexibleSchedule()) {
82  $type = new ilRadioGroupInputGUI($lng->txt("cron_schedule_type"), "type");
83  $type->setRequired(true);
84  $type->setValue($data["schedule_type"]);
85  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_daily"), ilCronJob::SCHEDULE_TYPE_DAILY));
86  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_weekly"), ilCronJob::SCHEDULE_TYPE_WEEKLY));
87  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_monthly"), ilCronJob::SCHEDULE_TYPE_MONTHLY));
88  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_quarterly"), ilCronJob::SCHEDULE_TYPE_QUARTERLY));
89  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_yearly"), ilCronJob::SCHEDULE_TYPE_YEARLY));
90 
91  $min = new ilRadioOption(
92  sprintf($lng->txt("cron_schedule_in_minutes"), "x"),
94  );
95  $mini = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "smini");
96  $mini->setRequired(true);
97  $mini->setSize(5);
98  if ($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_MINUTES) {
99  $mini->setValue($data["schedule_value"]);
100  }
101  $min->addSubItem($mini);
102  $type->addOption($min);
103 
104  $hr = new ilRadioOption(
105  sprintf($lng->txt("cron_schedule_in_hours"), "x"),
107  );
108  $hri = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "shri");
109  $hri->setRequired(true);
110  $hri->setSize(5);
111  if ($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_HOURS) {
112  $hri->setValue($data["schedule_value"]);
113  }
114  $hr->addSubItem($hri);
115  $type->addOption($hr);
116 
117  $dy = new ilRadioOption(
118  sprintf($lng->txt("cron_schedule_in_days"), "x"),
120  );
121  $dyi = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "sdyi");
122  $dyi->setRequired(true);
123  $dyi->setSize(5);
124  if ($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_DAYS) {
125  $dyi->setValue($data["schedule_value"]);
126  }
127  $dy->addSubItem($dyi);
128  $type->addOption($dy);
129 
130  $form->addItem($type);
131  }
132 
133  if ($job->hasCustomSettings()) {
134  $job->addCustomSettingsToForm($form);
135  }
136 
137  $form->addCommandButton("update", $lng->txt("save"));
138  $form->addCommandButton("render", $lng->txt("cancel"));
139 
140  return $form;
141  }
This class represents an option in a radio group.
This class represents a property form user interface.
$type
const SCHEDULE_TYPE_IN_MINUTES
const SCHEDULE_TYPE_MONTHLY
const SCHEDULE_TYPE_WEEKLY
global $ilCtrl
Definition: ilias.php:18
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
This class represents a property in a property form.
static getJobInstanceById($a_job_id)
Get job instance (by job id)
if(isset($_POST['submit'])) $form
This class represents a number property in a property form.
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_YEARLY
global $lng
Definition: privfeed.php:17
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
const SCHEDULE_TYPE_IN_HOURS
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilCronManagerGUI::render ( )

Definition at line 30 of file class.ilCronManagerGUI.php.

References $ilSetting, $lng, $tbl, $tpl, ilDatePresentation\formatDate(), IL_CAL_UNIX, and ilUtil\sendInfo().

31  {
32  global $tpl, $ilSetting, $lng;
33 
34  if ($ilSetting->get('last_cronjob_start_ts')) {
35  $tstamp = ilDatePresentation::formatDate(new ilDateTime($ilSetting->get('last_cronjob_start_ts'), IL_CAL_UNIX));
36  } else {
37  $tstamp = $lng->txt('cronjob_last_start_unknown');
38  }
39  ilUtil::sendInfo($lng->txt('cronjob_last_start') . ": " . $tstamp);
40 
41  include_once "Services/Cron/classes/class.ilCronManagerTableGUI.php";
42  $tbl = new ilCronManagerTableGUI($this, "render");
43  $tpl->setContent($tbl->getHTML());
44  }
$tbl
Definition: example_048.php:81
$tpl
Definition: ilias.php:10
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
const IL_CAL_UNIX
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Date and time handling
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
List all active cron jobs.
+ Here is the call graph for this function:

◆ reset()

ilCronManagerGUI::reset ( )

Definition at line 262 of file class.ilCronManagerGUI.php.

263  {
264  $this->confirm("reset");
265  }

◆ run()

ilCronManagerGUI::run ( )

Definition at line 194 of file class.ilCronManagerGUI.php.

195  {
196  $this->confirm("run");
197  }

◆ update()

ilCronManagerGUI::update ( )

Definition at line 143 of file class.ilCronManagerGUI.php.

References $form, $id, $ilCtrl, $lng, $type, $valid, edit(), ilCronManager\getJobInstanceById(), initEditForm(), ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_IN_HOURS, ilCronJob\SCHEDULE_TYPE_IN_MINUTES, ilUtil\sendSuccess(), and ilCronManager\updateJobSchedule().

144  {
145  global $ilCtrl, $lng;
146 
147  $id = $_REQUEST["jid"];
148  if (!$id) {
149  $ilCtrl->redirect($this, "render");
150  }
151 
152  $form = $this->initEditForm($id);
153  if ($form->checkInput()) {
155  if ($job) {
156  $valid = true;
157  if ($job->hasCustomSettings() &&
158  !$job->saveCustomSettings($form)) {
159  $valid = false;
160  }
161 
162  if ($valid && $job->hasFlexibleSchedule()) {
163  $type = $form->getInput("type");
164  switch ($type) {
166  $value = $form->getInput("smini");
167  break;
168 
170  $value = $form->getInput("shri");
171  break;
172 
174  $value = $form->getInput("sdyi");
175  break;
176 
177  default:
178  $value = null;
179  }
180 
182  }
183  if ($valid) {
184  ilUtil::sendSuccess($lng->txt("cron_action_edit_success"), true);
185  $ilCtrl->redirect($this, "render");
186  }
187  }
188  }
189 
190  $form->setValuesByPost();
191  $this->edit($form);
192  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$type
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
const SCHEDULE_TYPE_IN_MINUTES
global $ilCtrl
Definition: ilias.php:18
static getJobInstanceById($a_job_id)
Get job instance (by job id)
if(isset($_POST['submit'])) $form
const SCHEDULE_TYPE_IN_DAYS
global $lng
Definition: privfeed.php:17
edit(ilPropertyFormGUI $a_form=null)
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
const SCHEDULE_TYPE_IN_HOURS
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: