5 include_once
"Services/Cron/classes/class.ilCronManager.php";
45 $this->lng = $DIC->language();
46 $this->ctrl = $DIC->ctrl();
48 $this->tpl = $DIC->ui()->mainTemplate();
50 $this->lng->loadLanguageModule(
'cron');
55 $class = $this->ctrl->getNextClass($this);
58 case "ilpropertyformgui":
60 $this->ctrl->forwardCommand(
$form);
63 $cmd = $this->ctrl->getCmd(
"render");
71 if ($this->
settings->get(
'last_cronjob_start_ts')) {
74 $tstamp = $this->lng->txt(
'cronjob_last_start_unknown');
78 include_once
"Services/Cron/classes/class.ilCronManagerTableGUI.php";
80 $this->tpl->setContent(
$tbl->getHTML());
85 $id = $_REQUEST[
"jid"];
87 $this->ctrl->redirect($this,
"render");
94 $this->tpl->setContent($a_form->getHTML());
104 switch ($scheduleTypeId) {
106 return $this->lng->txt(
'cron_schedule_daily');
109 return $this->lng->txt(
'cron_schedule_weekly');
112 return $this->lng->txt(
'cron_schedule_monthly');
115 return $this->lng->txt(
'cron_schedule_quarterly');
118 return $this->lng->txt(
'cron_schedule_yearly');
121 return sprintf($this->lng->txt(
'cron_schedule_in_minutes'),
'x');
124 return sprintf($this->lng->txt(
'cron_schedule_in_hours'),
'x');
127 return sprintf($this->lng->txt(
'cron_schedule_in_days'),
'x');
130 throw new \InvalidArgumentException(sprintf(
'The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
140 switch ($scheduleTypeId) {
151 throw new \InvalidArgumentException(sprintf(
'The passed argument %s is invalid!', var_export($scheduleTypeId, 1)));
174 $this->ctrl->redirect($this,
"render");
177 $this->ctrl->setParameter($this,
"jid", $a_job_id);
181 include_once(
"Services/Cron/classes/class.ilCronJob.php");
182 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
184 $form->setFormAction($this->ctrl->getFormAction($this,
"update"));
185 $form->setTitle($this->lng->txt(
"cron_action_edit") .
': "' . $job->getTitle() .
'"');
187 if ($job->hasFlexibleSchedule()) {
189 $type->setRequired(
true);
192 foreach ($job->getAllScheduleTypes() as $typeId) {
193 if (!in_array($typeId, $job->getValidScheduleTypes())) {
201 $type->addOption($option);
203 if (in_array($typeId, $job->getScheduleTypesWithValues())) {
205 $this->lng->txt(
'cron_schedule_value'),
209 $scheduleValue->setRequired(
true);
210 $scheduleValue->setSize(5);
211 if (
$data[
'schedule_type'] == $typeId) {
212 $scheduleValue->setValue(
$data[
'schedule_value']);
214 $option->addSubItem($scheduleValue);
221 if ($job->hasCustomSettings()) {
222 $job->addCustomSettingsToForm(
$form);
225 $form->addCommandButton(
"update", $this->lng->txt(
"save"));
226 $form->addCommandButton(
"render", $this->lng->txt(
"cancel"));
233 $id = $_REQUEST[
"jid"];
235 $this->ctrl->redirect($this,
"render");
239 if (
$form->checkInput()) {
243 if ($job->hasCustomSettings() &&
244 !$job->saveCustomSettings(
$form)) {
248 if (
$valid && $job->hasFlexibleSchedule()) {
263 ilUtil::sendSuccess($this->lng->txt(
"cron_action_edit_success"),
true);
264 $this->ctrl->redirect($this,
"render");
269 $form->setValuesByPost();
275 $this->confirm(
"run");
280 $job_id =
$_GET[
"jid"];
283 ilUtil::sendSuccess($this->lng->txt(
"cron_action_run_success"),
true);
289 $this->ctrl->redirect($this,
"render");
294 $this->confirm(
"activate");
301 foreach ($jobs as $job) {
308 ilUtil::sendSuccess($this->lng->txt(
"cron_action_activate_success"),
true);
311 $this->ctrl->redirect($this,
"render");
316 $this->confirm(
"deactivate");
323 foreach ($jobs as $job) {
329 ilUtil::sendSuccess($this->lng->txt(
"cron_action_deactivate_success"),
true);
332 $this->ctrl->redirect($this,
"render");
337 $this->confirm(
"reset");
344 foreach ($jobs as $job) {
347 ilUtil::sendSuccess($this->lng->txt(
"cron_action_reset_success"),
true);
350 $this->ctrl->redirect($this,
"render");
357 if ($_REQUEST[
"jid"]) {
358 $job_id = trim($_REQUEST[
"jid"]);
361 $res[$job_id] = $job;
363 } elseif (is_array($_REQUEST[
"mjid"])) {
364 foreach ($_REQUEST[
"mjid"] as $job_id) {
367 $res[$job_id] = $job;
375 protected function confirm($a_action)
379 $this->ctrl->redirect($this,
"render");
382 if (
'run' == $a_action) {
384 $jobs = array_filter($jobs,
function ($job) {
388 return $job->isManuallyExecutable();
391 if (0 == count($jobs)) {
393 $this->ctrl->redirect($this,
'render');
397 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
400 if (
sizeof($jobs) == 1) {
401 $job_id = array_pop(array_keys($jobs));
402 $job = array_pop($jobs);
403 $title = $job->getTitle();
405 $title = preg_replace(
"[^A-Za-z0-9_\-]",
"", $job->getId());
408 $cgui->setHeaderText(sprintf(
409 $this->lng->txt(
"cron_action_" . $a_action .
"_sure"),
413 $this->ctrl->setParameter($this,
"jid", $job_id);
415 $cgui->setHeaderText($this->lng->txt(
"cron_action_" . $a_action .
"_sure_multi"));
417 foreach ($jobs as $job_id => $job) {
418 $cgui->addItem(
"mjid[]", $job_id, $job->getTitle());
422 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmed" . ucfirst($a_action)));
423 $cgui->setCancel($this->lng->txt(
"cancel"),
"render");
424 $cgui->setConfirm($this->lng->txt(
"cron_action_" . $a_action),
"confirmed" . ucfirst($a_action));
426 $this->tpl->setContent($cgui->getHTML());
434 foreach (
$data as $item) {
442 if (method_exists($job,
"addToExternalSettingsForm")) {
443 $job->addToExternalSettingsForm($a_form_id, $fields, $item[
"job_status"]);
447 if (
sizeof($fields)) {
448 return array(
"cron_jobs" => array(
"jumpToCronJobs", $fields));
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.
getScheduleValueFormElementName(int $scheduleTypeId)
static deactivateJob(ilCronJob $a_job, $a_manual=false)
Deactivate cron job.
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
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
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
hasScheduleValue(int $scheduleTypeId)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct()
ilCronManagerGUI constructor.
const SCHEDULE_TYPE_YEARLY
edit(ilPropertyFormGUI $a_form=null)
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
getScheduleTypeFormElementName(int $scheduleTypeId)
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.