ILIAS  release_8 Revision v8.24
class.ilECSServerTableGUI.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
24{
26
32 public function __construct($a_parent_obj, $a_parent_cmd = "")
33 {
34 global $DIC;
35
36 parent::__construct($a_parent_obj, $a_parent_cmd);
37 $this->setId('ecs_server_list');
38
39 $this->access = $DIC->access();
40 }
41
45 public function initTable(): void
46 {
47 $this->setTitle($this->lng->txt('ecs_available_ecs'));
48 $this->setRowTemplate('tpl.ecs_server_row.html', 'Services/WebServices/ECS');
49
50 $this->addColumn($this->lng->txt('ecs_tbl_active'), '', '1%');
51 $this->addColumn($this->lng->txt('title'), '', '80%');
52
53 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
54 $this->addColumn($this->lng->txt('actions'), '', '19%');
55 }
56 }
57
62 protected function fillRow(array $a_set): void
63 {
64 $this->ctrl->setParameter($this->getParentObject(), 'server_id', $a_set['server_id']);
65 $this->ctrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $a_set['server_id']);
66
67 if ($a_set['active']) {
68 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg'));
69 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
70 } else {
71 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_not_ok.svg'));
72 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated'));
73 }
74
75
76 $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($a_set['server_id'])->getTitle());
77 $this->tpl->setVariable('LINK_EDIT', $this->ctrl->getLinkTarget($this->getParentObject(), 'edit'));
78 $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr'));
79
80 if (ilECSSetting::getInstanceByServerId($a_set['server_id'])->getServer()) {
81 $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($a_set['server_id'])->getServer());
82 } else {
83 $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
84 }
85
86 $dt = ilECSSetting::getInstanceByServerId($a_set['server_id'])->fetchCertificateExpiration();
87 if ($dt !== null) {
88 $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
89
90 $now = new ilDateTime(time(), IL_CAL_UNIX);
91 $now->increment(IL_CAL_MONTH, 2);
92
93 if (ilDateTime::_before($dt, $now)) {
94 $this->tpl->setCurrentBlock('invalid');
95 $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
96 } else {
97 $this->tpl->setCurrentBlock('valid');
98 $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
99 }
100 $this->tpl->parseCurrentBlock();
101 }
102
103 if ($this->access->checkAccess('write', '', (int) $_REQUEST["ref_id"])) {
104 // Actions
105 $list = new ilAdvancedSelectionListGUI();
106 $list->setSelectionHeaderClass('small');
107 $list->setItemLinkClass('small');
108 $list->setId('actl_' . $a_set['server_id']);
109 $list->setListTitle($this->lng->txt('actions'));
110
111
112 if (ilECSSetting::getInstanceByServerId($a_set['server_id'])->isEnabled()) {
113 $list->addItem($this->lng->txt('ecs_deactivate'), '', $this->ctrl->getLinkTarget($this->getParentObject(), 'deactivate'));
114 } else {
115 $list->addItem($this->lng->txt('ecs_activate'), '', $this->ctrl->getLinkTarget($this->getParentObject(), 'activate'));
116 }
117
118 $list->addItem($this->lng->txt('edit'), '', $this->ctrl->getLinkTarget($this->getParentObject(), 'edit'));
119 $list->addItem($this->lng->txt('copy'), '', $this->ctrl->getLinkTarget($this->getParentObject(), 'cp'));
120 $list->addItem($this->lng->txt('delete'), '', $this->ctrl->getLinkTarget($this->getParentObject(), 'delete'));
121
122 $this->tpl->setCurrentBlock("actions");
123 $this->tpl->setVariable('ACTIONS', $list->getHTML());
124 $this->tpl->parseCurrentBlock();
125 }
126 $this->ctrl->clearParameters($this->getParentObject());
127 }
128
132 public function parse(ilECSServerSettings $servers): void
133 {
134 $rows = [];
135 foreach ($servers->getServers(ilECSServerSettings::ALL_SERVER) as $server) {
136 $tmp['server_id'] = $server->getServerId();
137 $tmp['active'] = $server->isEnabled();
138
139 $rows[] = $tmp;
140 }
141 $this->setData($rows);
142 }
143}
const IL_CAL_UNIX
const IL_CAL_MONTH
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)
@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.
parse(ilECSServerSettings $servers)
Parse available servers.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
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 $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$server
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10