ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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 $ilAccess;
31  $this->setTitle($this->lng->txt('ecs_available_ecs'));
32  $this->setRowTemplate('tpl.ecs_server_row.html', 'Services/WebServices/ECS');
33 
34  $this->addColumn($this->lng->txt('ecs_tbl_active'), '', '1%');
35  $this->addColumn($this->lng->txt('title'), '', '80%');
36 
37  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
38  $this->addColumn($this->lng->txt('actions'), '', '19%');
39  }
40  }
41 
47  public function fillRow($set)
48  {
49  global $ilCtrl, $ilAccess;
50 
51  $ilCtrl->setParameter($this->getParentObject(), 'server_id', $set['server_id']);
52  $ilCtrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $set['server_id']);
53 
54  if ($set['active']) {
55  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg'));
56  $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
57  } else {
58  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_not_ok.svg'));
59  $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated'));
60  }
61 
62  $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($set['server_id'])->getTitle());
63  $this->tpl->setVariable('LINK_EDIT', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
64  $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr'));
65 
66  if (ilECSSetting::getInstanceByServerId($set['server_id'])->getServer()) {
67  $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($set['server_id'])->getServer());
68  } else {
69  $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
70  }
71 
72  $dt = ilECSSetting::getInstanceByServerId($set['server_id'])->fetchCertificateExpiration();
73  if ($dt != null) {
74  $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
75 
76  $now = new ilDateTime(time(), IL_CAL_UNIX);
77  $now->increment(IL_CAL_MONTH, 2);
78 
79  if (ilDateTime::_before($dt, $now)) {
80  $this->tpl->setCurrentBlock('invalid');
81  $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
82  $this->tpl->parseCurrentBlock();
83  } else {
84  $this->tpl->setCurrentBlock('valid');
85  $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
86  $this->tpl->parseCurrentBlock();
87  }
88  }
89 
90  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
91  // Actions
92  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
94  $list->setSelectionHeaderClass('small');
95  $list->setItemLinkClass('small');
96  $list->setId('actl_' . $set['server_id']);
97  $list->setListTitle($this->lng->txt('actions'));
98 
99  if (ilECSSetting::getInstanceByServerId($set['server_id'])->isEnabled()) {
100  $list->addItem($this->lng->txt('ecs_deactivate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'deactivate'));
101  } else {
102  $list->addItem($this->lng->txt('ecs_activate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'activate'));
103  }
104 
105  $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
106  $list->addItem($this->lng->txt('copy'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'cp'));
107  $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'delete'));
108 
109  $this->tpl->setCurrentBlock("actions");
110  $this->tpl->setVariable('ACTIONS', $list->getHTML());
111  $this->tpl->parseCurrentBlock();
112  }
113  $ilCtrl->clearParameters($this->getParentObject());
114  }
115 
120  public function parse(ilECSServerSettings $servers)
121  {
122  $rows = array();
123  foreach ($servers->getServers() as $server_id => $server) {
124  $tmp['server_id'] = $server->getServerId();
125  $tmp['active'] = $server->isEnabled();
126 
127  $rows[] = $tmp;
128  }
129  $this->setData($rows);
130  }
131 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
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.
parse(ilECSServerSettings $servers)
Parse available servers.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
fillRow($set)
Fill row int $counter.
const IL_CAL_MONTH
const IL_CAL_UNIX
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
Collection of ECS settings.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
Date and time handling
Description of ilECSServerTableGUI.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
$server
Definition: getUserInfo.php:12
$rows
Definition: xhr_table.php:10
User interface class for advanced drop-down selection lists.
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.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.