5 include_once
"Services/Cron/classes/class.ilCronManager.php";
22 $lng->loadLanguageModule(
"cron");
24 $cmd = $ilCtrl->getCmd(
"render");
34 if ($ilSetting->get(
'last_cronjob_start_ts')) {
37 $tstamp = $lng->txt(
'cronjob_last_start_unknown');
41 include_once
"Services/Cron/classes/class.ilCronManagerTableGUI.php";
43 $tpl->setContent(
$tbl->getHTML());
50 $id = $_REQUEST[
"jid"];
52 $ilCtrl->redirect($this,
"render");
59 $tpl->setContent($a_form->getHTML());
68 $ilCtrl->redirect($this,
"render");
71 $ilCtrl->setParameter($this,
"jid", $a_job_id);
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() .
'"');
81 if ($job->hasFlexibleSchedule()) {
83 $type->setRequired(
true);
92 sprintf($lng->txt(
"cron_schedule_in_minutes"),
"x"),
99 $mini->setValue(
$data[
"schedule_value"]);
101 $min->addSubItem($mini);
102 $type->addOption($min);
105 sprintf($lng->txt(
"cron_schedule_in_hours"),
"x"),
112 $hri->setValue(
$data[
"schedule_value"]);
114 $hr->addSubItem($hri);
115 $type->addOption($hr);
118 sprintf($lng->txt(
"cron_schedule_in_days"),
"x"),
125 $dyi->setValue(
$data[
"schedule_value"]);
127 $dy->addSubItem($dyi);
128 $type->addOption($dy);
133 if ($job->hasCustomSettings()) {
134 $job->addCustomSettingsToForm(
$form);
137 $form->addCommandButton(
"update", $lng->txt(
"save"));
138 $form->addCommandButton(
"render", $lng->txt(
"cancel"));
147 $id = $_REQUEST[
"jid"];
149 $ilCtrl->redirect($this,
"render");
153 if (
$form->checkInput()) {
157 if ($job->hasCustomSettings() &&
158 !$job->saveCustomSettings(
$form)) {
162 if (
$valid && $job->hasFlexibleSchedule()) {
166 $value =
$form->getInput(
"smini");
170 $value =
$form->getInput(
"shri");
174 $value =
$form->getInput(
"sdyi");
185 $ilCtrl->redirect($this,
"render");
190 $form->setValuesByPost();
196 $this->confirm(
"run");
203 $job_id =
$_GET[
"jid"];
212 $ilCtrl->redirect($this,
"render");
217 $this->confirm(
"activate");
226 foreach ($jobs as $job) {
236 $ilCtrl->redirect($this,
"render");
241 $this->confirm(
"deactivate");
250 foreach ($jobs as $job) {
259 $ilCtrl->redirect($this,
"render");
264 $this->confirm(
"reset");
273 foreach ($jobs as $job) {
281 $ilCtrl->redirect($this,
"render");
288 if ($_REQUEST[
"jid"]) {
289 $job_id = trim($_REQUEST[
"jid"]);
292 $res[$job_id] = $job;
294 } elseif (is_array($_REQUEST[
"mjid"])) {
295 foreach ($_REQUEST[
"mjid"] as $job_id) {
298 $res[$job_id] = $job;
306 protected function confirm($a_action)
312 $ilCtrl->redirect($this,
"render");
315 if (
'run' == $a_action) {
317 $jobs = array_filter($jobs,
function ($job) {
321 return $job->isManuallyExecutable();
324 if (0 == count($jobs)) {
326 $ilCtrl->redirect($this,
'render');
330 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
333 if (
sizeof($jobs) == 1) {
334 $job_id = array_pop(array_keys($jobs));
335 $job = array_pop($jobs);
336 $title = $job->getTitle();
338 $title = preg_replace(
"[^A-Za-z0-9_\-]",
"", $job->getId());
341 $cgui->setHeaderText(sprintf(
342 $lng->txt(
"cron_action_" . $a_action .
"_sure"),
346 $ilCtrl->setParameter($this,
"jid", $job_id);
348 $cgui->setHeaderText($lng->txt(
"cron_action_" . $a_action .
"_sure_multi"));
350 foreach ($jobs as $job_id => $job) {
351 $cgui->addItem(
"mjid[]", $job_id, $job->getTitle());
355 $cgui->setFormAction($ilCtrl->getFormAction($this,
"confirmed" . ucfirst($a_action)));
356 $cgui->setCancel($lng->txt(
"cancel"),
"render");
357 $cgui->setConfirm($lng->txt(
"cron_action_" . $a_action),
"confirmed" . ucfirst($a_action));
359 $tpl->setContent($cgui->getHTML());
367 foreach (
$data as $item) {
375 if (method_exists($job,
"addToExternalSettingsForm")) {
376 $job->addToExternalSettingsForm($a_form_id, $fields, $item[
"job_status"]);
380 if (
sizeof($fields)) {
381 return array(
"cron_jobs"=>
array(
"jumpToCronJobs", $fields));
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getJobInstance($a_id, $a_component, $a_class, $a_path=null)
Get job instance (by job data)
This class represents an option in a radio group.
static deactivateJob(ilCronJob $a_job, $a_manual=false)
Deactivate cron job.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
if(!array_key_exists('StateId', $_REQUEST)) $id
const SCHEDULE_TYPE_IN_MINUTES
static activateJob(ilCronJob $a_job, $a_manual=false)
Activate cron job.
static isJobInactive($a_job_id)
Check if given job is currently inactive.
static runJobManual($a_job_id)
Run single job manually.
const SCHEDULE_TYPE_MONTHLY
const SCHEDULE_TYPE_WEEKLY
static resetJob(ilCronJob $a_job)
Reset job.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
addToExternalSettingsForm($a_form_id)
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
foreach($_POST as $key=> $value) $res
static getJobInstanceById($a_job_id)
Get job instance (by job id)
if(isset($_POST['submit'])) $form
const SCHEDULE_TYPE_IN_DAYS
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const SCHEDULE_TYPE_YEARLY
edit(ilPropertyFormGUI $a_form=null)
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
static isJobActive($a_job_id)
Check if given job is currently active.
const SCHEDULE_TYPE_IN_HOURS
List all active cron jobs.
Confirmation screen class.