ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSessionParticipantsTableGUI.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 
34 {
35  const TYPE_ADMIN = 'admins';
36  const TYPE_TUTOR = 'tutors';
37  const TYPE_MEMBER = 'members';
38 
39  private $role_type = '';
40 
41  private $session_participants = null;
42  private $participants = array();
43  private $reg_enabled = true;
44 
52  public function __construct($a_parent_obj,$a_type = self::TYPE_ADMIN, $a_show_content = true)
53  {
54  global $lng,$ilCtrl;
55 
56  $this->lng = $lng;
57  $this->lng->loadLanguageModule('sess');
58  $this->lng->loadLanguageModule('crs');
59  $this->lng->loadLanguageModule('trac');
60  $this->ctrl = $ilCtrl;
61 
62  $this->role_type = $a_type;
63 
64 
65  $this->setId('sess_'.$a_type.'_'.$a_parent_obj->object->getId());
66 
67  switch($a_type)
68  {
69  case self::TYPE_ADMIN:
70  $this->setPrefix('admins');
71  break;
72  case self::TYPE_TUTOR:
73  $this->setPrefix('tutors');
74  break;
75  case self::TYPE_MEMBER:
76  $this->setPrefix('member');
77  break;
78  }
79 
80  parent::__construct($a_parent_obj,'members');
81 
82  $this->setFormName('participants');
83 
84 
85  $this->setSelectAllCheckbox($this->getRoleType());
86  $this->setShowRowsSelector(TRUE);
87 
88  if($a_show_content)
89  {
90  $this->enable('sort');
91  $this->enable('header');
92  $this->enable('numinfo');
93  $this->enable('select_all');
94  }
95  else
96  {
97  $this->disable('content');
98  $this->disable('header');
99  $this->disable('footer');
100  $this->disable('numinfo');
101  $this->disable('select_all');
102  }
103 
104  $this->session_participants = new ilEventParticipants($this->getParentObject()->object->getId());
105  }
106 
107  public function getRoleType()
108  {
109  return $this->role_type;
110  }
111 
119  public function enableRegistration($a_status)
120  {
121  $this->reg_enabled = $a_status;
122  }
123 
130  public function isRegistrationEnabled()
131  {
132  return $this->reg_enabled;
133  }
134 
142  public function setParticipants($a_part)
143  {
144  $this->participants = $a_part;
145  }
146 
153  public function getParticipants()
154  {
155  return $this->participants;
156  }
157 
164  public function parse()
165  {
166  $this->init();
167 
168  foreach($this->getParticipants() as $participant_id)
169  {
170  $usr_data = $this->session_participants->getUser($participant_id);
171 
172  $tmp_data['id'] = $participant_id;
173  $name = ilObjUser::_lookupName($participant_id);
174 
175  $tmp_data['name'] = $name['lastname'];
176  $tmp_data['lastname'] = $name['lastname'];
177  $tmp_data['firstname'] = $name['firstname'];
178  $tmp_data['login'] = ilObjUser::_lookupLogin($participant_id);
179  $tmp_data['mark'] = $usr_data['mark'];
180  $tmp_data['comment'] = $usr_data['comment'];
181  $tmp_data['participated'] = $this->session_participants->hasParticipated($participant_id);
182  $tmp_data['registered'] = $this->session_participants->isRegistered($participant_id);
183 
184  $part[] = $tmp_data;
185  }
186  $this->setData($part ? $part : array());
187  }
188 
195  public function fillRow($a_set)
196  {
197  $this->tpl->setVariable('VAL_POSTNAME',$this->getRoleType());
198 
199  if($this->isRegistrationEnabled())
200  {
201  $this->tpl->setCurrentBlock('registered_col');
202  $this->tpl->setVariable('VAL_ID',$a_set['id']);
203  $this->tpl->setVariable('REG_CHECKED',$a_set['registered'] ? 'checked="checked"' : '');
204  $this->tpl->parseCurrentBlock();
205  }
206 
207  $this->tpl->setVariable('VAL_ID',$a_set['id']);
208  $this->tpl->setVariable('LASTNAME',$a_set['lastname']);
209  $this->tpl->setVariable('FIRSTNAME',$a_set['firstname']);
210  $this->tpl->setVariable('LOGIN',$a_set['login']);
211  $this->tpl->setVariable('MARK',$a_set['mark']);
212  $this->tpl->setVariable('COMMENT',$a_set['comment']);
213  $this->tpl->setVariable('PART_CHECKED',$a_set['participated'] ? 'checked="checked"' : '');
214  }
215 
216 
224  protected function init()
225  {
226  $this->setFormName('participants');
227  #$this->setFormAction($this->ctrl->getFormAction($this->getParentObject(),'members'));
228 
229  $this->addColumn('','f',"1");
230  $this->addColumn($this->lng->txt('name'),'name','20%');
231  $this->addColumn($this->lng->txt('login'),'login','10%');
232  if($this->isRegistrationEnabled())
233  {
234  $this->addColumn($this->lng->txt('event_tbl_registered'),'registered');
235  }
236  $this->addColumn($this->lng->txt('trac_mark'),'mark');
237  $this->addColumn($this->lng->txt('trac_comment'),'comment');
238  $this->addColumn($this->lng->txt('event_tbl_participated'),'participated');
239  $this->setRowTemplate("tpl.sess_members_row.html","Modules/Session");
240  if($this->isRegistrationEnabled())
241  {
242  $this->setDefaultOrderField('registered');
243  $this->setDefaultOrderDirection('desc');
244  }
245  else
246  {
247  $this->setDefaultOrderField('name');
248  }
249  }
250 }
251 ?>