ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCronManagerGUI Class Reference

Class ilCronManagerGUI. More...

+ Collaboration diagram for ilCronManagerGUI:

Public Member Functions

 __construct ()
 ilCronManagerGUI constructor. More...
 
 executeCommand ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 update ()
 
 run ()
 
 confirmedRun ()
 
 activate ()
 
 confirmedActivate ()
 
 deactivate ()
 
 confirmedDeactivate ()
 
 reset ()
 
 confirmedReset ()
 
 addToExternalSettingsForm ($a_form_id)
 

Protected Member Functions

 render ()
 
 getScheduleTypeFormElementName (int $scheduleTypeId)
 
 getScheduleValueFormElementName (int $scheduleTypeId)
 
 hasScheduleValue (int $scheduleTypeId)
 
 initEditForm ($a_job_id)
 
 getMultiActionData ()
 

Protected Attributes

 $lng
 
 $ctrl
 
 $settings
 
 $tpl
 

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

@ilCtrl_Calls ilCronManagerGUI: ilPropertyFormGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilCronManagerGUI::__construct ( )

ilCronManagerGUI constructor.

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

42 {
43 global $DIC;
44
45 $this->lng = $DIC->language();
46 $this->ctrl = $DIC->ctrl();
47 $this->settings = $DIC->settings();
48 $this->tpl = $DIC->ui()->mainTemplate();
49
50 $this->lng->loadLanguageModule('cron');
51 }
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2

References $DIC, and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilCronManagerGUI::activate ( )

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

293 {
294 $this->confirm("activate");
295 }

◆ addToExternalSettingsForm()

ilCronManagerGUI::addToExternalSettingsForm (   $a_form_id)

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

430 {
431 $fields = array();
432
434 foreach ($data as $item) {
436 $item["job_id"],
437 $item["component"],
438 $item["class"],
439 $item["path"]
440 );
441
442 if (method_exists($job, "addToExternalSettingsForm")) {
443 $job->addToExternalSettingsForm($a_form_id, $fields, $item["job_status"]);
444 }
445 }
446
447 if (sizeof($fields)) {
448 return array("cron_jobs" => array("jumpToCronJobs", $fields));
449 }
450 }
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
static getJobInstance($a_id, $a_component, $a_class, $a_path=null)
Get job instance (by job data)
$data
Definition: bench.php:6

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

+ Here is the call graph for this function:

◆ confirmedActivate()

ilCronManagerGUI::confirmedActivate ( )

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

298 {
299 $jobs = $this->getMultiActionData();
300 if ($jobs) {
301 foreach ($jobs as $job) {
302 if (ilCronManager::isJobInactive($job->getId())) {
304 ilCronManager::activateJob($job, true);
305 }
306 }
307
308 ilUtil::sendSuccess($this->lng->txt("cron_action_activate_success"), true);
309 }
310
311 $this->ctrl->redirect($this, "render");
312 }
static isJobInactive($a_job_id)
Check if given job is currently inactive.
static activateJob(ilCronJob $a_job, $a_manual=false)
Activate cron job.
static resetJob(ilCronJob $a_job)
Reset job.

References ilCronManager\activateJob(), getMultiActionData(), ilCronManager\isJobInactive(), and ilCronManager\resetJob().

+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

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

320 {
321 $jobs = $this->getMultiActionData();
322 if ($jobs) {
323 foreach ($jobs as $job) {
324 if (ilCronManager::isJobActive($job->getId())) {
326 }
327 }
328
329 ilUtil::sendSuccess($this->lng->txt("cron_action_deactivate_success"), true);
330 }
331
332 $this->ctrl->redirect($this, "render");
333 }
static isJobActive($a_job_id)
Check if given job is currently active.
static deactivateJob(ilCronJob $a_job, $a_manual=false)
Deactivate cron job.

References ilCronManager\deactivateJob(), getMultiActionData(), and ilCronManager\isJobActive().

+ Here is the call graph for this function:

◆ confirmedReset()

ilCronManagerGUI::confirmedReset ( )

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

341 {
342 $jobs = $this->getMultiActionData();
343 if ($jobs) {
344 foreach ($jobs as $job) {
346 }
347 ilUtil::sendSuccess($this->lng->txt("cron_action_reset_success"), true);
348 }
349
350 $this->ctrl->redirect($this, "render");
351 }

References getMultiActionData(), and ilCronManager\resetJob().

+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

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

279 {
280 $job_id = $_GET["jid"];
281 if ($job_id) {
282 if (ilCronManager::runJobManual($job_id)) {
283 ilUtil::sendSuccess($this->lng->txt("cron_action_run_success"), true);
284 } else {
285 ilUtil::sendFailure($this->lng->txt("cron_action_run_fail"), true);
286 }
287 }
288
289 $this->ctrl->redirect($this, "render");
290 }
$_GET["client_id"]
static runJobManual($a_job_id)
Run single job manually.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

◆ deactivate()

ilCronManagerGUI::deactivate ( )

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

315 {
316 $this->confirm("deactivate");
317 }

◆ edit()

ilCronManagerGUI::edit ( ilPropertyFormGUI  $a_form = null)

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

84 {
85 $id = $_REQUEST["jid"];
86 if (!$id) {
87 $this->ctrl->redirect($this, "render");
88 }
89
90 if (!$a_form) {
91 $a_form = $this->initEditForm($id);
92 }
93
94 $this->tpl->setContent($a_form->getHTML());
95 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, and initEditForm().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCronManagerGUI::executeCommand ( )

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

54 {
55 $class = $this->ctrl->getNextClass($this);
56
57 switch ($class) {
58 case "ilpropertyformgui":
59 $form = $this->initEditForm($_REQUEST['jid']);
60 $this->ctrl->forwardCommand($form);
61 break;
62 }
63 $cmd = $this->ctrl->getCmd("render");
64 $this->$cmd();
65
66 return true;
67 }
if(isset($_POST['submit'])) $form

References $form, and initEditForm().

+ Here is the call graph for this function:

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

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

354 {
355 $res = array();
356
357 if ($_REQUEST["jid"]) {
358 $job_id = trim($_REQUEST["jid"]);
359 $job = ilCronManager::getJobInstanceById($job_id);
360 if ($job) {
361 $res[$job_id] = $job;
362 }
363 } elseif (is_array($_REQUEST["mjid"])) {
364 foreach ($_REQUEST["mjid"] as $job_id) {
365 $job = ilCronManager::getJobInstanceById($job_id);
366 if ($job) {
367 $res[$job_id] = $job;
368 }
369 }
370 }
371
372 return $res;
373 }
static getJobInstanceById($a_job_id)
Get job instance (by job id)
foreach($_POST as $key=> $value) $res

References $res, and ilCronManager\getJobInstanceById().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScheduleTypeFormElementName()

ilCronManagerGUI::getScheduleTypeFormElementName ( int  $scheduleTypeId)
protected
Parameters
int$scheduleTypeId
Returns
string
Exceptions

InvalidArgumentException

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

103 {
104 switch ($scheduleTypeId) {
106 return $this->lng->txt('cron_schedule_daily');
107
109 return $this->lng->txt('cron_schedule_weekly');
110
112 return $this->lng->txt('cron_schedule_monthly');
113
115 return $this->lng->txt('cron_schedule_quarterly');
116
118 return $this->lng->txt('cron_schedule_yearly');
119
121 return sprintf($this->lng->txt('cron_schedule_in_minutes'), 'x');
122
124 return sprintf($this->lng->txt('cron_schedule_in_hours'), 'x');
125
127 return sprintf($this->lng->txt('cron_schedule_in_days'), 'x');
128 }
129
130 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
131 }
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_IN_HOURS
const SCHEDULE_TYPE_IN_MINUTES
const SCHEDULE_TYPE_WEEKLY
const SCHEDULE_TYPE_YEARLY
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
const SCHEDULE_TYPE_MONTHLY

References 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, and ilCronJob\SCHEDULE_TYPE_YEARLY.

Referenced by initEditForm().

+ Here is the caller graph for this function:

◆ getScheduleValueFormElementName()

ilCronManagerGUI::getScheduleValueFormElementName ( int  $scheduleTypeId)
protected
Parameters
int$scheduleTypeId
Returns
string
Exceptions

InvalidArgumentException

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

139 {
140 switch ($scheduleTypeId) {
142 return 'smini';
143
145 return 'shri';
146
148 return 'sdyi';
149 }
150
151 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
152 }

References ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_IN_HOURS, and ilCronJob\SCHEDULE_TYPE_IN_MINUTES.

Referenced by update().

+ Here is the caller graph for this function:

◆ hasScheduleValue()

ilCronManagerGUI::hasScheduleValue ( int  $scheduleTypeId)
protected
Parameters
int$scheduleTypeId
Returns
bool

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

158 : bool
159 {
160 return in_array(
161 $scheduleTypeId,
162 [
166 ]
167 );
168 }

References ilCronJob\SCHEDULE_TYPE_IN_DAYS, ilCronJob\SCHEDULE_TYPE_IN_HOURS, and ilCronJob\SCHEDULE_TYPE_IN_MINUTES.

Referenced by update().

+ Here is the caller graph for this function:

◆ initEditForm()

ilCronManagerGUI::initEditForm (   $a_job_id)
protected

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

171 {
172 $job = ilCronManager::getJobInstanceById($a_job_id);
173 if (!$job) {
174 $this->ctrl->redirect($this, "render");
175 }
176
177 $this->ctrl->setParameter($this, "jid", $a_job_id);
178
179 $data = array_pop(ilCronManager::getCronJobData($job->getId()));
180
181 include_once("Services/Cron/classes/class.ilCronJob.php");
182 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
183 $form = new ilPropertyFormGUI();
184 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
185 $form->setTitle($this->lng->txt("cron_action_edit") . ': "' . $job->getTitle() . '"');
186
187 if ($job->hasFlexibleSchedule()) {
188 $type = new ilRadioGroupInputGUI($this->lng->txt('cron_schedule_type'), 'type');
189 $type->setRequired(true);
190 $type->setValue($data['schedule_type']);
191
192 foreach ($job->getAllScheduleTypes() as $typeId) {
193 if (!in_array($typeId, $job->getValidScheduleTypes())) {
194 continue;
195 }
196
197 $option = new ilRadioOption(
198 $this->getScheduleTypeFormElementName($typeId),
199 $typeId
200 );
201 $type->addOption($option);
202
203 if (in_array($typeId, $job->getScheduleTypesWithValues())) {
204 $scheduleValue = new ilNumberInputGUI(
205 $this->lng->txt('cron_schedule_value'),
206 $this->getScheduleValueFormElementName($typeId)
207 );
208 $scheduleValue->allowDecimals(false);
209 $scheduleValue->setRequired(true);
210 $scheduleValue->setSize(5);
211 if ($data['schedule_type'] == $typeId) {
212 $scheduleValue->setValue($data['schedule_value']);
213 }
214 $option->addSubItem($scheduleValue);
215 }
216 }
217
218 $form->addItem($type);
219 }
220
221 if ($job->hasCustomSettings()) {
222 $job->addCustomSettingsToForm($form);
223 }
224
225 $form->addCommandButton("update", $this->lng->txt("save"));
226 $form->addCommandButton("render", $this->lng->txt("cancel"));
227
228 return $form;
229 }
getScheduleTypeFormElementName(int $scheduleTypeId)
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
$type

References $data, $form, $type, ilCronManager\getCronJobData(), ilCronManager\getJobInstanceById(), and getScheduleTypeFormElementName().

Referenced by edit(), executeCommand(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilCronManagerGUI::render ( )
protected

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

70 {
71 if ($this->settings->get('last_cronjob_start_ts')) {
72 $tstamp = ilDatePresentation::formatDate(new ilDateTime($this->settings->get('last_cronjob_start_ts'), IL_CAL_UNIX));
73 } else {
74 $tstamp = $this->lng->txt('cronjob_last_start_unknown');
75 }
76 ilUtil::sendInfo($this->lng->txt('cronjob_last_start') . ": " . $tstamp);
77
78 include_once "Services/Cron/classes/class.ilCronManagerTableGUI.php";
79 $tbl = new ilCronManagerTableGUI($this, "render");
80 $this->tpl->setContent($tbl->getHTML());
81 }
const IL_CAL_UNIX
List all active cron jobs.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$tbl
Definition: example_048.php:81

References $tbl, ilDatePresentation\formatDate(), IL_CAL_UNIX, ilUtil\sendInfo(), and settings().

+ Here is the call graph for this function:

◆ reset()

ilCronManagerGUI::reset ( )

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

336 {
337 $this->confirm("reset");
338 }

◆ run()

ilCronManagerGUI::run ( )

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

274 {
275 $this->confirm("run");
276 }

◆ update()

ilCronManagerGUI::update ( )

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

232 {
233 $id = $_REQUEST["jid"];
234 if (!$id) {
235 $this->ctrl->redirect($this, "render");
236 }
237
238 $form = $this->initEditForm($id);
239 if ($form->checkInput()) {
241 if ($job) {
242 $valid = true;
243 if ($job->hasCustomSettings() &&
244 !$job->saveCustomSettings($form)) {
245 $valid = false;
246 }
247
248 if ($valid && $job->hasFlexibleSchedule()) {
249 $type = $form->getInput("type");
250 switch (true) {
251 case $this->hasScheduleValue($type):
252 $value = $form->getInput($this->getScheduleValueFormElementName($type));
253 break;
254
255 default:
256 $value = null;
257 break;
258 }
259
261 }
262 if ($valid) {
263 ilUtil::sendSuccess($this->lng->txt("cron_action_edit_success"), true);
264 $this->ctrl->redirect($this, "render");
265 }
266 }
267 }
268
269 $form->setValuesByPost();
270 $this->edit($form);
271 }
edit(ilPropertyFormGUI $a_form=null)
getScheduleValueFormElementName(int $scheduleTypeId)
hasScheduleValue(int $scheduleTypeId)
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
$valid

References $form, $id, $type, $valid, edit(), ilCronManager\getJobInstanceById(), getScheduleValueFormElementName(), hasScheduleValue(), initEditForm(), and ilCronManager\updateJobSchedule().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCronManagerGUI::$ctrl
protected

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

◆ $lng

ilCronManagerGUI::$lng
protected

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

◆ $settings

ilCronManagerGUI::$settings
protected

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

◆ $tpl

ilCronManagerGUI::$tpl
protected

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


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