ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
 

Private Attributes

 $rbac
 
 $error
 
 $dic
 

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 47 of file class.ilCronManagerGUI.php.

48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->ctrl = $DIC->ctrl();
53 $this->settings = $DIC->settings();
54 $this->tpl = $DIC->ui()->mainTemplate();
55 $this->dic = $DIC;
56 $this->rbac = $DIC->rbac();
57 $this->error = $DIC['ilErr'];
58
59 $this->lng->loadLanguageModule('cron');
60 }
error($a_errmsg)
set error message @access public
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46

References $DIC, error(), and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilCronManagerGUI::activate ( )

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

323 {
324 $this->confirm("activate");
325 }

◆ addToExternalSettingsForm()

ilCronManagerGUI::addToExternalSettingsForm (   $a_form_id)

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

476 {
477 $fields = array();
478
480 foreach ($data as $item) {
482 $item["job_id"],
483 $item["component"],
484 $item["class"],
485 $item["path"]
486 );
487
488 if (method_exists($job, "addToExternalSettingsForm")) {
489 $job->addToExternalSettingsForm($a_form_id, $fields, $item["job_status"]);
490 }
491 }
492
493 if (sizeof($fields)) {
494 return array("cron_jobs" => array("jumpToCronJobs", $fields));
495 }
496 }
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: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ confirmedActivate()

ilCronManagerGUI::confirmedActivate ( )

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

328 {
329 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
330 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
331 }
332
333 $jobs = $this->getMultiActionData();
334 if ($jobs) {
335 foreach ($jobs as $job) {
336 if (ilCronManager::isJobInactive($job->getId())) {
338 ilCronManager::activateJob($job, true);
339 }
340 }
341
342 ilUtil::sendSuccess($this->lng->txt("cron_action_activate_success"), true);
343 }
344
345 $this->ctrl->redirect($this, "render");
346 }
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(), error(), getMultiActionData(), ilCronManager\isJobInactive(), and ilCronManager\resetJob().

+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

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

354 {
355 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
356 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
357 }
358
359 $jobs = $this->getMultiActionData();
360 if ($jobs) {
361 foreach ($jobs as $job) {
362 if (ilCronManager::isJobActive($job->getId())) {
364 }
365 }
366
367 ilUtil::sendSuccess($this->lng->txt("cron_action_deactivate_success"), true);
368 }
369
370 $this->ctrl->redirect($this, "render");
371 }
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(), error(), getMultiActionData(), and ilCronManager\isJobActive().

+ Here is the call graph for this function:

◆ confirmedReset()

ilCronManagerGUI::confirmedReset ( )

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

379 {
380 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
381 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
382 }
383
384 $jobs = $this->getMultiActionData();
385 if ($jobs) {
386 foreach ($jobs as $job) {
388 }
389 ilUtil::sendSuccess($this->lng->txt("cron_action_reset_success"), true);
390 }
391
392 $this->ctrl->redirect($this, "render");
393 }

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

+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

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

305 {
306 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
307 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
308 }
309
310 $job_id = $_GET["jid"];
311 if ($job_id) {
312 if (ilCronManager::runJobManual($job_id)) {
313 ilUtil::sendSuccess($this->lng->txt("cron_action_run_success"), true);
314 } else {
315 ilUtil::sendFailure($this->lng->txt("cron_action_run_fail"), true);
316 }
317 }
318
319 $this->ctrl->redirect($this, "render");
320 }
$_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, error(), ilCronManager\runJobManual(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ deactivate()

ilCronManagerGUI::deactivate ( )

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

349 {
350 $this->confirm("deactivate");
351 }

◆ edit()

ilCronManagerGUI::edit ( ilPropertyFormGUI  $a_form = null)

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

102 {
103 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
104 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
105 }
106
107 $id = $_REQUEST["jid"];
108 if (!$id) {
109 $this->ctrl->redirect($this, "render");
110 }
111
112 if (!$a_form) {
113 $a_form = $this->initEditForm($id);
114 }
115
116 $this->tpl->setContent($a_form->getHTML());
117 }

References error(), 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 62 of file class.ilCronManagerGUI.php.

63 {
64 if (!$this->rbac->system()->checkAccess('visible,read', SYSTEM_FOLDER_ID)) {
65 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
66 }
67
68 $class = $this->ctrl->getNextClass($this);
69
70 switch ($class) {
71 case "ilpropertyformgui":
72 $form = $this->initEditForm($_REQUEST['jid']);
73 $this->ctrl->forwardCommand($form);
74 break;
75 }
76 $cmd = $this->ctrl->getCmd("render");
77 $this->$cmd();
78
79 return true;
80 }

References error(), and initEditForm().

+ Here is the call graph for this function:

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

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

396 {
397 $res = array();
398
399 if ($_REQUEST["jid"]) {
400 $job_id = trim($_REQUEST["jid"]);
401 $job = ilCronManager::getJobInstanceById($job_id);
402 if ($job) {
403 $res[$job_id] = $job;
404 }
405 } elseif (is_array($_REQUEST["mjid"])) {
406 foreach ($_REQUEST["mjid"] as $job_id) {
407 $job = ilCronManager::getJobInstanceById($job_id);
408 if ($job) {
409 $res[$job_id] = $job;
410 }
411 }
412 }
413
414 return $res;
415 }
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 124 of file class.ilCronManagerGUI.php.

125 {
126 switch ($scheduleTypeId) {
128 return $this->lng->txt('cron_schedule_daily');
129
131 return $this->lng->txt('cron_schedule_weekly');
132
134 return $this->lng->txt('cron_schedule_monthly');
135
137 return $this->lng->txt('cron_schedule_quarterly');
138
140 return $this->lng->txt('cron_schedule_yearly');
141
143 return sprintf($this->lng->txt('cron_schedule_in_minutes'), 'x');
144
146 return sprintf($this->lng->txt('cron_schedule_in_hours'), 'x');
147
149 return sprintf($this->lng->txt('cron_schedule_in_days'), 'x');
150 }
151
152 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
153 }
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 160 of file class.ilCronManagerGUI.php.

161 {
162 switch ($scheduleTypeId) {
164 return 'smini';
165
167 return 'shri';
168
170 return 'sdyi';
171 }
172
173 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
174 }

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 180 of file class.ilCronManagerGUI.php.

180 : bool
181 {
182 return in_array(
183 $scheduleTypeId,
184 [
188 ]
189 );
190 }

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 192 of file class.ilCronManagerGUI.php.

193 {
194 $job = ilCronManager::getJobInstanceById($a_job_id);
195 if (!$job) {
196 $this->ctrl->redirect($this, "render");
197 }
198
199 $this->ctrl->setParameter($this, "jid", $a_job_id);
200
201 $data = array_pop(ilCronManager::getCronJobData($job->getId()));
202
203 include_once("Services/Cron/classes/class.ilCronJob.php");
204 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
205 $form = new ilPropertyFormGUI();
206 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
207 $form->setTitle($this->lng->txt("cron_action_edit") . ': "' . $job->getTitle() . '"');
208
209 if ($job->hasFlexibleSchedule()) {
210 $type = new ilRadioGroupInputGUI($this->lng->txt('cron_schedule_type'), 'type');
211 $type->setRequired(true);
212 $type->setValue($data['schedule_type']);
213
214 foreach ($job->getAllScheduleTypes() as $typeId) {
215 if (!in_array($typeId, $job->getValidScheduleTypes())) {
216 continue;
217 }
218
219 $option = new ilRadioOption(
220 $this->getScheduleTypeFormElementName($typeId),
221 $typeId
222 );
223 $type->addOption($option);
224
225 if (in_array($typeId, $job->getScheduleTypesWithValues())) {
226 $scheduleValue = new ilNumberInputGUI(
227 $this->lng->txt('cron_schedule_value'),
228 $this->getScheduleValueFormElementName($typeId)
229 );
230 $scheduleValue->allowDecimals(false);
231 $scheduleValue->setRequired(true);
232 $scheduleValue->setSize(5);
233 if ($data['schedule_type'] == $typeId) {
234 $scheduleValue->setValue($data['schedule_value']);
235 }
236 $option->addSubItem($scheduleValue);
237 }
238 }
239
240 $form->addItem($type);
241 }
242
243 if ($job->hasCustomSettings()) {
244 $job->addCustomSettingsToForm($form);
245 }
246
247 $form->addCommandButton("update", $this->lng->txt("save"));
248 $form->addCommandButton("render", $this->lng->txt("cancel"));
249
250 return $form;
251 }
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, $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 82 of file class.ilCronManagerGUI.php.

83 {
84 if ($this->settings->get('last_cronjob_start_ts')) {
85 $tstamp = ilDatePresentation::formatDate(new ilDateTime($this->settings->get('last_cronjob_start_ts'), IL_CAL_UNIX));
86 } else {
87 $tstamp = $this->lng->txt('cronjob_last_start_unknown');
88 }
89 ilUtil::sendInfo($this->lng->txt('cronjob_last_start') . ": " . $tstamp);
90
91 include_once "Services/Cron/classes/class.ilCronManagerTableGUI.php";
92 $tbl = new ilCronManagerTableGUI(
93 $this,
94 "render",
95 $this->dic,
96 $this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)
97 );
98 $this->tpl->setContent($tbl->getHTML());
99 }
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.

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

+ Here is the call graph for this function:

◆ reset()

ilCronManagerGUI::reset ( )

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

374 {
375 $this->confirm("reset");
376 }

◆ run()

ilCronManagerGUI::run ( )

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

300 {
301 $this->confirm("run");
302 }

◆ update()

ilCronManagerGUI::update ( )

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

254 {
255 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
256 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
257 }
258
259 $id = $_REQUEST["jid"];
260 if (!$id) {
261 $this->ctrl->redirect($this, "render");
262 }
263
264 $form = $this->initEditForm($id);
265 if ($form->checkInput()) {
267 if ($job) {
268 $valid = true;
269 if ($job->hasCustomSettings() &&
270 !$job->saveCustomSettings($form)) {
271 $valid = false;
272 }
273
274 if ($valid && $job->hasFlexibleSchedule()) {
275 $type = $form->getInput("type");
276 switch (true) {
277 case $this->hasScheduleValue($type):
278 $value = $form->getInput($this->getScheduleValueFormElementName($type));
279 break;
280
281 default:
282 $value = null;
283 break;
284 }
285
287 }
288 if ($valid) {
289 ilUtil::sendSuccess($this->lng->txt("cron_action_edit_success"), true);
290 $this->ctrl->redirect($this, "render");
291 }
292 }
293 }
294
295 $form->setValuesByPost();
296 $this->edit($form);
297 }
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 $type, $valid, edit(), error(), 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.

◆ $dic

ilCronManagerGUI::$dic
private

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

◆ $error

ilCronManagerGUI::$error
private

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

◆ $lng

ilCronManagerGUI::$lng
protected

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

◆ $rbac

ilCronManagerGUI::$rbac
private

Definition at line 38 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: