ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
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  $this->addColumn('', 'actions','10%');
68  $this->disable('form');
69  $this->setRowTemplate("tpl.participant_row.html","Services/WebServices/ECS");
70  $this->setDefaultOrderField('participants');
71  $this->setDefaultOrderDirection("desc");
72 
73  $this->cid = $cid;
74  $this->server = $set;
75  }
76 
81  public function getServer()
82  {
83  return $this->server;
84  }
85 
93  public function fillRow($a_set)
94  {
95  global $ilCtrl;
96 
97  $this->tpl->setVariable('S_ID', $this->getServer()->getServerId());
98  $this->tpl->setVariable('M_ID', $a_set['mid']);
99  $this->tpl->setVariable('VAL_ID', $this->getServer()->getServerId().'_'.$a_set['mid']);
100  $this->tpl->setVariable('VAL_ORG', (string) $a_set['org']);
101  $this->tpl->setVariable('VAL_CHECKED',$a_set['checked'] ? 'checked="checked"' : '');
102  $this->tpl->setVariable('VAL_TITLE',$a_set['participants']);
103  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
104  $this->tpl->setVariable('VAL_EMAIL',$a_set['email']);
105  $this->tpl->setVariable('VAL_DNS',$a_set['dns']);
106  $this->tpl->setVariable('VAL_ABR',$a_set['abr']);
107  $this->tpl->setVariable('TXT_EMAIL',$this->lng->txt('ecs_email'));
108  $this->tpl->setVariable('TXT_DNS',$this->lng->txt('ecs_dns'));
109  $this->tpl->setVariable('TXT_ABR',$this->lng->txt('ecs_abr'));
110  $this->tpl->setVariable('TXT_ID',$this->lng->txt('ecs_unique_id'));
111  $this->tpl->setVariable('TXT_ORG', $this->lng->txt('organization'));
112 
113  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
114  $part = new ilECSParticipantSetting($this->getServer()->getServerId(), $a_set['mid']);
115  if($part->isExportEnabled())
116  {
117  $this->tpl->setVariable('EXP_CHECKED', 'checked="checked"');
118  }
119  if($part->isImportEnabled())
120  {
121  $this->tpl->setVariable('IMP_CHECKED', 'checked="checked"');
122  }
123 
124  // :TODO: what types are to be supported?
125  $sel = ilUtil::formSelect(
126  $part->getImportType(),
127  'import_type['.$this->getServer()->getServerId().']['.$a_set['mid'].']',
128  array(
129  ilECSParticipantSetting::IMPORT_RCRS => $this->lng->txt('obj_rcrs'),
130  ilECSParticipantSetting::IMPORT_CRS => $this->lng->txt('obj_crs'),
131  ilECSParticipantSetting::IMPORT_CMS => $this->lng->txt('ecs_import_cms')
132  ),
133  false,
134  true
135  );
136  $this->tpl->setVariable('IMPORT_SEL', $sel);
137 
138  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
139  $list = new ilAdvancedSelectionListGUI();
140  $list->setItemLinkClass('small');
141  $list->setSelectionHeaderClass('small');
142  $list->setId('actl_'.$a_set['server_id'].'_'.$a_set['mid']);
143  $list->setListTitle($this->lng->txt('actions'));
144 
145  switch($part->getImportType())
146  {
148  // Do nothing
149  break;
150 
152  // Possible action => Edit course allocation
153  $ilCtrl->setParameter($this->getParentObject(),'server_id',$this->getServer()->getServerId());
154  $ilCtrl->setParameter($this->getParentObject(),'mid',$a_set['mid']);
155  $list->addItem(
156  $this->lng->txt('ecs_crs_alloc_set'),
157  '',
158  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','cStart')
159  );
160  $this->tpl->setVariable('ACTIONS',$list->getHTML());
161  break;
162 
164 
165  $ilCtrl->setParameter($this->getParentObject(),'server_id',$this->getServer()->getServerId());
166  $ilCtrl->setParameter($this->getParentObject(),'mid',$a_set['mid']);
167  // Possible action => Edit course allocation, edit node mapping
168  $list->addItem(
169  $this->lng->txt('ecs_dir_alloc_set'),
170  '',
171  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','dStart')
172  );
173  $list->addItem(
174  $this->lng->txt('ecs_crs_alloc_set'),
175  '',
176  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','cStart')
177  );
178  $this->tpl->setVariable('ACTIONS',$list->getHTML());
179  break;
180  }
181 
182 
183 
184 
185  }
186 
194  public function parse($a_participants)
195  {
196  foreach($a_participants as $participant)
197  {
198  $tmp_arr['mid'] = $participant->getMID();
199  $tmp_arr['participants'] = $participant->getParticipantName();
200  $tmp_arr['description'] = $participant->getDescription();
201  $tmp_arr['email'] = $participant->getEmail();
202  $tmp_arr['dns'] = $participant->getDNS();
203 
204  if($participant->getOrganisation() instanceof ilECSOrganisation)
205  {
206  $tmp_arr['abr'] = $participant->getOrganisation()->getAbbreviation();
207  $tmp_arr['org'] = $participant->getOrganisation()->getName();
208  }
209  $def[] = $tmp_arr;
210  }
211 
212  $this->setData($def ? $def : array());
213  }
214 
215 }
216 
217 
218 ?>