ILIAS  release_8 Revision v8.24
class.ilSCTaskTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
25{
26 private int $group_id = 0;
27
29
30 public function __construct(int $a_group_id, object $a_parent_obj, string $a_parent_cmd = '')
31 {
32 global $DIC;
33 $this->group_id = $a_group_id;
34 $this->setId('sc_groups');
35 $this->access = $DIC->access();
36
37 parent::__construct($a_parent_obj, $a_parent_cmd);
38 }
39
40 public function getGroupId(): int
41 {
42 return $this->group_id;
43 }
44
45 public function init(): void
46 {
47 $this->lng->loadLanguageModule('sysc');
48 $this->addColumn($this->lng->txt('title'), 'title', '60%');
49 $this->addColumn($this->lng->txt('last_update'), 'last_update_sort', '20%');
50 $this->addColumn($this->lng->txt('status'), 'status', '10%');
51 $this->addColumn($this->lng->txt('actions'), '', '10%');
52
53 $this->setTitle($this->lng->txt('sysc_task_overview'));
54
55 $this->setRowTemplate('tpl.syscheck_tasks_row.html', 'Services/SystemCheck');
56 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
57 }
58
62 protected function fillRow(array $a_set): void
63 {
64 $this->tpl->setVariable('VAL_TITLE', (string) ($a_set['title'] ?? ''));
65 $this->tpl->setVariable('VAL_DESC', (string) ($a_set['description'] ?? ''));
66
67 $status = (int) ($a_set['status'] ?? 0);
68 $text = ilSCUtils::taskStatus2Text($status);
69 switch ($status) {
71 $this->tpl->setVariable('VAL_STATUS_SUCCESS', $text);
72 break;
73
75 $this->tpl->setCurrentBlock('warning');
76 $this->tpl->setVariable('VAL_STATUS_WARNING', $text);
77 $this->tpl->parseCurrentBlock();
78 break;
79
80 default:
81 $this->tpl->setVariable('VAL_STATUS_STANDARD', $text);
82 break;
83 }
84
85 $this->tpl->setVariable('VAL_LAST_UPDATE', (string) ($a_set['last_update'] ?? ''));
86
87 // Actions
88 if ($this->access->checkAccess('write', '', $this->parent_obj->getObject()->getRefId())) {
89 $id = (int) ($a_set['id'] ?? 0);
90 $list = new ilAdvancedSelectionListGUI();
91 $list->setSelectionHeaderClass('small');
92 $list->setItemLinkClass('small');
93 $list->setId('sysc_' . $id);
94 $list->setListTitle($this->lng->txt('actions'));
95
97
98 $this->ctrl->setParameterByClass(get_class($task_handler), 'task_id', $id);
99 foreach ($task_handler->getActions() as $actions) {
100 $list->addItem(
101 (string) ($actions['txt'] ?? ''),
102 '',
103 $this->ctrl->getLinkTargetByClass(
104 get_class($task_handler),
105 (string) ($actions['command'] ?? '')
106 )
107 );
108 }
109
110 $this->tpl->setVariable('ACTIONS', $list->getHTML());
111 }
112 }
113
114 public function parse(): void
115 {
116 $data = array();
117
118 foreach (ilSCTasks::getInstanceByGroupId($this->getGroupId())->getTasks() as $task) {
119 $task_handler = ilSCComponentTaskFactory::getComponentTask($task->getId());
120
121 if (!$task->isActive()) {
122 continue;
123 }
124
125 $item = array();
126 $item['id'] = $task->getId();
127 $item['title'] = $task_handler->getTitle();
128 $item['description'] = $task_handler->getDescription();
129 $item['last_update'] = ilDatePresentation::formatDate($task->getLastUpdate());
130 $item['last_update_sort'] = $task->getLastUpdate()->get(IL_CAL_UNIX);
131 $item['status'] = $task->getStatus();
132
133 $data[] = $item;
134 }
135
136 $this->setData($data);
137 }
138}
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_group_id, object $a_parent_obj, string $a_parent_cmd='')
const STATUS_COMPLETED
const STATUS_FAILED
static getInstanceByGroupId(int $a_group_id)
static taskStatus2Text(int $a_status)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc