4 include_once
'./Services/Table/classes/class.ilTable2GUI.php';
5 include_once
'./Services/Cron/classes/class.ilCronJobResult.php';
35 $this->controller = $dic->ctrl();
37 $this->
setId(
"crnmng");
39 parent::__construct($a_parent_obj, $a_parent_cmd);
42 $this->
addColumn($this->lng->txt(
"cron_job_id"),
"title");
43 $this->
addColumn($this->lng->txt(
"cron_component"),
"component");
44 $this->
addColumn($this->lng->txt(
"cron_schedule"),
"schedule");
45 $this->
addColumn($this->lng->txt(
"cron_status"),
"status");
46 $this->
addColumn($this->lng->txt(
"cron_status_info"),
"");
47 $this->
addColumn($this->lng->txt(
"cron_result"),
"result");
48 $this->
addColumn($this->lng->txt(
"cron_result_info"),
"");
49 $this->
addColumn($this->lng->txt(
"cron_last_run"),
"last_run");
50 $this->
addColumn($this->lng->txt(
"actions"),
"");
52 $this->
setTitle($this->lng->txt(
"cron_jobs"));
61 $this->
setFormAction($this->controller->getFormAction($a_parent_obj, $a_parent_cmd));
75 $res[
"title"] = $a_item[
"job_id"];
81 if ($a_item[
"schedule_type"]) {
87 $res[
"editable_schedule"] =
false;
90 if (!$a_item[
"schedule_type"]) {
95 $a_item[
"schedule_type"],
96 $a_item[
"schedule_value"]
100 $res[
"editable_schedule"] =
true;
103 switch ($a_item[
"schedule_type"]) {
105 $schedule = $this->
language->txt(
"cron_schedule_daily");
109 $schedule = $this->
language->txt(
"cron_schedule_weekly");
113 $schedule = $this->
language->txt(
"cron_schedule_monthly");
117 $schedule = $this->
language->txt(
"cron_schedule_quarterly");
121 $schedule = $this->
language->txt(
"cron_schedule_yearly");
125 $schedule = sprintf($this->
language->txt(
"cron_schedule_in_minutes"), $a_item[
"schedule_value"]);
129 $schedule = sprintf($this->
language->txt(
"cron_schedule_in_hours"), $a_item[
"schedule_value"]);
133 $schedule = sprintf($this->
language->txt(
"cron_schedule_in_days"), $a_item[
"schedule_value"]);
136 $res[
"schedule"] = $schedule;
139 if ($a_item[
"job_status"]) {
140 $res[
"status"] = $this->
language->txt(
"cron_status_active");
142 $res[
"status"] = $this->
language->txt(
"cron_status_inactive");
145 $status_info = array();
146 if ($a_item[
"job_status_ts"]) {
149 if (!$a_item[
"job_status_type"]) {
150 $status_info[] = $this->
language->txt(
"cron_changed_by_crontab");
154 $res[
"status_info"] = implode(
"<br />", $status_info);
158 if ($a_item[
"job_result_status"]) {
159 switch ($a_item[
"job_result_status"]) {
161 $result = $this->
language->txt(
"cron_result_status_invalid_configuration");
187 $result_info = array();
188 if ($a_item[
"job_result_dur"]) {
189 $result_info[] = ($a_item[
"job_result_dur"] / 1000) .
" sec";
193 $resultCode = $a_item[
'job_result_code'];
195 $result_info[] = $this->
language->txt(
'cro_job_rc_' . $resultCode);
197 if ($a_item[
'job_result_message']) {
198 $result_info[] = $a_item[
'job_result_message'];
202 if (defined(
'DEVMODE') && DEVMODE) {
203 $result_info[] = $resultCode;
206 if (!$a_item[
"job_result_type"]) {
207 $result_info[] = $this->
language->txt(
"cron_changed_by_crontab");
211 $res[
"result_info"] = implode(
"<br />", $result_info);
213 if ($a_item[
"running_ts"]) {
214 $res[
"last_run"] = strtotime(
"+1year", $a_item[
"running_ts"]);
215 } elseif ($a_item[
"job_result_ts"]) {
216 $res[
"last_run"] = $a_item[
"job_result_ts"];
218 $res[
"last_run"] = null;
228 include_once
"Services/User/classes/class.ilUserUtil.php";
229 include_once
"Services/Cron/classes/class.ilCronJobResult.php";
233 foreach (
$data as $idx => $item) {
246 $this->
language->loadLanguageModule(
"cmps");
251 $item[
"job_id"] =
"pl__" . $item[
"component"] .
"__" . $job->getId();
252 $item[
"component"] = $this->
language->txt(
"cmps_plugin") .
"/" . $item[
"component"];
262 $this->tpl->setVariable(
"VAL_ID", $a_set[
"title"]);
263 $this->tpl->setVariable(
"VAL_JID", $a_set[
"job_id"]);
265 if ($a_set[
"description"]) {
266 $this->tpl->setVariable(
"VAL_DESC", $a_set[
"description"]);
269 $this->tpl->setVariable(
"VAL_COMPONENT", $a_set[
"component"]);
270 $this->tpl->setVariable(
"VAL_SCHEDULE", $a_set[
"schedule"]);
271 $this->tpl->setVariable(
"VAL_STATUS", $a_set[
"status"]);
272 $this->tpl->setVariable(
"VAL_STATUS_INFO", $a_set[
"status_info"]);
273 $this->tpl->setVariable(
"VAL_RESULT", $a_set[
"result"]);
274 $this->tpl->setVariable(
"VAL_RESULT_INFO", $a_set[
"result_info"]);
275 if ($a_set[
"last_run"] > time()) {
276 $a_set[
"last_run"] = $this->
language->txt(
"cron_running_since") .
" " .
280 if ($a_set[
"alive_ts"] != $a_set[
"running_ts"]) {
281 $a_set[
"last_run"] .=
"<br />(Ping: " .
284 } elseif ($a_set[
"last_run"]) {
287 $this->tpl->setVariable(
"VAL_LAST_RUN", $a_set[
"last_run"] ? $a_set[
"last_run"] :
"-");
294 if (!$a_set[
"running_ts"]) {
297 $actions[] =
"reset";
300 elseif (!$a_set[
"job_status"]) {
301 $actions[] =
"activate";
305 if ($a_set[
'is_manually_executable']) {
308 $actions[] =
"deactivate";
311 if ($a_set[
"editable_schedule"] || $a_set[
"has_settings"]) {
315 $this->controller->setParameter($this->
getParentObject(),
"jid", $a_set[
"job_id"]);
317 foreach ($actions as
$action) {
318 $this->tpl->setCurrentBlock(
"action_bl");
319 $this->tpl->setVariable(
321 $this->controller->getLinkTarget($this->getParentObject(),
$action)
323 $this->tpl->setVariable(
"TXT_ACTION", $this->
language->txt(
"cron_action_" . $action));
324 $this->tpl->parseCurrentBlock();
static getJobInstance($a_id, $a_component, $a_class, $a_path=null)
Get job instance (by job data)
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
const STATUS_INVALID_CONFIGURATION
__construct($a_parent_obj, $a_parent_cmd, \ILIAS\DI\Container $dic=null)
Constructor.
Cron job application base class.
const SCHEDULE_TYPE_IN_MINUTES
getDescription()
Get description.
const SCHEDULE_TYPE_MONTHLY
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
const SCHEDULE_TYPE_WEEKLY
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static getCronJobData($a_id=null, $a_include_inactive=true)
Get cron job configuration/execution data.
foreach($_POST as $key=> $value) $res
hasFlexibleSchedule()
Can the schedule be configured?
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
addMultiCommand($a_cmd, $a_text)
Add Command button.
const SCHEDULE_TYPE_IN_DAYS
hasCustomSettings()
Has cron job any custom setting which can be edited?
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
setRowTemplate($a_template, $a_template_dir="")
Set row template.
const SCHEDULE_TYPE_YEARLY
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getDefaultScheduleType()
Get schedule type.
static getPluginJobs($a_only_active=false)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
const SCHEDULE_TYPE_DAILY
getDefaultScheduleValue()
Get schedule value.
const SCHEDULE_TYPE_QUARTERLY
static updateJobSchedule(ilCronJob $a_job, $a_schedule_type, $a_schedule_value)
Update job schedule.
const SCHEDULE_TYPE_IN_HOURS
isManuallyExecutable()
Defines whether or not a cron job can be started manually.
parseJobToData(array $a_item, ilCronJob $job)
List all active cron jobs.