4 include_once
'./Services/Table/classes/class.ilTable2GUI.php';
5 include_once
'./Services/Cron/classes/class.ilCronJobResult.php';
25 $this->
setId(
"crnmng");
27 parent::__construct($a_parent_obj, $a_parent_cmd);
30 $this->
addColumn($this->lng->txt(
"cron_job_id"),
"title");
31 $this->
addColumn($this->lng->txt(
"cron_component"),
"component");
32 $this->
addColumn($this->lng->txt(
"cron_schedule"),
"schedule");
33 $this->
addColumn($this->lng->txt(
"cron_status"),
"status");
34 $this->
addColumn($this->lng->txt(
"cron_status_info"),
"");
35 $this->
addColumn($this->lng->txt(
"cron_result"),
"result");
36 $this->
addColumn($this->lng->txt(
"cron_result_info"),
"");
37 $this->
addColumn($this->lng->txt(
"cron_last_run"),
"last_run");
38 $this->
addColumn($this->lng->txt(
"actions"),
"");
40 $this->
setTitle($this->lng->txt(
"cron_jobs"));
45 $this->
addMultiCommand(
"deactivate", $lng->txt(
"cron_action_deactivate"));
49 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
65 $res[
"title"] = $a_item[
"job_id"];
71 if ($a_item[
"schedule_type"]) {
77 $res[
"editable_schedule"] =
false;
80 if (!$a_item[
"schedule_type"]) {
85 $a_item[
"schedule_type"],
86 $a_item[
"schedule_value"]
90 $res[
"editable_schedule"] =
true;
93 switch ($a_item[
"schedule_type"]) {
95 $schedule = $lng->txt(
"cron_schedule_daily");
99 $schedule = $lng->txt(
"cron_schedule_weekly");
103 $schedule = $lng->txt(
"cron_schedule_monthly");
107 $schedule = $lng->txt(
"cron_schedule_quarterly");
111 $schedule = $lng->txt(
"cron_schedule_yearly");
115 $schedule = sprintf($lng->txt(
"cron_schedule_in_minutes"), $a_item[
"schedule_value"]);
119 $schedule = sprintf($lng->txt(
"cron_schedule_in_hours"), $a_item[
"schedule_value"]);
123 $schedule = sprintf($lng->txt(
"cron_schedule_in_days"), $a_item[
"schedule_value"]);
126 $res[
"schedule"] = $schedule;
129 if ($a_item[
"job_status"]) {
130 $res[
"status"] = $lng->txt(
"cron_status_active");
132 $res[
"status"] = $lng->txt(
"cron_status_inactive");
135 $status_info =
array();
136 if ($a_item[
"job_status_ts"]) {
139 if (!$a_item[
"job_status_type"]) {
140 $status_info[] = $lng->txt(
"cron_changed_by_crontab");
144 $res[
"status_info"] = implode(
"<br />", $status_info);
148 if ($a_item[
"job_result_status"]) {
149 switch ($a_item[
"job_result_status"]) {
151 $result = $lng->txt(
"cron_result_status_invalid_configuration");
155 $result = $lng->txt(
"cron_result_status_no_action");
159 $result = $lng->txt(
"cron_result_status_ok");
163 $result = $lng->txt(
"cron_result_status_crashed");
167 $result = $lng->txt(
"cron_result_status_reset");
171 $result = $lng->txt(
"cron_result_status_fail");
177 $result_info =
array();
178 if ($a_item[
"job_result_dur"]) {
179 $result_info[] = ($a_item[
"job_result_dur"]/1000) .
" sec";
183 $resultCode = $a_item[
'job_result_code'];
185 $result_info[] = $lng->txt(
'cro_job_rc_' . $resultCode);
187 if ($a_item[
'job_result_message']) {
188 $result_info[] = $a_item[
'job_result_message'];
192 if (
defined(
'DEVMODE') && DEVMODE) {
193 $result_info[] = $resultCode;
196 if (!$a_item[
"job_result_type"]) {
197 $result_info[] = $lng->txt(
"cron_changed_by_crontab");
201 $res[
"result_info"] = implode(
"<br />", $result_info);
203 if ($a_item[
"running_ts"]) {
204 $res[
"last_run"] = strtotime(
"+1year", $a_item[
"running_ts"]);
205 } elseif ($a_item[
"job_result_ts"]) {
206 $res[
"last_run"] = $a_item[
"job_result_ts"];
208 $res[
"last_run"] = null;
218 global $ilPluginAdmin,
$lng;
220 include_once
"Services/User/classes/class.ilUserUtil.php";
221 include_once
"Services/Cron/classes/class.ilCronJobResult.php";
225 foreach (
$data as $idx => $item) {
238 $lng->loadLanguageModule(
"cmps");
243 $item[
"job_id"] =
"pl__" . $item[
"component"] .
"__" . $job->getId();
244 $item[
"component"] = $lng->txt(
"cmps_plugin") .
"/" . $item[
"component"];
256 $this->tpl->setVariable(
"VAL_ID", $a_set[
"title"]);
257 $this->tpl->setVariable(
"VAL_JID", $a_set[
"job_id"]);
259 if ($a_set[
"description"]) {
260 $this->tpl->setVariable(
"VAL_DESC", $a_set[
"description"]);
263 $this->tpl->setVariable(
"VAL_COMPONENT", $a_set[
"component"]);
264 $this->tpl->setVariable(
"VAL_SCHEDULE", $a_set[
"schedule"]);
265 $this->tpl->setVariable(
"VAL_STATUS", $a_set[
"status"]);
266 $this->tpl->setVariable(
"VAL_STATUS_INFO", $a_set[
"status_info"]);
267 $this->tpl->setVariable(
"VAL_RESULT", $a_set[
"result"]);
268 $this->tpl->setVariable(
"VAL_RESULT_INFO", $a_set[
"result_info"]);
269 if ($a_set[
"last_run"] >
time()) {
270 $a_set[
"last_run"] = $lng->txt(
"cron_running_since") .
" " .
274 if ($a_set[
"alive_ts"] != $a_set[
"running_ts"]) {
275 $a_set[
"last_run"] .=
"<br />(Ping: " .
278 } elseif ($a_set[
"last_run"]) {
281 $this->tpl->setVariable(
"VAL_LAST_RUN", $a_set[
"last_run"] ? $a_set[
"last_run"] :
"-");
288 if (!$a_set[
"running_ts"]) {
291 $actions[] =
"reset";
294 elseif (!$a_set[
"job_status"]) {
295 $actions[] =
"activate";
299 if ($a_set[
'is_manually_executable']) {
302 $actions[] =
"deactivate";
305 if ($a_set[
"editable_schedule"] || $a_set[
"has_settings"]) {
309 $ilCtrl->setParameter($this->
getParentObject(),
"jid", $a_set[
"job_id"]);
311 foreach ($actions as
$action) {
312 $this->tpl->setCurrentBlock(
"action_bl");
313 $this->tpl->setVariable(
315 $ilCtrl->getLinkTarget($this->getParentObject(),
$action)
317 $this->tpl->setVariable(
"TXT_ACTION", $lng->txt(
"cron_action_" . $action));
318 $this->tpl->parseCurrentBlock();
static getJobInstance($a_id, $a_component, $a_class, $a_path=null)
Get job instance (by job data)
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
const STATUS_INVALID_CONFIGURATION
Cron job application base class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
const SCHEDULE_TYPE_IN_MINUTES
getDescription()
Get description.
const SCHEDULE_TYPE_MONTHLY
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?
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.
Create styles array
The data for the language used.
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.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
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.