ILIAS  eassessment Revision 61809
 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 = 'admin';
36  const TYPE_TUTOR = 'tutor';
37  const TYPE_MEMBER = 'member';
38 
39  private $session_participants = null;
40  private $participants = array();
41  private $reg_enabled = true;
42 
50  public function __construct($a_parent_obj,$a_type = self::TYPE_ADMIN, $a_show_content = true)
51  {
52  global $lng,$ilCtrl;
53 
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('sess');
56  $this->lng->loadLanguageModule('crs');
57  $this->lng->loadLanguageModule('trac');
58  $this->ctrl = $ilCtrl;
59 
60  parent::__construct($a_parent_obj,'members');
61 
62  $this->setFormName('participants');
63 
64  switch($a_type)
65  {
66  case self::TYPE_ADMIN:
67  $this->setPrefix('admins');
68  break;
69  case self::TYPE_TUTOR:
70  $this->setPrefix('tutors');
71  break;
72  case self::TYPE_MEMBER:
73  $this->setPrefix('member');
74  break;
75  }
76 
77 
78 
79  if($a_show_content)
80  {
81  $this->enable('sort');
82  $this->enable('header');
83  $this->enable('numinfo');
84  $this->enable('select_all');
85  }
86  else
87  {
88  $this->disable('content');
89  $this->disable('header');
90  $this->disable('footer');
91  $this->disable('numinfo');
92  $this->disable('select_all');
93  }
94 
95  $this->session_participants = new ilEventParticipants($this->getParentObject()->object->getId());
96  }
97 
105  public function enableRegistration($a_status)
106  {
107  $this->reg_enabled = $a_status;
108  }
109 
116  public function isRegistrationEnabled()
117  {
118  return $this->reg_enabled;
119  }
120 
128  public function setParticipants($a_part)
129  {
130  $this->participants = $a_part;
131  }
132 
139  public function getParticipants()
140  {
141  return $this->participants;
142  }
143 
150  public function parse()
151  {
152  $this->init();
153 
154  foreach($this->getParticipants() as $participant_id)
155  {
156  $usr_data = $this->session_participants->getUser($participant_id);
157 
158  $tmp_data['id'] = $participant_id;
159  $name = ilObjUser::_lookupName($participant_id);
160 
161  $tmp_data['name'] = $name['lastname'];
162  $tmp_data['lastname'] = $name['lastname'];
163  $tmp_data['firstname'] = $name['firstname'];
164  $tmp_data['login'] = ilObjUser::_lookupLogin($participant_id);
165  $tmp_data['mark'] = $usr_data['mark'];
166  $tmp_data['comment'] = $usr_data['comment'];
167  $tmp_data['participated'] = $this->session_participants->hasParticipated($participant_id);
168  $tmp_data['registered'] = $this->session_participants->isRegistered($participant_id);
169 
170  $part[] = $tmp_data;
171  }
172  $this->setData($part ? $part : array());
173  }
174 
181  public function fillRow($a_set)
182  {
183  $this->tpl->setVariable('VAL_ID',$a_set['id']);
184  $this->tpl->setVariable('LASTNAME',$a_set['lastname']);
185  $this->tpl->setVariable('FIRSTNAME',$a_set['firstname']);
186  $this->tpl->setVariable('LOGIN',$a_set['login']);
187  $this->tpl->setVariable('MARK',$a_set['mark']);
188  $this->tpl->setVariable('COMMENT',$a_set['comment']);
189  $this->tpl->setVariable('PART_CHECKED',$a_set['participated'] ? 'checked="checked"' : '');
190 
191  if($this->isRegistrationEnabled())
192  {
193  $this->tpl->setCurrentBlock('registered_col');
194  if($a_set['registered'])
195  {
196  $this->tpl->setVariable('IMAGE_REGISTERED',ilUtil::getImagePath('icon_ok.gif'));
197  $this->tpl->setVariable('REGISTERED',$this->lng->txt('event_registered'));
198  }
199  else
200  {
201  $this->tpl->setVariable('IMAGE_REGISTERED',ilUtil::getImagePath('icon_not_ok.gif'));
202  $this->tpl->setVariable('REGISTERED',$this->lng->txt('event_not_registered'));
203  }
204  $this->tpl->parseCurrentBlock();
205  }
206  }
207 
208 
216  protected function init()
217  {
218  $this->setFormName('participants');
219  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(),'members'));
220 
221  $this->addColumn($this->lng->txt('lastname'),'name','30%');
222  $this->addColumn($this->lng->txt('trac_mark'),'mark');
223  $this->addColumn($this->lng->txt('trac_comment'),'comment');
224  if($this->isRegistrationEnabled())
225  {
226  $this->addColumn($this->lng->txt('event_tbl_registered'),'registered');
227  }
228  $this->addColumn($this->lng->txt('event_tbl_participated'),'participated');
229  $this->setRowTemplate("tpl.sess_members_row.html","Modules/Session");
230  $this->setDefaultOrderField('name');
231  }
232 }
233 ?>