ILIAS  Release_4_2_x_branch Revision 61807
 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  $sel = ilUtil::formSelect(
125  $part->getImportType(),
126  'import_type['.$this->getServer()->getServerId().']['.$a_set['mid'].']',
127  array(
128  ilECSParticipantSetting::IMPORT_RCRS => $this->lng->txt('obj_rcrs'),
129  ilECSParticipantSetting::IMPORT_CRS => $this->lng->txt('obj_crs'),
130  ilECSParticipantSetting::IMPORT_CMS => $this->lng->txt('ecs_import_cms')
131  ),
132  false,
133  true
134  );
135  $this->tpl->setVariable('IMPORT_SEL', $sel);
136 
137  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
138  $list = new ilAdvancedSelectionListGUI();
139  $list->setId('actl_'.$set['server_id'].'_'.$a_set['mid']);
140  $list->setListTitle($this->lng->txt('actions'));
141 
142  switch($part->getImportType())
143  {
145  // Do nothing
146  break;
147 
149  // Possible action => Edit course allocation
150  $list->addItem(
151  $this->lng->txt('ecs_crs_alloc_set'),
152  '',
153  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','dStart')
154  );
155  $this->tpl->setVariable('ACTIONS',$list->getHTML());
156  break;
157 
159  // Possible action => Edit course allocation, edit node mapping
160  $list->addItem(
161  $this->lng->txt('ecs_crs_alloc_set'),
162  '',
163  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','cStart')
164  );
165  $list->addItem(
166  $this->lng->txt('ecs_dir_alloc_set'),
167  '',
168  $ilCtrl->getLinkTargetByClass('ilecsmappingsettingsgui','dStart')
169  );
170  $this->tpl->setVariable('ACTIONS',$list->getHTML());
171  break;
172  }
173  }
174 
182  public function parse($a_participants)
183  {
184  foreach($a_participants as $participant)
185  {
186  $tmp_arr['mid'] = $participant->getMID();
187  $tmp_arr['participants'] = $participant->getParticipantName();
188  $tmp_arr['description'] = $participant->getDescription();
189  $tmp_arr['email'] = $participant->getEmail();
190  $tmp_arr['dns'] = $participant->getDNS();
191 
192  if($participant->getOrganisation() instanceof ilECSOrganisation)
193  {
194  $tmp_arr['abr'] = $participant->getOrganisation()->getAbbreviation();
195  $tmp_arr['org'] = $participant->getOrganisation()->getName();
196  }
197  $def[] = $tmp_arr;
198  }
199 
200  $this->setData($def ? $def : array());
201  }
202 
203 }
204 
205 
206 ?>