ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
39  $this->addColumn($this->lng->txt('actions'), '', '19%');
40  }
41 
42  }
43 
49  public function fillRow($set)
50  {
51  global $ilCtrl, $ilAccess;
52 
53  $ilCtrl->setParameter($this->getParentObject(),'server_id',$set['server_id']);
54  $ilCtrl->setParameterByClass('ilecsmappingsettingsgui','server_id',$set['server_id']);
55 
56  if($set['active'])
57  {
58  $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg'));
59  $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
60  }
61  else
62  {
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  {
73  $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($set['server_id'])->getServer());
74  }
75  else
76  {
77  $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
78  }
79 
80  $dt = ilECSSetting::getInstanceByServerId($set['server_id'])->fetchCertificateExpiration();
81  if($dt != NULL)
82  {
83  $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
84 
85  $now = new ilDateTime(time(),IL_CAL_UNIX);
86  $now->increment(IL_CAL_MONTH, 2);
87 
88  if(ilDateTime::_before($dt, $now))
89  {
90  $this->tpl->setCurrentBlock('invalid');
91  $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
92  $this->tpl->parseCurrentBlock();
93  }
94  else
95  {
96  $this->tpl->setCurrentBlock('valid');
97  $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
98  $this->tpl->parseCurrentBlock();
99  }
100  }
101 
102  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
103  {
104  // Actions
105  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
106  $list = new ilAdvancedSelectionListGUI();
107  $list->setSelectionHeaderClass('small');
108  $list->setItemLinkClass('small');
109  $list->setId('actl_'.$set['server_id']);
110  $list->setListTitle($this->lng->txt('actions'));
111 
112  if(ilECSSetting::getInstanceByServerId($set['server_id'])->isEnabled())
113  {
114  $list->addItem($this->lng->txt('ecs_deactivate'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'deactivate'));
115  }
116  else
117  {
118  $list->addItem($this->lng->txt('ecs_activate'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'activate'));
119  }
120 
121  $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'edit'));
122  $list->addItem($this->lng->txt('copy'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'cp'));
123  $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'delete'));
124 
125  $this->tpl->setCurrentBlock("actions");
126  $this->tpl->setVariable('ACTIONS',$list->getHTML());
127  $this->tpl->parseCurrentBlock();
128  }
129  $ilCtrl->clearParameters($this->getParentObject());
130  }
131 
136  public function parse(ilECSServerSettings $servers)
137  {
138  $rows = array();
139  foreach($servers->getServers() as $server_id => $server)
140  {
141  $tmp['server_id'] = $server->getServerId();
142  $tmp['active'] = $server->isEnabled();
143 
144  $rows[] = $tmp;
145  }
146  $this->setData($rows);
147  }
148 
149 }
150 ?>
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.
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)
static formatDate(ilDateTime $date)
Format a date public.
__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.
User interface class for advanced drop-down selection lists.
$server
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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.