ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCourseMembershipGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once './Services/Membership/classes/class.ilMembershipGUI.php';
6
19{
23 protected function getMailMemberRoles()
24 {
25 return new ilMailMemberCourseRoles();
26 }
27
33 public function filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
34 {
35 return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
36 'manage_members',
37 'manage_members',
38 $this->getParentObject()->getRefId(),
39 $a_user_ids
40 );
41 }
42
46 protected function getMailContextOptions()
47 {
48 $context_options = [];
49
50 $context_options =
51 [
53 'ref_id' => $this->getParentObject()->getRefId(),
54 'ts' => time()
55 ];
56 return $context_options;
57 }
58
64 {
65 ilUtil::sendQuestion($this->lng->txt('crs_ref_delete_confirmation_info'));
66
67 $table = new ilCourseReferenceDeleteConfirmationTableGUI($this, $this->getParentObject(), 'confirmDeleteParticipants');
68 $table->init();
69 $table->setParticipants($participants);
70 $table->parse();
71
72 $this->tpl->setContent($table->getHTML());
73 }
74
75
80 {
81 global $DIC;
82
83 $ilAccess = $DIC['ilAccess'];
84
85 $participants = (array) $_POST['participants'];
86
87 if (!is_array($participants) or !count($participants)) {
88 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
89 $this->ctrl->redirect($this, 'participants');
90 }
91
92 // If the user doesn't have the edit_permission and is not administrator, he may not remove
93 // members who have the course administrator role
94 if (
95 !$ilAccess->checkAccess('edit_permission', '', $this->getParentObject()->getRefId()) &&
96 !$this->getMembersObject()->isAdmin($GLOBALS['DIC']['ilUser']->getId())
97 ) {
98 foreach ($participants as $part) {
99 if ($this->getMembersObject()->isAdmin($part)) {
100 ilUtil::sendFailure($this->lng->txt('msg_no_perm_perm'), true);
101 $this->ctrl->redirect($this, 'participants');
102 }
103 }
104 }
105
106 if (!$this->getMembersObject()->deleteParticipants($participants)) {
107 ilUtil::sendFailure('Error deleting participants.', true);
108 $this->ctrl->redirect($this, 'participants');
109 } else {
110 foreach ((array) $_POST["participants"] as $usr_id) {
111 $mail_type = 0;
112 switch ($this->getParentObject()->getType()) {
113 case 'crs':
114 $mail_type = $this->getMembersObject()->NOTIFY_DISMISS_MEMBER;
115 break;
116 }
117 $this->getMembersObject()->sendNotification($mail_type, $usr_id);
118 }
119 }
120
121 // Delete course reference assignments
122 if (count((array) $_POST['refs'])) {
123 foreach ($_POST['refs'] as $usr_id => $usr_info) {
124 foreach ((array) $usr_info as $course_ref_id => $tmp) {
125 $part = ilParticipants::getInstance($course_ref_id);
126 $part->delete($usr_id);
127 }
128 }
129 }
130
131 ilUtil::sendSuccess($this->lng->txt($this->getParentObject()->getType() . "_members_deleted"), true);
132 $this->ctrl->redirect($this, "participants");
133
134 return true;
135 }
136
137
145 public function assignMembers(array $a_usr_ids, $a_type)
146 {
147 global $DIC;
148
149 $rbacsystem = $DIC['rbacsystem'];
150 $ilErr = $DIC['ilErr'];
151
152 if (!$this->checkRbacOrPositionAccessBool('manage_members', 'manage_members')) {
153 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->FATAL);
154 }
155
156 if (!count($a_usr_ids)) {
157 ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"), true);
158 return false;
159 }
160
161 $a_usr_ids = $this->filterUserIdsByRbacOrPositionOfCurrentUser($a_usr_ids);
162
163 $added_users = 0;
164 foreach ($a_usr_ids as $user_id) {
165 if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false)) {
166 continue;
167 }
168 if ($this->getMembersObject()->isAssigned($user_id)) {
169 continue;
170 }
171 switch ($a_type) {
172 case $this->getParentObject()->getDefaultMemberRole():
173 $this->getMembersObject()->add($user_id, IL_CRS_MEMBER);
174 break;
175 case $this->getParentObject()->getDefaultTutorRole():
176 $this->getMembersObject()->add($user_id, IL_CRS_TUTOR);
177 break;
178 case $this->getParentObject()->getDefaultAdminRole():
179 $this->getMembersObject()->add($user_id, IL_CRS_ADMIN);
180 break;
181 default:
182 if (in_array($a_type, $this->getParentObject()->getLocalCourseRoles(true))) {
183 $this->getMembersObject()->add($user_id, IL_CRS_MEMBER);
184 $this->getMembersObject()->updateRoleAssignments($user_id, (array) $a_type);
185 } else {
186 ilLoggerFactory::getLogger('crs')->notice('Can\'t find role with id .' . $a_type . ' to assign users.');
187 ilUtil::sendFailure($this->lng->txt("crs_cannot_find_role"), true);
188 return false;
189 }
190 break;
191 }
192 $this->getMembersObject()->sendNotification($this->getMembersObject()->NOTIFY_ACCEPT_USER, $user_id);
193
194 $this->getParentObject()->checkLPStatusSync($user_id);
195
196 ++$added_users;
197 }
198 if ($added_users) {
199 ilUtil::sendSuccess($this->lng->txt("crs_users_added"), true);
200 $this->ctrl->redirect($this, 'participants');
201 }
202 ilUtil::sendFailure($this->lng->txt("crs_users_already_assigned"), true);
203 return false;
204 }
205
209 protected function updateParticipantsStatus()
210 {
211 global $DIC;
212
213 $ilAccess = $DIC['ilAccess'];
214 $ilErr = $DIC['ilErr'];
215 $ilUser = $DIC['ilUser'];
216 $rbacadmin = $DIC['rbacadmin'];
217
218 $visible_members = (array) $_POST['visible_member_ids'];
219 $passed = (array) $_POST['passed'];
220 $blocked = (array) $_POST['blocked'];
221 $contact = (array) $_POST['contact'];
222 $notification = (array) $_POST['notification'];
223
224 foreach ($visible_members as $member_id) {
225 if ($ilAccess->checkAccess("grade", "", $this->getParentObject()->getRefId())) {
226 $this->getMembersObject()->updatePassed($member_id, in_array($member_id, $passed), true);
227 $this->updateLPFromStatus($member_id, in_array($member_id, $passed));
228 }
229
230 if ($this->getMembersObject()->isAdmin($member_id) or $this->getMembersObject()->isTutor($member_id)) {
231 // remove blocked
232 $this->getMembersObject()->updateBlocked($member_id, 0);
233 $this->getMembersObject()->updateNotification($member_id, in_array($member_id, $notification));
234 $this->getMembersObject()->updateContact($member_id, in_array($member_id, $contact));
235 } else {
236 // send notifications => unblocked
237 if ($this->getMembersObject()->isBlocked($member_id) && !in_array($member_id, $blocked)) {
238 $this->getMembersObject()->sendNotification($this->getMembersObject()->NOTIFY_UNBLOCK_MEMBER, $member_id);
239 }
240 // => blocked
241 if (!$this->getMembersObject()->isBlocked($member_id) && in_array($member_id, $blocked)) {
242 $this->getMembersObject()->sendNotification($this->getMembersObject()->NOTIFY_BLOCK_MEMBER, $member_id);
243 }
244
245 // normal member => remove notification, contact
246 $this->getMembersObject()->updateNotification($member_id, false);
247 $this->getMembersObject()->updateContact($member_id, false);
248 $this->getMembersObject()->updateBlocked($member_id, in_array($member_id, $blocked));
249 }
250 }
251
252
253 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
254 $this->ctrl->redirect($this, 'participants');
255 }
256
257
261 protected function initParticipantTableGUI()
262 {
263 include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
264 $show_tracking =
266 ;
267 if ($show_tracking) {
268 include_once('./Services/Object/classes/class.ilObjectLP.php');
269 $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
270 $show_tracking = $olp->isActive();
271 }
272
273 include_once('./Services/Object/classes/class.ilObjectActivation.php');
274 $timings_enabled =
275 (ilObjectActivation::hasTimings($this->getParentObject()->getRefId()) && ($this->getParentObject()->getViewMode() == IL_CRS_VIEW_TIMING))
276 ;
277
278
279 include_once './Modules/Course/classes/class.ilCourseParticipantsTableGUI.php';
281 $this,
282 $this->getParentObject(),
283 $show_tracking,
284 $timings_enabled,
285 $this->getParentObject()->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP
286 );
287 }
288
294 protected function initEditParticipantTableGUI(array $participants)
295 {
296 include_once './Modules/Course/classes/class.ilCourseEditParticipantsTableGUI.php';
297 $table = new ilCourseEditParticipantsTableGUI($this, $this->getParentObject());
298 $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
299 $table->setData($this->getParentGUI()->readMemberData($participants));
300
301 return $table;
302 }
303
307 protected function initParticipantTemplate()
308 {
309 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.crs_edit_members.html', 'Modules/Course');
310 }
311
315 public function getLocalTypeRole($a_translation = false)
316 {
317 return $this->getParentObject()->getLocalCourseRoles($a_translation);
318 }
319
323 protected function updateLPFromStatus($a_member_id, $a_passed)
324 {
325 return $this->getParentGUI()->updateLPFromStatus($a_member_id, $a_passed);
326 }
327
332 protected function initWaitingList()
333 {
334 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
335 $wait = new ilCourseWaitingList($this->getParentObject()->getId());
336 return $wait;
337 }
338
342 protected function getDefaultRole()
343 {
344 return $this->getParentGUI()->object->getDefaultMemberRole();
345 }
346
351 protected function deliverCertificate()
352 {
353 return $this->getParentGUI()->deliverCertificateObject();
354 }
355
360 protected function getPrintMemberData($a_members)
361 {
362 global $DIC;
363
364 $ilAccess = $DIC['ilAccess'];
365 $lng = $DIC['lng'];
366
367 $lng->loadLanguageModule('trac');
368
369 $is_admin = true;
370 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
372
373 if ($privacy->enabledCourseAccessTimes()) {
374 include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
375 $progress = ilLearningProgress::_lookupProgressByObjId($this->getParentObject()->getId());
376 }
377
378 include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
379 $show_tracking =
381 if ($show_tracking) {
382 include_once('./Services/Object/classes/class.ilObjectLP.php');
383 $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
384 $show_tracking = $olp->isActive();
385 }
386
387 if ($show_tracking) {
388 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
390 $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->getParentObject()->getId());
392 }
393
394 $profile_data = ilObjUser::_readUsersProfileData($a_members);
395
396 // course defined fields
397 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
398 $cdfs = ilCourseUserData::_getValuesByObjId($this->getParentObject()->getId());
399
400 $print_member = [];
401 foreach ($a_members as $member_id) {
402 // GET USER OBJ
403 if ($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id, false)) {
404 // udf
405 include_once './Services/User/classes/class.ilUserDefinedData.php';
406 $udf_data = new ilUserDefinedData($member_id);
407 foreach ($udf_data->getAll() as $field => $value) {
408 list($f, $field_id) = explode('_', $field);
409 $print_member[$member_id]['udf_' . $field_id] = (string) $value;
410 }
411
412 foreach ((array) $cdfs[$member_id] as $cdf_field => $cdf_value) {
413 $print_member[$member_id]['cdf_' . $cdf_field] = (string) $cdf_value;
414 }
415
416 foreach ((array) $profile_data[$member_id] as $field => $value) {
417 $print_member[$member_id][$field] = $value;
418 }
419
420 $print_member[$member_id]['login'] = $tmp_obj->getLogin();
421 $print_member[$member_id]['name'] = $tmp_obj->getLastname() . ', ' . $tmp_obj->getFirstname();
422
423 if ($this->getMembersObject()->isAdmin($member_id)) {
424 $print_member[$member_id]['role'] = $this->lng->txt("il_crs_admin");
425 } elseif ($this->getMembersObject()->isTutor($member_id)) {
426 $print_member[$member_id]['role'] = $this->lng->txt("il_crs_tutor");
427 } elseif ($this->getMembersObject()->isMember($member_id)) {
428 $print_member[$member_id]['role'] = $this->lng->txt("il_crs_member");
429 }
430 if ($this->getMembersObject()->isAdmin($member_id) or $this->getMembersObject()->isTutor($member_id)) {
431 if ($this->getMembersObject()->isNotificationEnabled($member_id)) {
432 $print_member[$member_id]['status'] = $this->lng->txt("crs_notify");
433 } else {
434 $print_member[$member_id]['status'] = $this->lng->txt("crs_no_notify");
435 }
436 } else {
437 if ($this->getMembersObject()->isBlocked($member_id)) {
438 $print_member[$member_id]['status'] = $this->lng->txt("crs_blocked");
439 } else {
440 $print_member[$member_id]['status'] = $this->lng->txt("crs_unblocked");
441 }
442 }
443
444 if ($is_admin) {
445 $print_member[$member_id]['passed'] = $this->getMembersObject()->hasPassed($member_id) ?
446 $this->lng->txt('crs_member_passed') :
447 $this->lng->txt('crs_member_not_passed');
448 }
449 if ($privacy->enabledCourseAccessTimes()) {
450 if (isset($progress[$member_id]['ts']) and $progress[$member_id]['ts']) {
452 $print_member[$member_id]['access'] = ilDatePresentation::formatDate(new ilDateTime($progress[$member_id]['ts'], IL_CAL_UNIX));
454 } else {
455 $print_member[$member_id]['access'] = $this->lng->txt('no_date');
456 }
457 }
458 if ($show_tracking) {
459 if (in_array($member_id, $completed)) {
460 $print_member[$member_id]['progress'] = $this->lng->txt(ilLPStatus::LP_STATUS_COMPLETED);
461 } elseif (in_array($member_id, $in_progress)) {
462 $print_member[$member_id]['progress'] = $this->lng->txt(ilLPStatus::LP_STATUS_IN_PROGRESS);
463 } elseif (in_array($member_id, $failed)) {
464 $print_member[$member_id]['progress'] = $this->lng->txt(ilLPStatus::LP_STATUS_FAILED);
465 } else {
466 $print_member[$member_id]['progress'] = $this->lng->txt(ilLPStatus::LP_STATUS_NOT_ATTEMPTED);
467 }
468 }
469 }
470 }
471 return ilUtil::sortArray($print_member, 'name', $_SESSION['crs_print_order'], false, true);
472 }
473
478 public function getAttendanceListUserData($a_user_id)
479 {
480 if (is_array($this->member_data) && array_key_exists($a_user_id, $this->member_data)) {
481 return $this->member_data[$a_user_id];
482 }
483 return [];
484 }
485}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$failed
Definition: Utf8Test.php:85
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CRS_VIEW_TIMING
const IL_CAL_UNIX
const IL_CRS_ADMIN
Base class for course and group participants.
const IL_CRS_MEMBER
const IL_CRS_TUTOR
showDeleteParticipantsConfirmationWithLinkedCourses($participants)
Show deletion confirmation with linked courses.
getAttendanceListUserData($a_user_id)
Callback from attendance list.
getMailContextOptions()
Get mail context options.array
filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
Filter user ids by access.
getPrintMemberData($a_members)
Get print member data.
initParticipantTemplate()
Init participant view template.
deliverCertificate()
Deliver certificate for an user on the member list.
updateParticipantsStatus()
=> save button in member table
initEditParticipantTableGUI(array $participants)
init edit participants table gui
getLocalTypeRole($a_translation=false)
assignMembers(array $a_usr_ids, $a_type)
callback from repository search gui @global ilRbacSystem $rbacsystem
updateLPFromStatus($a_member_id, $a_passed)
Update lp from status.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static _lookupProgressByObjId($a_obj_id)
lookup progress for a specific object
static getLogger($a_component_id)
Get component logger.
const CONTEXT_KEY
Session parameter for the context.
Class ilMailMemberCourseRoles.
Base class for member tab content.
getParentGUI()
Get parent gui.
checkRbacOrPositionAccessBool($a_rbac_perm, $a_pos_perm, $a_ref_id=0)
Check if rbac or position access is granted.
getParentObject()
Get parent object.
getMembersObject()
Get member object.
readMemberData(array $usr_ids, array $columns)
Required for member table guis.
const STATUS_DETERMINATION_LP
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
static hasTimings($a_ref_id)
Check if there is any active timing (in subtree)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance($a_obj_id)
static getInstance($a_ref_id)
Get instance by ref_id.
static _getInstance()
Get instance of ilPrivacySettings.
Class ilUserDefinedData.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ilErr
Definition: raiseError.php:18
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46