ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseEditParticipantsTableGUI.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 
35 {
36  public $container = null;
37 
46  private $localCourseRoles = null;
47 
55  public function __construct($a_parent_obj)
56  {
57  global $lng,$ilCtrl;
58 
59  $this->lng = $lng;
60  $this->lng->loadLanguageModule('crs');
61  $this->ctrl = $ilCtrl;
62 
63  $this->container = $a_parent_obj;
64 
65  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
66  $this->privacy = ilPrivacySettings::_getInstance();
67 
68  $this->participants = ilCourseParticipants::_getInstanceByObjId($a_parent_obj->object->getId());
69 
70  parent::__construct($a_parent_obj,'editMembers');
71  $this->setFormName('participants');
72  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
73 
74  $this->addColumn($this->lng->txt('name'),'name','20%');
75  $this->addColumn($this->lng->txt('login'),'login','25%');
76 
77  if($this->privacy->enabledCourseAccessTimes())
78  {
79  $this->addColumn($this->lng->txt('last_access'),'access_time');
80  }
81  $this->addColumn($this->lng->txt('crs_passed'),'passed');
82  $this->addColumn($this->lng->txt('crs_blocked'),'blocked');
83  $this->addColumn($this->lng->txt('crs_notification'),'notification');
84  $this->addColumn($this->lng->txt('objs_role'),'roles');
85 
86  $this->addCommandButton('updateMembers',$this->lng->txt('save'));
87  $this->addCommandButton('members',$this->lng->txt('cancel'));
88 
89  $this->setRowTemplate("tpl.edit_participants_row.html","Modules/Course");
90 
91  $this->disable('sort');
92  $this->enable('header');
93  $this->enable('numinfo');
94  $this->disable('select_all');
95 
96  // Performance improvement: We read the local course roles
97  // only once, instead of reading them for each row in method fillRow().
98  $this->localCourseRoles = array();
99  foreach($this->container->object->getLocalCourseRoles(false) as $title => $role_id)
100  {
101  $this->localCourseRoles[ilObjRole::_getTranslation($title)] = array('role_id'=>$role_id, 'title'=>$title);
102  }
103  }
104 
111  public function fillRow($a_set)
112  {
113  global $rbacsystem, $ilAccess, $ilUser;
114  $hasEditPermissionAccess =
115  (
116  $ilAccess->checkAccess('edit_permission', '',$this->container->object->getRefId()) or
117  $this->participants->isAdmin($ilUser->getId())
118  );
119 
120  $this->tpl->setVariable('VAL_ID',$a_set['usr_id']);
121  $this->tpl->setVariable('VAL_NAME',$a_set['lastname'].', '.$a_set['firstname']);
122 
123  $this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
124 
125  if($this->privacy->enabledCourseAccessTimes())
126  {
127  $this->tpl->setVariable('VAL_ACCESS',$a_set['access_time']);
128  }
129  $this->tpl->setVariable('VAL_NOTIFICATION_CHECKED',$a_set['notification'] ? 'checked="checked"' : '');
130  $this->tpl->setVariable('VAL_PASSED_CHECKED',$a_set['passed'] ? 'checked="checked"' : '');
131  $this->tpl->setVariable('VAL_BLOCKED_CHECKED',$a_set['blocked'] ? 'checked="checked"' : '');
132 
133  $this->tpl->setVariable('NUM_ROLES',count($this->participants->getRoles()));
134 
135  $assigned = $this->participants->getAssignedRoles($a_set['usr_id']);
136  foreach($this->localCourseRoles as $localizedTitle => $roleData)
137  {
138  if ($hasEditPermissionAccess || substr($roleData['title'], 0, 12) != 'il_crs_admin')
139  {
140  $this->tpl->setCurrentBlock('roles');
141  $this->tpl->setVariable('ROLE_ID',$roleData['role_id']);
142  $this->tpl->setVariable('ROLE_NAME',$localizedTitle);
143 
144  if(in_array($roleData['role_id'],$assigned))
145  {
146  $this->tpl->setVariable('ROLE_CHECKED','selected="selected"');
147  }
148  $this->tpl->parseCurrentBlock();
149  }
150  }
151  }
152 }
153 ?>