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

@ilCtrl_Calls 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.

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 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)

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

+ Here is the call graph for this function:

◆ confirmedActivate()

ilCronManagerGUI::confirmedActivate ( )

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

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 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.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17

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

+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

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

245 {
246 global $ilCtrl, $lng;
247
248 $jobs = $this->getMultiActionData();
249 if ($jobs) {
250 foreach ($jobs as $job) {
251 if (ilCronManager::isJobActive($job->getId())) {
253 }
254 }
255
256 ilUtil::sendSuccess($lng->txt("cron_action_deactivate_success"), true);
257 }
258
259 $ilCtrl->redirect($this, "render");
260 }
static isJobActive($a_job_id)
Check if given job is currently active.
static deactivateJob(ilCronJob $a_job, $a_manual=false)
Deactivate cron job.

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

+ Here is the call graph for this function:

◆ confirmedReset()

ilCronManagerGUI::confirmedReset ( )

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

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 }

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

+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

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

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 }
$_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, $ilCtrl, $lng, ilCronManager\runJobManual(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ 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.

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

References $id, $ilCtrl, $tpl, 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 18 of file class.ilCronManagerGUI.php.

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

References $ilCtrl, and $lng.

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

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

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 }
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:

◆ initEditForm()

ilCronManagerGUI::initEditForm (   $a_job_id)

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

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");
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 }
sprintf('%.4f', $callTime)
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
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
if(isset($_POST['submit'])) $form

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 sprintf.

Referenced by edit(), and update().

+ 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.

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 }
const IL_CAL_UNIX
List all active cron jobs.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=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
global $ilSetting
Definition: privfeed.php:17

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

+ 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.

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 }
edit(ilPropertyFormGUI $a_form=null)
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
$valid

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().

+ Here is the call graph for this function:

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