ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilECSCommunityTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('Services/Table/classes/class.ilTable2GUI.php');
25 include_once('Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php');
26 
36 {
37  protected $lng;
38  protected $ctrl;
39 
40 
41  protected $server = null;
42  protected $cid = 0;
43 
51  public function __construct(ilECSSetting $set,$a_parent_obj,$a_parent_cmd,$cid)
52  {
53  global $lng,$ilCtrl, $ilAccess;
54 
55  $this->lng = $lng;
56  $this->ctrl = $ilCtrl;
57 
58  // TODO: set id
59  $this->setId($set->getServerId().'_'.$cid.'_'.'community_table');
60 
61  parent::__construct($a_parent_obj,$a_parent_cmd);
62  $this->addColumn($this->lng->txt('ecs_participants'),'participants',"35%");
63  $this->addColumn($this->lng->txt('ecs_participants_infos'),'infos',"35%");
64  $this->addColumn($this->lng->txt('ecs_tbl_export'),'export','5%');
65  $this->addColumn($this->lng->txt('ecs_tbl_import'),'import','5%');
66  $this->addColumn($this->lng->txt('ecs_tbl_import_type'), 'type','10%');
67 
68  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
69  {
70  $this->addColumn('', 'actions','10%');
71  }
72 
73  $this->disable('form');
74  $this->setRowTemplate("tpl.participant_row.html","Services/WebServices/ECS");
75  $this->setDefaultOrderField('participants');
76  $this->setDefaultOrderDirection("desc");
77 
78  $this->cid = $cid;
79  $this->server = $set;
80  }
81 
86  public function getServer()
87  {
88  return $this->server;
89  }
90 
98  public function fillRow($a_set)
99  {
100  global $ilCtrl, $ilAccess;
101 
102  $this->tpl->setVariable('S_ID', $this->getServer()->getServerId());
103  $this->tpl->setVariable('M_ID', $a_set['mid']);
104  $this->tpl->setVariable('VAL_ID', $this->getServer()->getServerId().'_'.$a_set['mid']);
105  $this->tpl->setVariable('VAL_ORG', (string) $a_set['org']);
106  $this->tpl->setVariable('VAL_CHECKED',$a_set['checked'] ? 'checked="checked"' : '');
107  $this->tpl->setVariable('VAL_TITLE',$a_set['participants']);
108  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
109  $this->tpl->setVariable('VAL_EMAIL',$a_set['email']);
110  $this->tpl->setVariable('VAL_DNS',$a_set['dns']);
111  $this->tpl->setVariable('VAL_ABR',$a_set['abr']);
112  $this->tpl->setVariable('TXT_EMAIL',$this->lng->txt('ecs_email'));
113  $this->tpl->setVariable('TXT_DNS',$this->lng->txt('ecs_dns'));
114  $this->tpl->setVariable('TXT_ABR',$this->lng->txt('ecs_abr'));
115  $this->tpl->setVariable('TXT_ID',$this->lng->txt('ecs_unique_id'));
116  $this->tpl->setVariable('TXT_ORG', $this->lng->txt('organization'));
117 
118  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
119  $part = new ilECSParticipantSetting($this->getServer()->getServerId(), $a_set['mid']);
120 
121 
122  if($part->isExportEnabled())
123  {
124  foreach($part->getExportTypes() as $obj_type)
125  {
126  $this->tpl->setCurrentBlock('obj_erow');
127  $this->tpl->setVariable('TXT_OBJ_EINFO',$this->lng->txt('objs_'.$obj_type));
128  $this->tpl->parseCurrentBlock();
129  }
130  }
131  else
132  {
133  $this->lng->loadLanguageModule('administration');
134  $this->tpl->setVariable('TXT_OBJ_EINFO',$this->lng->txt('disabled'));
135  }
136 
137  if($part->isImportEnabled())
138  {
139  foreach($part->getImportTypes() as $obj_type)
140  {
141  $this->tpl->setCurrentBlock('obj_irow');
142  $this->tpl->setVariable('TXT_OBJ_IINFO',$this->lng->txt('objs_'.$obj_type));
143  $this->tpl->parseCurrentBlock();
144  }
145  }
146  else
147  {
148  $this->lng->loadLanguageModule('administration');
149  $this->tpl->setVariable('TXT_OBJ_IINFO',$this->lng->txt('disabled'));
150  }
151  // :TODO: what types are to be supported?
152  $sel = ilUtil::formSelect(
153  $part->getImportType(),
154  'import_type['.$this->getServer()->getServerId().']['.$a_set['mid'].']',
155  array(
156  ilECSParticipantSetting::IMPORT_RCRS => $this->lng->txt('obj_rcrs'),
157  ilECSParticipantSetting::IMPORT_CRS => $this->lng->txt('obj_crs'),
158  ilECSParticipantSetting::IMPORT_CMS => $this->lng->txt('ecs_import_cms')
159  ),
160  false,
161  true
162  );
163  $this->tpl->setVariable('IMPORT_SEL', $sel);
164 
165  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
166  $list = new ilAdvancedSelectionListGUI();
167  $list->setItemLinkClass('small');
168  $list->setSelectionHeaderClass('small');
169  $list->setId('actl_'.$a_set['server_id'].'_'.$a_set['mid']);
170  $list->setListTitle($this->lng->txt('actions'));
171 
172  $ilCtrl->setParameter($this->getParentObject(),'server_id',$this->getServer()->getServerId());
173  $ilCtrl->setParameter($this->getParentObject(),'mid',$a_set['mid']);
174  $list->addItem(
175  $this->lng->txt('edit'),
176  '',
177  $ilCtrl->getLinkTargetByClass('ilecsparticipantsettingsgui','settings')
178  );
179 
180  switch($part->getImportType())
181  {
183  // Do nothing
184  break;
185 
187  // Possible action => Edit course allocation
188  $ilCtrl->setParameter($this->getParentObject(),'server_id',$this->getServer()->getServerId());
189  $ilCtrl->setParameter($this->getParentObject(),'mid',$a_set['mid']);
190  $list->addItem(
191  $this->lng->txt('ecs_crs_alloc_set'),
192  '',
193  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','cStart')
194  );
195  break;
196 
198 
199  $ilCtrl->setParameter($this->getParentObject(),'server_id',$this->getServer()->getServerId());
200  $ilCtrl->setParameter($this->getParentObject(),'mid',$a_set['mid']);
201  // Possible action => Edit course allocation, edit node mapping
202  $list->addItem(
203  $this->lng->txt('ecs_dir_alloc_set'),
204  '',
205  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','dStart')
206  );
207  $list->addItem(
208  $this->lng->txt('ecs_crs_alloc_set'),
209  '',
210  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','cStart')
211  );
212  break;
213  }
214 
215  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
216  {
217  $this->tpl->setCurrentBlock("actions");
218  $this->tpl->setVariable('ACTIONS',$list->getHTML());
219  $this->tpl->parseCurrentBlock();
220  }
221 
222  }
223 
231  public function parse($a_participants)
232  {
233  foreach($a_participants as $participant)
234  {
235  $tmp_arr['mid'] = $participant->getMID();
236  $tmp_arr['participants'] = $participant->getParticipantName();
237  $tmp_arr['description'] = $participant->getDescription();
238  $tmp_arr['email'] = $participant->getEmail();
239  $tmp_arr['dns'] = $participant->getDNS();
240 
241  if($participant->getOrganisation() instanceof ilECSOrganisation)
242  {
243  $tmp_arr['abr'] = $participant->getOrganisation()->getAbbreviation();
244  $tmp_arr['org'] = $participant->getOrganisation()->getName();
245  }
246  $def[] = $tmp_arr;
247  }
248 
249  $this->setData($def ? $def : array());
250  }
251 
252 }
253 
254 
255 ?>
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getServerId()
Get current server id.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
__construct(ilECSSetting $set, $a_parent_obj, $a_parent_cmd, $cid)
constructor
Class ilTable2GUI.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
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.
disable($a_module_name)
diesables particular modules of table
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.