ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 $uiFactory
 
 $uiRenderer
 
 $uiService
 
 $repository
 
 $rbac
 
 $error
 
 $dic
 

Detailed Description

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 $this->uiFactory = $DIC->ui()->factory();
50 $this->uiRenderer = $DIC->ui()->renderer();
51 $this->uiRenderer = $DIC->ui()->renderer();
52 $this->uiService = $DIC->uiService();
53 $this->dic = $DIC;
54 $this->rbac = $DIC->rbac();
55 $this->error = $DIC['ilErr'];
57
58 $this->lng->loadLanguageModule('cron');
59 $this->lng->loadLanguageModule('cmps');
60 }
error($a_errmsg)
set error message @access public
Class ilCronJobRepositoryImpl.
global $DIC
Definition: goto.php:24
repository()
Definition: repository.php:5
settings()
Definition: settings.php:2

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

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilCronManagerGUI::activate ( )

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

344 {
345 $this->confirm("activate");
346 }

◆ addToExternalSettingsForm()

ilCronManagerGUI::addToExternalSettingsForm (   $a_form_id)

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

498 {
499 $fields = array();
500
502 foreach ($data as $item) {
504 $item["job_id"],
505 $item["component"],
506 $item["class"],
507 $item["path"]
508 );
509
510 if (method_exists($job, "addToExternalSettingsForm")) {
511 $job->addToExternalSettingsForm($a_form_id, $fields, $item["job_status"]);
512 }
513 }
514
515 if (sizeof($fields)) {
516 return array("cron_jobs" => array("jumpToCronJobs", $fields));
517 }
518 }
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 348 of file class.ilCronManagerGUI.php.

349 {
350 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
351 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
352 }
353
354 $jobs = $this->getMultiActionData();
355 if ($jobs) {
356 foreach ($jobs as $job) {
357 if (ilCronManager::isJobInactive($job->getId())) {
359 ilCronManager::activateJob($job, true);
360 }
361 }
362
363 ilUtil::sendSuccess($this->lng->txt("cron_action_activate_success"), true);
364 }
365
366 $this->ctrl->redirect($this, "render");
367 }
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.
const SYSTEM_FOLDER_ID
Definition: constants.php:33

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

+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

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

375 {
376 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
377 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
378 }
379
380 $jobs = $this->getMultiActionData();
381 if ($jobs) {
382 foreach ($jobs as $job) {
383 if (ilCronManager::isJobActive($job->getId())) {
385 }
386 }
387
388 ilUtil::sendSuccess($this->lng->txt("cron_action_deactivate_success"), true);
389 }
390
391 $this->ctrl->redirect($this, "render");
392 }
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(), ilCronManager\isJobActive(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ confirmedReset()

ilCronManagerGUI::confirmedReset ( )

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

400 {
401 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
402 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
403 }
404
405 $jobs = $this->getMultiActionData();
406 if ($jobs) {
407 foreach ($jobs as $job) {
409 }
410 ilUtil::sendSuccess($this->lng->txt("cron_action_reset_success"), true);
411 }
412
413 $this->ctrl->redirect($this, "render");
414 }

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

+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

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

326 {
327 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
328 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
329 }
330
331 $job_id = $_GET["jid"];
332 if ($job_id) {
333 if (ilCronManager::runJobManual($job_id)) {
334 ilUtil::sendSuccess($this->lng->txt("cron_action_run_success"), true);
335 } else {
336 ilUtil::sendFailure($this->lng->txt("cron_action_run_fail"), true);
337 }
338 }
339
340 $this->ctrl->redirect($this, "render");
341 }
$_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(), ilUtil\sendFailure(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ deactivate()

ilCronManagerGUI::deactivate ( )

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

370 {
371 $this->confirm("deactivate");
372 }

◆ edit()

ilCronManagerGUI::edit ( ilPropertyFormGUI  $a_form = null)

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

122 {
123 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
124 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
125 }
126
127 $id = $_REQUEST["jid"];
128 if (!$id) {
129 $this->ctrl->redirect($this, "render");
130 }
131
132 if (!$a_form) {
133 $a_form = $this->initEditForm($id);
134 }
135
136 $this->tpl->setContent($a_form->getHTML());
137 }

References error(), initEditForm(), and SYSTEM_FOLDER_ID.

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.

62 : void
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 (strtolower($class)) {
71 case strtolower(ilPropertyFormGUI::class):
72 $form = $this->initEditForm(ilUtil::stripSlashes($_REQUEST['jid']));
73 $this->ctrl->forwardCommand($form);
74 break;
75 }
76
77 $cmd = $this->ctrl->getCmd('render');
78 $this->$cmd();
79 }
@noRector

References error(), initEditForm(), ilUtil\stripSlashes(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

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

417 {
418 $res = array();
419
420 if ($_REQUEST["jid"]) {
421 $job_id = trim($_REQUEST["jid"]);
422 $job = ilCronManager::getJobInstanceById($job_id);
423 if ($job) {
424 $res[$job_id] = $job;
425 }
426 } elseif (is_array($_REQUEST["mjid"])) {
427 foreach ($_REQUEST["mjid"] as $job_id) {
428 $job = ilCronManager::getJobInstanceById($job_id);
429 if ($job) {
430 $res[$job_id] = $job;
431 }
432 }
433 }
434
435 return $res;
436 }
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 144 of file class.ilCronManagerGUI.php.

145 {
146 switch ($scheduleTypeId) {
148 return $this->lng->txt('cron_schedule_daily');
149
151 return $this->lng->txt('cron_schedule_weekly');
152
154 return $this->lng->txt('cron_schedule_monthly');
155
157 return $this->lng->txt('cron_schedule_quarterly');
158
160 return $this->lng->txt('cron_schedule_yearly');
161
163 return sprintf($this->lng->txt('cron_schedule_in_minutes'), 'x');
164
166 return sprintf($this->lng->txt('cron_schedule_in_hours'), 'x');
167
169 return sprintf($this->lng->txt('cron_schedule_in_days'), 'x');
170 }
171
172 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
173 }
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 180 of file class.ilCronManagerGUI.php.

181 {
182 switch ($scheduleTypeId) {
184 return 'smini';
185
187 return 'shri';
188
190 return 'sdyi';
191 }
192
193 throw new \InvalidArgumentException(sprintf('The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
194 }

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

200 : bool
201 {
202 return in_array(
203 $scheduleTypeId,
204 [
208 ]
209 );
210 }

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

213 {
214 $job = ilCronManager::getJobInstanceById($a_job_id);
215 if (!$job) {
216 $this->ctrl->redirect($this, "render");
217 }
218
219 $this->ctrl->setParameter($this, "jid", $a_job_id);
220
221 $jobData = ilCronManager::getCronJobData($job->getId());
222 $data = array_pop($jobData);
223
224 include_once("Services/Cron/classes/class.ilCronJob.php");
225 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
226 $form = new ilPropertyFormGUI();
227 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
228 $form->setTitle($this->lng->txt("cron_action_edit") . ': "' . $job->getTitle() . '"');
229
230 if ($job->hasFlexibleSchedule()) {
231 $type = new ilRadioGroupInputGUI($this->lng->txt('cron_schedule_type'), 'type');
232 $type->setRequired(true);
233 $type->setValue($data['schedule_type']);
234
235 foreach ($job->getAllScheduleTypes() as $typeId) {
236 if (!in_array($typeId, $job->getValidScheduleTypes())) {
237 continue;
238 }
239
240 $option = new ilRadioOption(
241 $this->getScheduleTypeFormElementName($typeId),
242 $typeId
243 );
244 $type->addOption($option);
245
246 if (in_array($typeId, $job->getScheduleTypesWithValues())) {
247 $scheduleValue = new ilNumberInputGUI(
248 $this->lng->txt('cron_schedule_value'),
249 $this->getScheduleValueFormElementName($typeId)
250 );
251 $scheduleValue->allowDecimals(false);
252 $scheduleValue->setRequired(true);
253 $scheduleValue->setSize(5);
254 if ($data['schedule_type'] == $typeId) {
255 $scheduleValue->setValue($data['schedule_value']);
256 }
257 $option->addSubItem($scheduleValue);
258 }
259 }
260
261 $form->addItem($type);
262 }
263
264 if ($job->hasCustomSettings()) {
265 $job->addCustomSettingsToForm($form);
266 }
267
268 $form->addCommandButton("update", $this->lng->txt("save"));
269 $form->addCommandButton("render", $this->lng->txt("cancel"));
270
271 return $form;
272 }
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 81 of file class.ilCronManagerGUI.php.

81 : void
82 {
83 $tstamp = $this->lng->txt('cronjob_last_start_unknown');
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 }
87
88 $message = $this->uiFactory->messageBox()->info($this->lng->txt('cronjob_last_start') . ': ' . $tstamp);
89
90 $cronJobs = $this->repository->findAll();
91
92 $tableFilterMediator = new ilCronManagerTableFilterMediator(
93 $cronJobs,
94 $this->uiFactory,
95 $this->uiService,
96 $this->lng
97 );
98 $filter = $tableFilterMediator->filter($this->ctrl->getFormAction(
99 $this,
100 'render',
101 '',
102 true
103 ));
104
105 $tbl = new ilCronManagerTableGUI(
106 $this,
107 'render',
108 $this->dic,
109 $this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)
110 );
111 $this->tpl->setContent(implode('', [
112 $this->uiRenderer->render([$message, $filter]),
113 $tbl->populate(
114 $tableFilterMediator->filteredJobs(
115 $filter
116 )
117 )->getHTML()
118 ]));
119 }
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
$message
Definition: xapiexit.php:14

References $message, ilDatePresentation\formatDate(), IL_CAL_UNIX, repository(), settings(), and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ reset()

ilCronManagerGUI::reset ( )

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

395 {
396 $this->confirm("reset");
397 }

◆ run()

ilCronManagerGUI::run ( )

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

321 {
322 $this->confirm("run");
323 }

◆ update()

ilCronManagerGUI::update ( )

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

275 {
276 if (!$this->rbac->system()->checkAccess('write', SYSTEM_FOLDER_ID)) {
277 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
278 }
279
280 $id = $_REQUEST["jid"];
281 if (!$id) {
282 $this->ctrl->redirect($this, "render");
283 }
284
285 $form = $this->initEditForm($id);
286 if ($form->checkInput()) {
288 if ($job) {
289 $valid = true;
290 if ($job->hasCustomSettings() &&
291 !$job->saveCustomSettings($form)) {
292 $valid = false;
293 }
294
295 if ($valid && $job->hasFlexibleSchedule()) {
296 $type = $form->getInput("type");
297 switch (true) {
298 case $this->hasScheduleValue($type):
299 $value = $form->getInput($this->getScheduleValueFormElementName($type));
300 break;
301
302 default:
303 $value = null;
304 break;
305 }
306
308 }
309 if ($valid) {
310 ilUtil::sendSuccess($this->lng->txt("cron_action_edit_success"), true);
311 $this->ctrl->redirect($this, "render");
312 }
313 }
314 }
315
316 $form->setValuesByPost();
317 $this->edit($form);
318 }
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(), SYSTEM_FOLDER_ID, and ilCronManager\updateJobSchedule().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCronManagerGUI::$ctrl
protected

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

◆ $dic

ilCronManagerGUI::$dic
private

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

◆ $error

ilCronManagerGUI::$error
private

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

◆ $lng

ilCronManagerGUI::$lng
protected

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

◆ $rbac

ilCronManagerGUI::$rbac
private

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

◆ $repository

ilCronManagerGUI::$repository
private

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

◆ $settings

ilCronManagerGUI::$settings
protected

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

◆ $tpl

ilCronManagerGUI::$tpl
protected

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

◆ $uiFactory

ilCronManagerGUI::$uiFactory
private

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

◆ $uiRenderer

ilCronManagerGUI::$uiRenderer
private

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

◆ $uiService

ilCronManagerGUI::$uiService
private

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


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