ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilECSServerTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5
13{
19 public function __construct($a_parent_obj, $a_parent_cmd = "")
20 {
21 $this->setId('ecs_server_list');
22 parent::__construct($a_parent_obj, $a_parent_cmd);
23 }
24
28 public function initTable()
29 {
30 global $DIC;
31
32 $ilAccess = $DIC['ilAccess'];
33 $this->setTitle($this->lng->txt('ecs_available_ecs'));
34 $this->setRowTemplate('tpl.ecs_server_row.html', 'Services/WebServices/ECS');
35
36 $this->addColumn($this->lng->txt('ecs_tbl_active'), '', '1%');
37 $this->addColumn($this->lng->txt('title'), '', '80%');
38
39 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
40 $this->addColumn($this->lng->txt('actions'), '', '19%');
41 }
42 }
43
49 public function fillRow($set)
50 {
51 global $DIC;
52
53 $ilCtrl = $DIC['ilCtrl'];
54 $ilAccess = $DIC['ilAccess'];
55
56 $ilCtrl->setParameter($this->getParentObject(), 'server_id', $set['server_id']);
57 $ilCtrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $set['server_id']);
58
59 if ($set['active']) {
60 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg'));
61 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
62 } else {
63 $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_not_ok.svg'));
64 $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated'));
65 }
66
67 $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($set['server_id'])->getTitle());
68 $this->tpl->setVariable('LINK_EDIT', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
69 $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr'));
70
71 if (ilECSSetting::getInstanceByServerId($set['server_id'])->getServer()) {
72 $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($set['server_id'])->getServer());
73 } else {
74 $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
75 }
76
77 $dt = ilECSSetting::getInstanceByServerId($set['server_id'])->fetchCertificateExpiration();
78 if ($dt != null) {
79 $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
80
81 $now = new ilDateTime(time(), IL_CAL_UNIX);
82 $now->increment(IL_CAL_MONTH, 2);
83
84 if (ilDateTime::_before($dt, $now)) {
85 $this->tpl->setCurrentBlock('invalid');
86 $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
87 $this->tpl->parseCurrentBlock();
88 } else {
89 $this->tpl->setCurrentBlock('valid');
90 $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
91 $this->tpl->parseCurrentBlock();
92 }
93 }
94
95 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
96 // Actions
97 include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
98 $list = new ilAdvancedSelectionListGUI();
99 $list->setSelectionHeaderClass('small');
100 $list->setItemLinkClass('small');
101 $list->setId('actl_' . $set['server_id']);
102 $list->setListTitle($this->lng->txt('actions'));
103
104 if (ilECSSetting::getInstanceByServerId($set['server_id'])->isEnabled()) {
105 $list->addItem($this->lng->txt('ecs_deactivate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'deactivate'));
106 } else {
107 $list->addItem($this->lng->txt('ecs_activate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'activate'));
108 }
109
110 $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
111 $list->addItem($this->lng->txt('copy'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'cp'));
112 $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'delete'));
113
114 $this->tpl->setCurrentBlock("actions");
115 $this->tpl->setVariable('ACTIONS', $list->getHTML());
116 $this->tpl->parseCurrentBlock();
117 }
118 $ilCtrl->clearParameters($this->getParentObject());
119 }
120
125 public function parse(ilECSServerSettings $servers)
126 {
127 $rows = array();
128 foreach ($servers->getServers() as $server_id => $server) {
129 $tmp['server_id'] = $server->getServerId();
130 $tmp['active'] = $server->isEnabled();
131
132 $rows[] = $tmp;
133 }
134 $this->setData($rows);
135 }
136}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_MONTH
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Collection of ECS settings.
Description of ilECSServerTableGUI.
fillRow($set)
Fill row @staticvar int $counter.
parse(ilECSServerSettings $servers)
Parse available servers.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
Class ilTable2GUI.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$server
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10