19 declare(strict_types=1);
28 class JobTable implements \ILIAS\UI\Component\Table\DataRetrieval
40 array $table_action_namespace,
41 string $table_action_param_name,
42 string $table_row_identifier_name,
49 private readonly
bool $mayWrite =
false 51 $form_action = (new \ILIAS\Data\Factory())->uri(
60 ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
61 $table_action_namespace,
62 $table_action_param_name,
63 $table_row_identifier_name
69 array $visible_column_ids,
73 ?array $additional_parameters
75 foreach ($this->
getRecords($range, $order) as $item) {
80 'status' => (bool) $item->getJobStatus(),
87 if ($item->getJob()->hasFlexibleSchedule()) {
88 if ($item->getScheduleType() ===
null) {
89 $this->job_repository->updateJobSchedule(
91 $item->getEffectiveScheduleType(),
92 $item->getEffectiveScheduleValue()
95 } elseif ($item->getScheduleType() !==
null) {
96 $this->job_repository->updateJobSchedule($item->getJob(),
null,
null);
99 $actions_executable = $this->mayWrite && !$item->getRunningTimestamp();
100 $is_crashed = \ILIAS\Cron\Job\JobResult::STATUS_CRASHED === $item->getJobResultStatus();
101 $is_acivated = (bool) $item->getJobStatus();
103 $may_reset = $actions_executable && $is_crashed;
104 $may_activate = $actions_executable && !$is_crashed && !$is_acivated;
105 $may_deactivate = $actions_executable && !$is_crashed && $is_acivated;
106 $may_run = $actions_executable && !$is_crashed && $is_acivated && $item->getJob()->isManuallyExecutable();
107 $may_edit = $actions_executable && (
108 $item->getJob()->hasFlexibleSchedule() || $item->getJob()->hasCustomSettings()
112 ->buildDataRow($item->getEffectiveJobId(), $record)
113 ->withDisabledAction(
'run', !$may_run)
114 ->withDisabledAction(
'activate', !$may_activate)
115 ->withDisabledAction(
'deactivate', !$may_deactivate)
116 ->withDisabledAction(
'reset', !$may_reset)
117 ->withDisabledAction(
'edit', !$may_edit);
123 return \count($this->job_collection);
131 [$order_field, $order_direction] = $order->join([],
static function ($ret, $key, $value) {
132 return [$key, $value];
135 $collection =
new OrderedJobEntities(
136 $this->job_collection,
137 match ($order_field) {
141 if ($order_field ===
'component') {
145 if ($order_field ===
'schedule') {
149 if ($order_field ===
'result') {
153 if ($order_field ===
'last_run') {
162 if ($right->getRunningTimestamp()) {
163 $right_last_run = strtotime(
'+1year', $right->getRunningTimestamp());
164 } elseif ($right->getJobResultTimestamp()) {
165 $right_last_run = $right->getJobResultTimestamp();
168 return $left_last_run <=> $right_last_run;
177 $records = \array_slice($collection->toArray(), $range->getStart(), $range->getLength());
184 $title = implode(
'', [
189 if ($entity->
getJob()->getDescription()) {
190 $title .= implode(
'', [
191 '<div class="il_Description_no_margin">',
192 $entity->
getJob()->getDescription(),
203 JobScheduleType::DAILY => $this->
lng->txt(
'cron_schedule_daily'),
204 JobScheduleType::WEEKLY => $this->
lng->txt(
'cron_schedule_weekly'),
205 JobScheduleType::MONTHLY => $this->
lng->txt(
'cron_schedule_monthly'),
206 JobScheduleType::QUARTERLY => $this->
lng->txt(
'cron_schedule_quarterly'),
208 JobScheduleType::IN_MINUTES => \sprintf(
209 $this->
lng->txt(
'cron_schedule_in_minutes'),
212 JobScheduleType::IN_HOURS => \sprintf(
213 $this->
lng->txt(
'cron_schedule_in_hours'),
216 JobScheduleType::IN_DAYS => \sprintf(
217 $this->
lng->txt(
'cron_schedule_in_days'),
229 $component = $this->
lng->txt(
'cmps_plugin') .
'/' . $component;
247 $status_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
250 return implode(
'<br />', $status_info);
258 case \ILIAS\Cron\Job\JobResult::STATUS_INVALID_CONFIGURATION:
259 $result = $this->
lng->txt(
'cron_result_status_invalid_configuration');
262 case \ILIAS\Cron\Job\JobResult::STATUS_NO_ACTION:
263 $result = $this->
lng->txt(
'cron_result_status_no_action');
266 case \ILIAS\Cron\Job\JobResult::STATUS_OK:
267 $result = $this->
lng->txt(
'cron_result_status_ok');
270 case \ILIAS\Cron\Job\JobResult::STATUS_CRASHED:
271 $result = $this->
lng->txt(
'cron_result_status_crashed');
274 case \ILIAS\Cron\Job\JobResult::STATUS_RESET:
275 $result = $this->
lng->txt(
'cron_result_status_reset');
278 case \ILIAS\Cron\Job\JobResult::STATUS_FAIL:
279 $result = $this->
lng->txt(
'cron_result_status_fail');
297 $result_info[] = $this->
lng->txt(
'cro_job_rc_' . $resultCode);
302 if (\defined(
'DEVMODE') && DEVMODE && $resultCode) {
303 $result_info[] = $resultCode;
309 $result_info[] = $this->
lng->txt(
'cron_changed_by_crontab');
312 return implode(
'<br />', $result_info);
324 if ($last_run > time()) {
325 $last_run = $this->
lng->txt(
'cron_running_since') .
' ' .
330 $last_run .=
'<br />(Ping: ' .
333 } elseif ($last_run) {
337 return $last_run ?:
'-';
346 'title' => $this->ui_factory
349 ->text($this->
lng->txt(
'title') .
' / ' . $this->
lng->txt(
'description'))
350 ->withIsSortable(
true),
351 'component' => $this->ui_factory
354 ->text($this->
lng->txt(
'cron_component'))
355 ->withIsSortable(
true)
356 ->withIsOptional(
true,
false),
357 'schedule' => $this->ui_factory
360 ->text($this->
lng->txt(
'cron_schedule'))
361 ->withIsSortable(
true),
362 'status' => $this->ui_factory
366 $this->
lng->txt(
'cron_status'),
367 $this->ui_factory->symbol()->icon()->custom(
368 'assets/images/standard/icon_ok.svg',
369 $this->
lng->txt(
'cron_status_active'),
370 \ILIAS\UI\Component\Symbol\Icon\Icon::SMALL
372 $this->ui_factory->symbol()->icon()->custom(
373 'assets/images/standard/icon_not_ok.svg',
374 $this->
lng->txt(
'cron_status_inactive'),
375 \ILIAS\UI\Component\Symbol\Icon\Icon::SMALL
378 ->withIsSortable(
true),
379 'status_info' => $this->ui_factory
382 ->text($this->
lng->txt(
'cron_status_info'))
383 ->withIsSortable(
false),
384 'result' => $this->ui_factory
387 ->status($this->
lng->txt(
'cron_result'))
388 ->withIsSortable(
true),
389 'result_info' => $this->ui_factory
392 ->text($this->
lng->txt(
'cron_result_info'))
393 ->withIsSortable(
false),
394 'last_run' => $this->ui_factory
397 ->text($this->
lng->txt(
'cron_last_run'))
398 ->withIsSortable(
true)
407 if (!$this->mayWrite) {
412 'run' => $this->ui_factory->table()->action()->single(
413 $this->
lng->txt(
'cron_action_run'),
414 $this->url_builder->withParameter($this->action_parameter_token,
'run'),
417 'activate' => $this->ui_factory->table()->action()->standard(
418 $this->
lng->txt(
'cron_action_activate'),
419 $this->url_builder->withParameter($this->action_parameter_token,
'activate'),
422 'deactivate' => $this->ui_factory->table()->action()->standard(
423 $this->
lng->txt(
'cron_action_deactivate'),
424 $this->url_builder->withParameter($this->action_parameter_token,
'deactivate'),
427 'reset' => $this->ui_factory->table()->action()->standard(
428 $this->
lng->txt(
'cron_action_reset'),
429 $this->url_builder->withParameter($this->action_parameter_token,
'reset'),
432 'edit' => $this->ui_factory->table()->action()->single(
433 $this->
lng->txt(
'cron_action_edit'),
434 $this->url_builder->withParameter($this->action_parameter_token,
'edit'),
442 return $this->ui_factory
444 ->data($this, $this->
lng->txt(
'cron_jobs'), $this->
getColumns())
446 ->withId(self::class)
447 ->withRequest($this->request)
formatComponent(JobEntity $entity)
readonly ILIAS UI URLBuilderToken $row_id_token
Interface Observer Contains several chained tasks and infos about them.
readonly ILIAS UI URLBuilder $url_builder
getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)
formatStatusInfo(JobEntity $entity)
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a link target for the given information.
formatResultInfo(JobEntity $entity)
Both the subject and the direction need to be specified when expressing an order. ...
readonly ILIAS UI URLBuilderToken $action_parameter_token
formatSchedule(JobEntity $entity)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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:
formatResult(JobEntity $entity)
final const int ORDER_BY_STATUS
getEffectiveScheduleType()
getEffectiveScheduleValue()
formatLastRun(JobEntity $entity)
__construct(\ilCronManagerGUI $a_parent_obj, string $a_parent_cmd, 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, \ilCtrlInterface $ctrl, private readonly \ilLanguage $lng, private readonly \ILIAS\Cron\Job\JobCollection $job_collection, private readonly JobRepository $job_repository, private readonly bool $mayWrite=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
ilCronManagerGUI: ilPropertyFormGUI ilCronManagerGUI: ilAdministrationGUI
formatTitle(JobEntity $entity)
A simple class to express a naive range of whole positive numbers.
getRows(\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, ?array $filter_data, ?array $additional_parameters)
final const int ORDER_BY_NAME