ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 229 of file class.ilCronManagerGUI.php.

230  {
231  $this->confirm("activate");
232  }

◆ addToExternalSettingsForm()

ilCronManagerGUI::addToExternalSettingsForm (   $a_form_id)

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

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

397  {
398  $fields = array();
399 
401  foreach($data as $item)
402  {
403  $job = ilCronManager::getJobInstance($item["job_id"],
404  $item["component"], $item["class"], $item["path"]);
405 
406  if(method_exists($job, "addToExternalSettingsForm"))
407  {
408  $job->addToExternalSettingsForm($a_form_id, $fields, $item["job_status"]);
409  }
410  }
411 
412  if(sizeof($fields))
413  {
414  return array("cron_jobs"=>array("jumpToCronJobs", $fields));
415  }
416  }
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.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ confirmedActivate()

ilCronManagerGUI::confirmedActivate ( )

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

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

235  {
236  global $ilCtrl, $lng;
237 
238  $jobs = $this->getMultiActionData();
239  if($jobs)
240  {
241  foreach($jobs as $job)
242  {
243  if(ilCronManager::isJobInactive($job->getId()))
244  {
246  ilCronManager::activateJob($job, true);
247  }
248  }
249 
250  ilUtil::sendSuccess($lng->txt("cron_action_activate_success"), true);
251  }
252 
253  $ilCtrl->redirect($this, "render");
254  }
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:40
+ Here is the call graph for this function:

◆ confirmedDeactivate()

ilCronManagerGUI::confirmedDeactivate ( )

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

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

262  {
263  global $ilCtrl, $lng;
264 
265  $jobs = $this->getMultiActionData();
266  if($jobs)
267  {
268  foreach($jobs as $job)
269  {
270  if(ilCronManager::isJobActive($job->getId()))
271  {
272  ilCronManager::deactivateJob($job, true);
273  }
274  }
275 
276  ilUtil::sendSuccess($lng->txt("cron_action_deactivate_success"), true);
277  }
278 
279  $ilCtrl->redirect($this, "render");
280  }
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:40
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 287 of file class.ilCronManagerGUI.php.

References $_GET, $ilCtrl, $lng, ilCronManager\getJobInstanceById(), ilCronManager\resetJob(), and ilUtil\sendSuccess().

288  {
289  global $ilCtrl, $lng;
290 
291  $job_id = $_GET["jid"];
292  if($job_id)
293  {
294  $job = ilCronManager::getJobInstanceById($job_id);
295  if($job)
296  {
298 
299  ilUtil::sendSuccess($lng->txt("cron_action_reset_success"), true);
300  }
301  }
302 
303  $ilCtrl->redirect($this, "render");
304  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static resetJob(ilCronJob $a_job)
Reset job.
global $ilCtrl
Definition: ilias.php:18
static getJobInstanceById($a_job_id)
Get job instance (by job id)
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ confirmedRun()

ilCronManagerGUI::confirmedRun ( )

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

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

210  {
211  global $ilCtrl, $lng;
212 
213  $job_id = $_GET["jid"];
214  if($job_id)
215  {
216  if(ilCronManager::runJobManual($job_id))
217  {
218  ilUtil::sendSuccess($lng->txt("cron_action_run_success"), true);
219  }
220  else
221  {
222  ilUtil::sendFailure($lng->txt("cron_action_run_fail"), true);
223  }
224  }
225 
226  $ilCtrl->redirect($this, "render");
227  }
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:40
+ Here is the call graph for this function:

◆ deactivate()

ilCronManagerGUI::deactivate ( )

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

257  {
258  $this->confirm("deactivate");
259  }

◆ edit()

ilCronManagerGUI::edit ( ilPropertyFormGUI  $a_form = null)

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

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

Referenced by update().

50  {
51  global $ilCtrl, $tpl;
52 
53  $id = $_REQUEST["jid"];
54  if(!$id)
55  {
56  $ilCtrl->redirect($this, "render");
57  }
58 
59  if(!$a_form)
60  {
61  $a_form = $this->initEditForm($id);
62  }
63 
64  $tpl->setContent($a_form->getHTML());
65  }
global $ilCtrl
Definition: ilias.php:18
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ 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 $cmd, $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  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

◆ getMultiActionData()

ilCronManagerGUI::getMultiActionData ( )
protected

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

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

Referenced by confirmedActivate(), and confirmedDeactivate().

307  {
308  $res = array();
309 
310  if($_REQUEST["jid"])
311  {
312  $job_id = trim($_REQUEST["jid"]);
313  $job = ilCronManager::getJobInstanceById($job_id);
314  if($job)
315  {
316  $res[$job_id] = $job;
317  }
318  }
319  else if(is_array($_REQUEST["mjid"]))
320  {
321  foreach($_REQUEST["mjid"] as $job_id)
322  {
323  $job = ilCronManager::getJobInstanceById($job_id);
324  if($job)
325  {
326  $res[$job_id] = $job;
327  }
328  }
329  }
330 
331  return $res;
332  }
static getJobInstanceById($a_job_id)
Get job instance (by job id)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ 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 67 of file class.ilCronManagerGUI.php.

References $data, $ilCtrl, $lng, 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().

68  {
69  global $ilCtrl, $lng;
70 
71  $job = ilCronManager::getJobInstanceById($a_job_id);
72  if(!$job)
73  {
74  $ilCtrl->redirect($this, "render");
75  }
76 
77  $ilCtrl->setParameter($this, "jid", $a_job_id);
78 
79  $data = array_pop(ilCronManager::getCronJobData($job->getId()));
80 
81  include_once("Services/Cron/classes/class.ilCronJob.php");
82  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
83  $form = new ilPropertyFormGUI();
84  $form->setFormAction($ilCtrl->getFormAction($this, "update"));
85  $form->setTitle($lng->txt("cron_action_edit"));
86 
87  if($job->hasFlexibleSchedule())
88  {
89  $type = new ilRadioGroupInputGUI($lng->txt("cron_schedule_type"), "type");
90  $type->setRequired(true);
91  $type->setValue($data["schedule_type"]);
92  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_daily"), ilCronJob::SCHEDULE_TYPE_DAILY));
93  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_weekly"), ilCronJob::SCHEDULE_TYPE_WEEKLY));
94  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_monthly"), ilCronJob::SCHEDULE_TYPE_MONTHLY));
95  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_quarterly"), ilCronJob::SCHEDULE_TYPE_QUARTERLY));
96  $type->addOption(new ilRadioOption($lng->txt("cron_schedule_yearly"), ilCronJob::SCHEDULE_TYPE_YEARLY));
97 
98  $min = new ilRadioOption(sprintf($lng->txt("cron_schedule_in_minutes"), "x"),
100  $mini = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "smini");
101  $mini->setRequired(true);
102  $mini->setSize(5);
103  if($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_MINUTES)
104  {
105  $mini->setValue($data["schedule_value"]);
106  }
107  $min->addSubItem($mini);
108  $type->addOption($min);
109 
110  $hr = new ilRadioOption(sprintf($lng->txt("cron_schedule_in_hours"), "x"),
112  $hri = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "shri");
113  $hri->setRequired(true);
114  $hri->setSize(5);
115  if($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_HOURS)
116  {
117  $hri->setValue($data["schedule_value"]);
118  }
119  $hr->addSubItem($hri);
120  $type->addOption($hr);
121 
122  $dy = new ilRadioOption(sprintf($lng->txt("cron_schedule_in_days"), "x"),
124  $dyi = new ilNumberInputGUI($lng->txt("cron_schedule_value"), "sdyi");
125  $dyi->setRequired(true);
126  $dyi->setSize(5);
127  if($data["schedule_type"] == ilCronJob::SCHEDULE_TYPE_IN_DAYS)
128  {
129  $dyi->setValue($data["schedule_value"]);
130  }
131  $dy->addSubItem($dyi);
132  $type->addOption($dy);
133 
134  $form->addItem($type);
135  }
136 
137  if($job->hasCustomSettings())
138  {
139  $job->addCustomSettingsToForm($form);
140  }
141 
142  $form->addCommandButton("update", $lng->txt("save"));
143  $form->addCommandButton("render", $lng->txt("cancel"));
144 
145  return $form;
146  }
This class represents an option in a radio group.
This class represents a property form user interface.
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)
This class represents a number property in a property form.
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_YEARLY
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $lng
Definition: privfeed.php:40
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, $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  {
36  $tstamp = ilDatePresentation::formatDate(new ilDateTime($ilSetting->get('last_cronjob_start_ts'), IL_CAL_UNIX));
37  }
38  else
39  {
40  $tstamp = $lng->txt('cronjob_last_start_unknown');
41  }
42  ilUtil::sendInfo($lng->txt('cronjob_last_start').": ".$tstamp);
43 
44  include_once "Services/Cron/classes/class.ilCronManagerTableGUI.php";
45  $tbl = new ilCronManagerTableGUI($this, "render");
46  $tpl->setContent($tbl->getHTML());
47  }
const IL_CAL_UNIX
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
List all active cron jobs.
+ Here is the call graph for this function:

◆ reset()

ilCronManagerGUI::reset ( )

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

283  {
284  $this->confirm("reset");
285  }

◆ run()

ilCronManagerGUI::run ( )

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

205  {
206  $this->confirm("run");
207  }

◆ update()

ilCronManagerGUI::update ( )

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

References $_REQUEST, $ilCtrl, $lng, $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().

149  {
150  global $ilCtrl, $lng;
151 
152  $id = $_REQUEST["jid"];
153  if(!$id)
154  {
155  $ilCtrl->redirect($this, "render");
156  }
157 
158  $form = $this->initEditForm($id);
159  if($form->checkInput())
160  {
162  if($job)
163  {
164  $valid = true;
165  if($job->hasCustomSettings() &&
166  !$job->saveCustomSettings($form))
167  {
168  $valid = false;
169  }
170 
171  if($valid && $job->hasFlexibleSchedule())
172  {
173  $type = $form->getInput("type");
174  switch($type)
175  {
177  $value = $form->getInput("smini");
178  break;
179 
181  $value = $form->getInput("shri");
182  break;
183 
185  $value = $form->getInput("sdyi");
186  break;
187 
188  default:
189  $value = null;
190  }
191 
192  ilCronManager::updateJobSchedule($job, $type, $value);
193  }
194 
195  ilUtil::sendSuccess($lng->txt("cron_action_edit_success"), true);
196  $ilCtrl->redirect($this, "render");
197  }
198  }
199 
200  $form->setValuesByPost();
201  $this->edit($form);
202  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$valid
const SCHEDULE_TYPE_IN_MINUTES
global $ilCtrl
Definition: ilias.php:18
static getJobInstanceById($a_job_id)
Get job instance (by job id)
const SCHEDULE_TYPE_IN_DAYS
global $lng
Definition: privfeed.php:40
edit(ilPropertyFormGUI $a_form=null)
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
const SCHEDULE_TYPE_IN_HOURS
+ Here is the call graph for this function:

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