4 include_once
'./Services/Table/classes/class.ilTable2GUI.php';
26 $this->
setId(
"crnmng");
29 $this->
addColumn($this->lng->txt(
"cron_job_id"),
"title");
30 $this->
addColumn($this->lng->txt(
"cron_component"),
"component");
31 $this->
addColumn($this->lng->txt(
"cron_schedule"),
"schedule");
32 $this->
addColumn($this->lng->txt(
"cron_status"),
"status");
33 $this->
addColumn($this->lng->txt(
"cron_status_info"),
"");
34 $this->
addColumn($this->lng->txt(
"cron_result"),
"result");
35 $this->
addColumn($this->lng->txt(
"cron_result_info"),
"");
36 $this->
addColumn($this->lng->txt(
"cron_last_run"),
"last_run");
37 $this->
addColumn($this->lng->txt(
"actions"),
"");
39 $this->
setTitle($this->lng->txt(
"cron_jobs"));
44 $this->
addMultiCommand(
"deactivate", $lng->txt(
"cron_action_deactivate"));
47 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
64 $res[
"title"] = $a_item[
"job_id"];
71 if($a_item[
"schedule_type"])
78 $res[
"editable_schedule"] =
false;
83 if(!$a_item[
"schedule_type"])
88 $a_item[
"schedule_value"]);
91 $res[
"editable_schedule"] =
true;
94 switch($a_item[
"schedule_type"])
97 $schedule = $lng->txt(
"cron_schedule_daily");
101 $schedule = $lng->txt(
"cron_schedule_weekly");
105 $schedule = $lng->txt(
"cron_schedule_monthly");
109 $schedule = $lng->txt(
"cron_schedule_quarterly");
113 $schedule = $lng->txt(
"cron_schedule_yearly");
117 $schedule = sprintf($lng->txt(
"cron_schedule_in_minutes"), $a_item[
"schedule_value"]);
121 $schedule = sprintf($lng->txt(
"cron_schedule_in_hours"), $a_item[
"schedule_value"]);
125 $schedule = sprintf($lng->txt(
"cron_schedule_in_days"), $a_item[
"schedule_value"]);
128 $res[
"schedule"] = $schedule;
131 if($a_item[
"job_status"])
133 $res[
"status"] = $lng->txt(
"cron_status_active");
137 $res[
"status"] = $lng->txt(
"cron_status_inactive");
140 $status_info = array();
141 if($a_item[
"job_status_ts"])
145 if(!$a_item[
"job_status_type"])
147 $status_info[] = $lng->txt(
"cron_changed_by_crontab");
153 $res[
"status_info"] = implode(
"<br />", $status_info);
157 if($a_item[
"job_result_status"])
159 switch($a_item[
"job_result_status"])
162 $result = $lng->txt(
"cron_result_status_invalid_configuration");
166 $result = $lng->txt(
"cron_result_status_no_action");
170 $result = $lng->txt(
"cron_result_status_ok");
174 $result = $lng->txt(
"cron_result_status_crashed");
178 $result = $lng->txt(
"cron_result_status_reset");
182 $result = $lng->txt(
"cron_result_status_fail");
188 $result_info = array();
189 if($a_item[
"job_result_dur"])
191 $result_info[] = ($a_item[
"job_result_dur"]/1000).
" sec";
193 if($a_item[
"job_result_message"])
195 $result_info[] = $a_item[
"job_result_message"];
197 if(DEVMODE && $a_item[
"job_result_code"])
199 $result_info[] = $a_item[
"job_result_code"];
201 if(!$a_item[
"job_result_type"])
203 $result_info[] = $lng->txt(
"cron_changed_by_crontab");
209 $res[
"result_info"] = implode(
"<br />", $result_info);
211 if($a_item[
"running_ts"])
213 $res[
"last_run"] = strtotime(
"+1year", $a_item[
"running_ts"]);
215 else if($a_item[
"job_result_ts"])
217 $res[
"last_run"] = $a_item[
"job_result_ts"];
221 $res[
"last_run"] = null;
231 global $ilPluginAdmin,
$lng;
233 include_once
"Services/User/classes/class.ilUserUtil.php";
234 include_once
"Services/Cron/classes/class.ilCronJobResult.php";
238 foreach(
$data as $idx => $item)
241 $item[
"component"], $item[
"class"], $item[
"path"]);
249 $lng->loadLanguageModule(
"cmps");
255 $item[
"job_id"] =
"pl__".$item[
"component"].
"__".$job->getId();
256 $item[
"component"] = $lng->txt(
"cmps_plugin").
"/".$item[
"component"];
268 $this->tpl->setVariable(
"VAL_ID", $a_set[
"title"]);
269 $this->tpl->setVariable(
"VAL_JID", $a_set[
"job_id"]);
271 if($a_set[
"description"])
273 $this->tpl->setVariable(
"VAL_DESC", $a_set[
"description"]);
276 $this->tpl->setVariable(
"VAL_COMPONENT", $a_set[
"component"]);
277 $this->tpl->setVariable(
"VAL_SCHEDULE", $a_set[
"schedule"]);
278 $this->tpl->setVariable(
"VAL_STATUS", $a_set[
"status"]);
279 $this->tpl->setVariable(
"VAL_STATUS_INFO", $a_set[
"status_info"]);
280 $this->tpl->setVariable(
"VAL_RESULT", $a_set[
"result"]);
281 $this->tpl->setVariable(
"VAL_RESULT_INFO", $a_set[
"result_info"]);
282 if($a_set[
"last_run"] > time())
284 $a_set[
"last_run"] = $lng->txt(
"cron_running_since").
" ".
288 if($a_set[
"alive_ts"] != $a_set[
"running_ts"])
290 $a_set[
"last_run"] .=
"<br />(Ping: ".
294 else if($a_set[
"last_run"])
298 $this->tpl->setVariable(
"VAL_LAST_RUN", $a_set[
"last_run"] ? $a_set[
"last_run"] :
"-");
305 if(!$a_set[
"running_ts"])
310 $actions[] =
"reset";
313 else if(!$a_set[
"job_status"])
315 $actions[] =
"activate";
320 if($a_set[
'is_manually_executable'])
324 $actions[] =
"deactivate";
327 if($a_set[
"editable_schedule"] || $a_set[
"has_settings"])
332 $ilCtrl->setParameter($this->
getParentObject(),
"jid", $a_set[
"job_id"]);
334 foreach($actions as $action)
336 $this->tpl->setCurrentBlock(
"action_bl");
337 $this->tpl->setVariable(
"URL_ACTION",
338 $ilCtrl->getLinkTarget($this->getParentObject(), $action));
339 $this->tpl->setVariable(
"TXT_ACTION", $lng->txt(
"cron_action_".$action));
340 $this->tpl->parseCurrentBlock();