19declare(strict_types=1);
40 array $table_action_namespace,
41 string $table_action_param_name,
42 string $table_row_identifier_name,
44 private readonly \Psr\Http\Message\ServerRequestInterface $request,
48 private readonly
bool $mayWrite =
false
54 ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
55 $table_action_namespace,
56 $table_action_param_name,
57 $table_row_identifier_name
63 array $visible_column_ids,
66 mixed $additional_viewcontrol_data,
68 mixed $additional_parameters
75 'status' => (bool) $item->getJobStatus(),
82 if ($item->getJob()->hasFlexibleSchedule()) {
83 if ($item->getScheduleType() ===
null) {
84 $this->job_repository->updateJobSchedule(
86 $item->getEffectiveScheduleType(),
87 $item->getEffectiveScheduleValue()
90 } elseif ($item->getScheduleType() !==
null) {
91 $this->job_repository->updateJobSchedule($item->getJob(),
null,
null);
94 $actions_executable = $this->mayWrite && !$item->getRunningTimestamp();
96 $is_acivated = (bool) $item->getJobStatus();
98 $may_reset = $actions_executable && $is_crashed;
99 $may_activate = $actions_executable && !$is_crashed && !$is_acivated;
100 $may_deactivate = $actions_executable && !$is_crashed && $is_acivated;
101 $may_run = $actions_executable && !$is_crashed && $is_acivated && $item->getJob()->isManuallyExecutable();
102 $may_edit = $actions_executable && (
103 $item->getJob()->hasFlexibleSchedule() || $item->getJob()->hasCustomSettings()
107 ->buildDataRow($item->getEffectiveJobId(), $record)
108 ->withDisabledAction(
'run', !$may_run)
109 ->withDisabledAction(
'activate', !$may_activate)
110 ->withDisabledAction(
'deactivate', !$may_deactivate)
111 ->withDisabledAction(
'reset', !$may_reset)
112 ->withDisabledAction(
'edit', !$may_edit);
117 mixed $additional_viewcontrol_data,
119 mixed $additional_parameters
121 return \count($this->job_collection);
129 [$order_field, $order_direction] = $order->join([],
static function ($ret, $key, $value) {
130 return [$key, $value];
134 $this->job_collection,
135 match ($order_field) {
136 'title' => OrderedJobEntities::ORDER_BY_NAME,
137 'status' => OrderedJobEntities::ORDER_BY_STATUS,
139 if ($order_field ===
'component') {
140 return \ilStr::strCmp($this->formatComponent($left), $this->formatComponent($right));
143 if ($order_field ===
'schedule') {
144 return \ilStr::strCmp($this->formatSchedule($left), $this->formatSchedule($right));
147 if ($order_field ===
'result') {
148 return \ilStr::strCmp($this->formatResult($left), $this->formatResult($right));
151 if ($order_field ===
'last_run') {
160 if ($right->getRunningTimestamp()) {
161 $right_last_run = strtotime(
'+1year', $right->getRunningTimestamp());
162 } elseif ($right->getJobResultTimestamp()) {
163 $right_last_run = $right->getJobResultTimestamp();
166 return $left_last_run <=> $right_last_run;
182 $title = implode(
'', [
187 if ($entity->
getJob()->getDescription()) {
188 $title .= implode(
'', [
189 '<div class="il_Description_no_margin">',
190 $entity->
getJob()->getDescription(),
201 JobScheduleType::DAILY => $this->
lng->txt(
'cron_schedule_daily'),
202 JobScheduleType::WEEKLY => $this->
lng->txt(
'cron_schedule_weekly'),
203 JobScheduleType::MONTHLY => $this->
lng->txt(
'cron_schedule_monthly'),
204 JobScheduleType::QUARTERLY => $this->
lng->txt(
'cron_schedule_quarterly'),
206 JobScheduleType::IN_MINUTES => \sprintf(
207 $this->
lng->txt(
'cron_schedule_in_minutes'),
210 JobScheduleType::IN_HOURS => \sprintf(
211 $this->
lng->txt(
'cron_schedule_in_hours'),
214 JobScheduleType::IN_DAYS => \sprintf(
215 $this->
lng->txt(
'cron_schedule_in_days'),
227 $component = $this->
lng->txt(
'cmps_plugin') .
'/' . $component;
245 $status_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
248 return implode(
'<br />', $status_info);
256 case \ILIAS\Cron\Job\JobResult::STATUS_INVALID_CONFIGURATION:
257 $result = $this->
lng->txt(
'cron_result_status_invalid_configuration');
260 case \ILIAS\Cron\Job\JobResult::STATUS_NO_ACTION:
261 $result = $this->
lng->txt(
'cron_result_status_no_action');
264 case \ILIAS\Cron\Job\JobResult::STATUS_OK:
265 $result = $this->
lng->txt(
'cron_result_status_ok');
268 case \ILIAS\Cron\Job\JobResult::STATUS_CRASHED:
269 $result = $this->
lng->txt(
'cron_result_status_crashed');
272 case \ILIAS\Cron\Job\JobResult::STATUS_RESET:
273 $result = $this->
lng->txt(
'cron_result_status_reset');
276 case \ILIAS\Cron\Job\JobResult::STATUS_FAIL:
277 $result = $this->
lng->txt(
'cron_result_status_fail');
294 if (\in_array($resultCode, \
ILIAS\
Cron\Job\JobResult::getCoreCodes(),
true)) {
295 $result_info[] = $this->
lng->txt(
'cro_job_rc_' . $resultCode);
300 if (\defined(
'DEVMODE') && DEVMODE && $resultCode) {
301 $result_info[] = $resultCode;
307 $result_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
310 return implode(
'<br />', $result_info);
322 if ($last_run > time()) {
323 $last_run = $this->
lng->txt(
'cron_running_since') .
' ' .
328 $last_run .=
'<br />(Ping: ' .
331 } elseif ($last_run) {
335 return $last_run ?:
'-';
344 'title' => $this->ui_factory
347 ->text($this->
lng->txt(
'title') .
' / ' . $this->lng->txt(
'description'))
348 ->withIsSortable(
true),
349 'component' => $this->ui_factory
352 ->text($this->
lng->txt(
'cron_component'))
353 ->withIsSortable(
true)
354 ->withIsOptional(
true,
false),
355 'schedule' => $this->ui_factory
358 ->text($this->
lng->txt(
'cron_schedule'))
359 ->withIsSortable(
true),
360 'status' => $this->ui_factory
364 $this->
lng->txt(
'cron_status'),
365 $this->ui_factory->symbol()->icon()->custom(
366 'assets/images/standard/icon_ok.svg',
367 $this->lng->txt(
'cron_status_active'),
370 $this->ui_factory->symbol()->icon()->custom(
371 'assets/images/standard/icon_not_ok.svg',
372 $this->lng->txt(
'cron_status_inactive'),
376 ->withIsSortable(
true),
377 'status_info' => $this->ui_factory
380 ->text($this->
lng->txt(
'cron_status_info'))
381 ->withIsSortable(
false),
382 'result' => $this->ui_factory
385 ->status($this->
lng->txt(
'cron_result'))
386 ->withIsSortable(
true),
387 'result_info' => $this->ui_factory
390 ->text($this->
lng->txt(
'cron_result_info'))
391 ->withIsSortable(
false),
392 'last_run' => $this->ui_factory
395 ->text($this->
lng->txt(
'cron_last_run'))
396 ->withIsSortable(
true)
405 if (!$this->mayWrite) {
410 'run' => $this->ui_factory->table()->action()->single(
411 $this->
lng->txt(
'cron_action_run'),
412 $this->url_builder->withParameter($this->action_parameter_token,
'run'),
415 'activate' => $this->ui_factory->table()->action()->standard(
416 $this->
lng->txt(
'cron_action_activate'),
417 $this->url_builder->withParameter($this->action_parameter_token,
'activate'),
420 'deactivate' => $this->ui_factory->table()->action()->standard(
421 $this->
lng->txt(
'cron_action_deactivate'),
422 $this->url_builder->withParameter($this->action_parameter_token,
'deactivate'),
425 'reset' => $this->ui_factory->table()->action()->standard(
426 $this->
lng->txt(
'cron_action_reset'),
427 $this->url_builder->withParameter($this->action_parameter_token,
'reset'),
430 'edit' => $this->ui_factory->table()->action()->single(
431 $this->
lng->txt(
'cron_action_edit'),
432 $this->url_builder->withParameter($this->action_parameter_token,
'edit'),
440 return $this->ui_factory
442 ->data($this, $this->
lng->txt(
'cron_jobs'), $this->getColumns())
443 ->withActions($this->getActions())
444 ->withId(self::class)
445 ->withRequest($this->request)
getEffectiveScheduleValue()
getEffectiveScheduleType()
final const int STATUS_CRASHED
readonly ILIAS UI URLBuilderToken $action_parameter_token
getRows(\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)
readonly ILIAS UI URLBuilder $url_builder
readonly ILIAS UI URLBuilderToken $row_id_token
__construct(URI $form_action, array $table_action_namespace, string $table_action_param_name, string $table_row_identifier_name, private readonly \ILIAS\UI\Factory $ui_factory, private readonly \Psr\Http\Message\ServerRequestInterface $request, private readonly \ilLanguage $lng, private readonly \ILIAS\Cron\Job\JobCollection $job_collection, private readonly JobRepository $job_repository, private readonly bool $mayWrite=false)
formatTitle(JobEntity $entity)
formatResult(JobEntity $entity)
formatResultInfo(JobEntity $entity)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
formatComponent(JobEntity $entity)
formatLastRun(JobEntity $entity)
formatStatusInfo(JobEntity $entity)
formatSchedule(JobEntity $entity)
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
The scope of this class is split ilias-conform URI's into components.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
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=null)
Default behaviour is:
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@template-extends \IteratorAggregate<\ILIAS\Cron\Job\JobEntity>
This is how the factory for UI elements looks.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.