19 declare(strict_types=1);
29 private readonly
bool $mayWrite =
false 31 $this->
setId(
'crnmng');
35 if ($this->mayWrite) {
38 $this->
addColumn($this->
lng->txt(
'cron_job_id'),
'title');
39 $this->
addColumn($this->
lng->txt(
'cron_component'),
'component');
40 $this->
addColumn($this->
lng->txt(
'cron_schedule'),
'schedule');
41 $this->
addColumn($this->
lng->txt(
'cron_status'),
'status');
42 $this->
addColumn($this->
lng->txt(
'cron_status_info'),
'');
43 $this->
addColumn($this->
lng->txt(
'cron_result'),
'result');
44 $this->
addColumn($this->
lng->txt(
'cron_result_info'),
'');
45 $this->
addColumn($this->
lng->txt(
'cron_last_run'),
'last_run');
46 if ($this->mayWrite) {
53 if ($this->mayWrite) {
67 CronJobScheduleType::SCHEDULE_TYPE_DAILY => $this->
lng->txt(
'cron_schedule_daily'),
68 CronJobScheduleType::SCHEDULE_TYPE_WEEKLY => $this->
lng->txt(
'cron_schedule_weekly'),
69 CronJobScheduleType::SCHEDULE_TYPE_MONTHLY => $this->
lng->txt(
'cron_schedule_monthly'),
70 CronJobScheduleType::SCHEDULE_TYPE_QUARTERLY => $this->
lng->txt(
'cron_schedule_quarterly'),
72 CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES => sprintf(
73 $this->
lng->txt(
'cron_schedule_in_minutes'),
76 CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS => sprintf(
77 $this->
lng->txt(
'cron_schedule_in_hours'),
80 CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS => sprintf(
81 $this->
lng->txt(
'cron_schedule_in_days'),
101 $status_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
104 return implode(
'<br />', $status_info);
113 $result = $this->
lng->txt(
'cron_result_status_invalid_configuration');
117 $result = $this->
lng->txt(
'cron_result_status_no_action');
121 $result = $this->
lng->txt(
'cron_result_status_ok');
125 $result = $this->
lng->txt(
'cron_result_status_crashed');
129 $result = $this->
lng->txt(
'cron_result_status_reset');
133 $result = $this->
lng->txt(
'cron_result_status_fail');
151 $result_info[] = $this->
lng->txt(
'cro_job_rc_' . $resultCode);
156 if (defined(
'DEVMODE') && DEVMODE && $resultCode) {
157 $result_info[] = $resultCode;
163 $result_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
166 return implode(
'<br />', $result_info);
175 $row[
'status'] = $this->
lng->txt(
'cron_status_inactive');
177 $row[
'status'] = $this->
lng->txt(
'cron_status_active');
183 $row[
'last_run'] = null;
190 $row[
'job_id'] = $entity->
getJobId();
193 $row[
'job_id'] =
'pl__' . $row[
'component'] .
'__' . $row[
'job_id'];
194 $row[
'component'] = $this->
lng->txt(
'cmps_plugin') .
'/' . $row[
'component'];
198 $row[
'description'] = $entity->
getJob()->getDescription();
199 $row[
'is_manually_executable'] = $entity->
getJob()->isManuallyExecutable();
200 $row[
'has_settings'] = $entity->
getJob()->hasCustomSettings();
206 if ($entity->
getJob()->hasFlexibleSchedule()) {
207 $row[
'editable_schedule'] =
true;
209 $this->cronRepository->updateJobSchedule(
216 $this->cronRepository->updateJobSchedule($entity->
getJob(), null, null);
225 protected function fillRow(array $a_set): void
227 if ($this->mayWrite) {
228 $this->tpl->setVariable(
'VAL_JID', $a_set[
'job_id']);
230 $this->tpl->setVariable(
'VAL_ID', $a_set[
'title']);
232 if ($a_set[
'description']) {
233 $this->tpl->setVariable(
'VAL_DESC', $a_set[
'description']);
236 $this->tpl->setVariable(
'VAL_COMPONENT', $a_set[
'component']);
237 $this->tpl->setVariable(
'VAL_SCHEDULE', $a_set[
'schedule']);
238 $this->tpl->setVariable(
'VAL_STATUS', $a_set[
'status']);
239 $this->tpl->setVariable(
'VAL_STATUS_INFO', $a_set[
'status_info']);
240 $this->tpl->setVariable(
'VAL_RESULT', $a_set[
'result']);
241 $this->tpl->setVariable(
'VAL_RESULT_INFO', $a_set[
'result_info']);
242 if ($a_set[
'last_run'] > time()) {
243 $a_set[
'last_run'] = $this->
lng->txt(
'cron_running_since') .
' ' .
247 if ($a_set[
'alive_ts'] !== $a_set[
'running_ts']) {
248 $a_set[
'last_run'] .=
'<br />(Ping: ' .
251 } elseif ($a_set[
'last_run']) {
254 $this->tpl->setVariable(
'VAL_LAST_RUN', $a_set[
'last_run'] ?:
'-');
257 if ($this->mayWrite && !$a_set[
'running_ts']) {
259 $actions[] =
'reset';
260 } elseif (!$a_set[
'job_status']) {
261 $actions[] =
'activate';
263 if ($a_set[
'is_manually_executable']) {
266 $actions[] =
'deactivate';
270 (isset($a_set[
'editable_schedule']) && $a_set[
'editable_schedule']) ||
271 (isset($a_set[
'has_settings']) && $a_set[
'has_settings'])
277 foreach ($actions as $action) {
278 $this->tpl->setCurrentBlock(
'action_bl');
279 $this->tpl->setVariable(
281 $this->
ctrl->getLinkTarget($this->getParentObject(), $action)
283 $this->tpl->setVariable(
'TXT_ACTION', $this->
lng->txt(
'cron_action_' . $action));
284 $this->tpl->parseCurrentBlock();
formatResultInfo(ilCronJobEntity $entity)
formatSchedule(ilCronJobEntity $entity, array $row)
getEffectiveScheduleValue()
getEffectiveScheduleType()
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
formatStatusInfo(ilCronJobEntity $entity)
final const STATUS_INVALID_CONFIGURATION
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
setDefaultOrderField(string $a_defaultorderfield)
final const STATUS_NO_ACTION
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
final const STATUS_CRASHED
formatResult(ilCronJobEntity $entity)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
addMultiCommand(string $a_cmd, string $a_text)
__construct(ilCronManagerGUI $a_parent_obj, private readonly ilCronJobRepository $cronRepository, string $a_parent_cmd, private readonly bool $mayWrite=false)
populate(ilCronJobCollection $collection)