ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSServerTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27
28 private \ILIAS\UI\Factory $ui_factory;
29 private \ILIAS\UI\Renderer $ui_renderer;
30
31 public function __construct(object $a_parent_obj, string $a_parent_cmd = "")
32 {
33 global $DIC;
34
35 parent::__construct($a_parent_obj, $a_parent_cmd);
36 $this->setId('ecs_server_list');
37
38 $this->access = $DIC->access();
39 $this->ui_factory = $DIC->ui()->factory();
40 $this->ui_renderer = $DIC->ui()->renderer();
41 }
42
46 public function initTable(): void
47 {
48 $this->setTitle($this->lng->txt('ecs_available_ecs'));
49 $this->setRowTemplate('tpl.ecs_server_row.html', 'components/ILIAS/WebServices/ECS');
50
51 $this->addColumn($this->lng->txt('ecs_tbl_active'), '', '1%');
52 $this->addColumn($this->lng->txt('title'), '', '80%');
53
54 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
55 $this->addColumn($this->lng->txt('actions'), '', '19%');
56 }
57 }
58
63 protected function fillRow(array $a_set): void
64 {
65 $this->ctrl->setParameter($this->getParentObject(), 'server_id', $a_set['server_id']);
66 $this->ctrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $a_set['server_id']);
67
68 if ($a_set['active']) {
69 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_ok.svg'));
70 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
71 } else {
72 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('standard/icon_not_ok.svg'));
73 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated'));
74 }
75
76
77 $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($a_set['server_id'])->getTitle());
78 $this->tpl->setVariable('LINK_EDIT', $this->ctrl->getLinkTarget($this->getParentObject(), 'edit'));
79 $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr'));
80
81 if (ilECSSetting::getInstanceByServerId($a_set['server_id'])->getServer()) {
82 $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($a_set['server_id'])->getServer());
83 } else {
84 $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
85 }
86
87 $dt = ilECSSetting::getInstanceByServerId($a_set['server_id'])->fetchCertificateExpiration();
88 if ($dt !== null) {
89 $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
90
91 $now = new ilDateTime(time(), IL_CAL_UNIX);
92 $now->increment(IL_CAL_MONTH, 2);
93
94 if (ilDateTime::_before($dt, $now)) {
95 $this->tpl->setCurrentBlock('invalid');
96 $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
97 } else {
98 $this->tpl->setCurrentBlock('valid');
99 $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
100 }
101 $this->tpl->parseCurrentBlock();
102 }
103
104 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
105 // Actions
106 $items = [];
107
108 if (ilECSSetting::getInstanceByServerId($a_set['server_id'])->isEnabled()) {
109 $items[] = [$this->lng->txt('ecs_deactivate'), $this->ctrl->getLinkTarget($this->getParentObject(), 'deactivate')];
110 } else {
111 $items[] = [$this->lng->txt('ecs_activate'), $this->ctrl->getLinkTarget($this->getParentObject(), 'activate')];
112 }
113
114 $items[] = [$this->lng->txt('edit'), $this->ctrl->getLinkTarget($this->getParentObject(), 'edit')];
115 $items[] = [$this->lng->txt('copy'), $this->ctrl->getLinkTarget($this->getParentObject(), 'cp')];
116 $items[] = [$this->lng->txt('delete'), $this->ctrl->getLinkTarget($this->getParentObject(), 'delete')];
117
118 $this->tpl->setCurrentBlock("actions");
119 $render_items = [];
120 foreach ($items as $item) {
121 $render_items[] = $this->ui_factory->button()->shy(...$item);
122 }
123 $this->tpl->setVariable(
124 'ACTIONS',
125 $this->ui_renderer->render($this->ui_factory->dropdown()->standard($render_items)->withLabel($this->lng->txt('actions')))
126 );
127 $this->tpl->parseCurrentBlock();
128 }
129 $this->ctrl->clearParameters($this->getParentObject());
130 }
131
135 public function parse(ilECSServerSettings $servers): void
136 {
137 $rows = [];
138 foreach ($servers->getServers(ilECSServerSettings::ALL_SERVER) as $server) {
139 $tmp['server_id'] = $server->getServerId();
140 $tmp['active'] = $server->isEnabled();
141
142 $rows[] = $tmp;
143 }
144 $this->setData($rows);
145 }
146}
const IL_CAL_UNIX
const IL_CAL_MONTH
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 _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Collection of ECS settings.
getServers(int $server_type)
Get servers The function must be called with ALL_SERVER, ACTIVE_SERVER or INACTIVE_SERVER.
__construct(object $a_parent_obj, string $a_parent_cmd="")
parse(ilECSServerSettings $servers)
Parse available servers.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
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="")
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.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$server
Definition: shib_login.php:28