25 include_once
'./Services/Membership/classes/class.ilParticipants.php';
65 protected function __construct($a_component_name, $a_obj_id, $a_usr_id)
72 $this->obj_id = $a_obj_id;
73 $this->usr_id = $a_usr_id;
76 $this->ref_id = current($ref_ids);
78 $this->component = $a_component_name;
97 $a_membership_role_type = self::getMembershipRoleType($a_role_id);
99 switch ($a_membership_role_type) {
100 case self::MEMBERSHIP_ADMIN:
101 $update_fields = array(
'admin' => array(
'integer', $a_status ? 1 : 0));
102 $update_string = (
'admin = ' .
$ilDB->quote($a_status ? 1 : 0,
'integer'));
105 case self::MEMBERSHIP_TUTOR:
106 $update_fields = array(
'tutor' => array(
'integer', $a_status ? 1 : 0));
107 $update_string = (
'tutor = ' .
$ilDB->quote($a_status ? 1 : 0,
'integer'));
110 case self::MEMBERSHIP_MEMBER:
112 $current_status = self::lookupStatusByMembershipRoleType($a_obj_id, $a_usr_id, $a_membership_role_type);
115 $new_status = $current_status + 1;
118 $new_status = $current_status - 1;
119 if ($new_status < 0) {
124 $update_fields = array(
'member' => array(
'integer', $new_status));
125 $update_string = (
'member = ' .
$ilDB->quote($new_status,
'integer'));
129 $query =
'SELECT count(*) num FROM obj_members ' .
130 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
131 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer');
144 'obj_id' => array(
'integer',$a_obj_id),
145 'usr_id' => array(
'integer',$a_usr_id)
150 $query =
'UPDATE obj_members SET ' .
151 $update_string .
' ' .
152 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
153 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer');
158 $query =
'DELETE from obj_members ' .
159 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
160 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer') .
' ' .
161 'AND admin = ' .
$ilDB->quote(0,
'integer') .
' ' .
162 'AND tutor = ' .
$ilDB->quote(0,
'integer') .
' ' .
163 'AND member = ' .
$ilDB->quote(0,
'integer');
174 switch (substr(
$title, 0, 8)) {
177 return self::MEMBERSHIP_ADMIN;
180 return self::MEMBERSHIP_TUTOR;
184 return self::MEMBERSHIP_MEMBER;
201 $ilDB = $DIC[
'ilDB'];
203 $query =
'SELECT * FROM obj_members ' .
204 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
205 'AND usr_id = ' .
$ilDB->quote($a_usr_id) .
' ';
208 switch ($a_membership_role_type) {
209 case self::MEMBERSHIP_ADMIN:
212 case self::MEMBERSHIP_TUTOR:
215 case self::MEMBERSHIP_MEMBER:
244 return (
bool) $this->participants_status[$this->
getUserId()][
'blocked'];
254 return (
bool) $this->participants_status[$this->
getUserId()][
'contact'];
287 $rbacreview = $DIC[
'rbacreview'];
289 if ($this->numMembers === null) {
290 $this->numMembers = $rbacreview->getNumberOfAssignedUsers($this->member_roles);
304 $rbacreview = $DIC[
'rbacreview'];
305 $ilObjDataCache = $DIC[
'ilObjDataCache'];
307 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
310 $this->participants = array();
311 $this->members = $this->admins = $this->tutors = array();
312 $this->member_roles = [];
314 foreach ($this->roles as $role_id) {
315 $title = $ilObjDataCache->lookupTitle($role_id);
316 switch (substr(
$title, 0, 8)) {
318 $this->member_roles[] = $role_id;
320 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
321 $this->participants =
true;
322 $this->members =
true;
328 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
329 $this->participants =
true;
330 $this->admins =
true;
336 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
337 $this->participants =
true;
338 $this->tutors =
true;
344 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
345 $this->participants =
true;
346 $this->admins =
true;
351 $this->member_roles[] = $role_id;
353 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
354 $this->participants =
true;
355 $this->members =
true;
361 $this->member_roles[] = $role_id;
362 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
363 $this->participants =
true;
364 $this->members =
true;
379 $ilDB = $DIC[
'ilDB'];
381 $query =
"SELECT * FROM obj_members " .
382 "WHERE obj_id = " .
$ilDB->quote($this->obj_id,
'integer') .
" " .
386 $this->participants_status = array();
388 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
389 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
390 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
392 $this->participants_status[$this->
getUserId()][
'contact'] =
$row->contact;
407 public function add($a_usr_id, $a_role)
411 $rbacadmin = $DIC[
'rbacadmin'];
412 $ilLog = $DIC->logger()->mmbr();
413 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
414 $rbacreview = $DIC[
'rbacreview'];
417 if ($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $this->roles)) {
423 $this->admins =
true;
427 $this->tutors =
true;
431 $this->members =
true;
435 $this->admins =
true;
439 $this->members =
true;
443 $rbacadmin->assignUser($this->role_data[$a_role], $a_usr_id);
449 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
453 $ilAppEventHandler->raise(
457 'obj_id' => $this->obj_id,
458 'usr_id' => $a_usr_id,
459 'role_id' => $a_role)
471 public function delete($a_usr_id)
475 $rbacadmin = $DIC[
'rbacadmin'];
476 $ilDB = $DIC[
'ilDB'];
477 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
480 foreach ($this->roles as $role_id) {
481 $rbacadmin->deassignUser($role_id, $a_usr_id);
484 $query =
"DELETE FROM obj_members " .
485 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
486 "AND obj_id = " .
$ilDB->quote($this->obj_id,
'integer');
489 $ilAppEventHandler->raise(
493 'obj_id' => $this->obj_id,
494 'usr_id' => $a_usr_id)
508 $ilDB = $DIC[
'ilDB'];
510 $query =
"DELETE FROM il_subscribers " .
511 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
512 "AND obj_id = " .
$ilDB->quote($this->obj_id,
'integer') .
" ";
561 $ilDB = $DIC[
'ilDB'];
564 'UPDATE obj_members SET ' .
565 'contact = ' .
$ilDB->quote($a_contact,
'integer') .
' ' .
566 'WHERE obj_id = ' .
$ilDB->quote($this->obj_id,
'integer') .
' ' .
567 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'integer')
570 $this->participants_status[$a_usr_id][
'contact'] = $a_contact;
587 $ilDB = $DIC[
'ilDB'];
589 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
591 $query =
"SELECT * FROM obj_members " .
592 "WHERE obj_id = " .
$ilDB->quote($this->obj_id,
'integer') .
" " .
593 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
595 if (
$res->numRows()) {
596 $query =
"UPDATE obj_members SET " .
597 "notification = " .
$ilDB->quote((
int) $a_notification,
'integer') .
" " .
598 "WHERE obj_id = " .
$ilDB->quote($this->obj_id,
'integer') .
" " .
599 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
601 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
603 $ilDB->quote((
int) $a_notification,
'integer') .
", " .
604 $ilDB->quote($this->obj_id,
'integer') .
", " .
605 $ilDB->quote($a_usr_id,
'integer') .
", " .
606 $ilDB->quote(0,
'integer') .
", " .
607 $ilDB->quote(0,
'integer') .
625 $ilDB = $DIC[
'ilDB'];
628 $this->type ==
'crs' ?
634 SELECT COUNT(rolesusers.usr_id) cnt 636 FROM object_data rdata 638 LEFT JOIN rbac_ua rolesusers 639 ON rolesusers.rol_id = rdata.obj_id 641 WHERE rdata.obj_id = %s 644 $query .=
' AND ' .
$ilDB->in(
'rolesusers.usr_id', $a_usr_ids,
true,
'integer');
649 return (
int)
$data[
'cnt'] > 0;
static updateMemberRoles($a_obj_id, $a_usr_id, $a_role_id, $a_status)
Update member roles ilDB $ilDB.
static getMembershipRoleType($a_role_id)
checkLastAdmin($a_usr_ids)
Check if user for deletion are last admins.
updateContact($a_usr_id, $a_contact)
ilDB $ilDB
isContact()
Check if user is contact for current object.
readParticipantStatus()
Read participant status ilDB $ilDB.
static _lookupTitle($a_id)
lookup object title
deleteSubscriber($a_usr_id)
Delete subsciber.
getComponent()
Get component name Used for event handling.
static _getAllReferences($a_id)
get all reference ids of object
foreach($_POST as $key=> $value) $res
__construct($a_component_name, $a_obj_id, $a_usr_id)
Singleton Constructor.
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
dropDesktopItem($a_usr_id)
Drop desktop item.
const IL_CRS_ADMIN
Base class for course and group participants.
Base class for course and group participant.
static _lookupType($a_id, $a_reference=false)
lookup object type
readParticipant()
Read participant.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
addDesktopItem($a_usr_id)
Add desktop item.
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
add($a_usr_id, $a_role)
Add user to course/group.
updateNotification($a_usr_id, $a_notification)
Update notification status.
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
static lookupStatusByMembershipRoleType($a_obj_id, $a_usr_id, $a_membership_role_type)
lookup assignment status ilDB $ilDB