25 include_once
'./Services/Membership/classes/class.ilParticipants.php';
65 protected function __construct($a_component_name, $a_obj_id, $a_usr_id)
69 $this->obj_id = $a_obj_id;
70 $this->usr_id = $a_usr_id;
73 $this->ref_id = current($ref_ids);
75 $this->component = $a_component_name;
92 $a_membership_role_type = self::getMembershipRoleType($a_role_id);
96 switch ($a_membership_role_type) {
97 case self::MEMBERSHIP_ADMIN:
98 $update_fields =
array(
'admin' =>
array(
'integer', $a_status ? 1 : 0));
99 $update_string = (
'admin = ' . $ilDB->quote($a_status ? 1 : 0,
'integer'));
102 case self::MEMBERSHIP_TUTOR:
103 $update_fields =
array(
'tutor' =>
array(
'integer', $a_status ? 1 : 0));
104 $update_string = (
'tutor = ' . $ilDB->quote($a_status ? 1 : 0,
'integer'));
107 case self::MEMBERSHIP_MEMBER:
109 $current_status = self::lookupStatusByMembershipRoleType($a_obj_id, $a_usr_id, $a_membership_role_type);
113 $new_status = $current_status + 1;
116 $new_status = $current_status - 1;
117 if ($new_status < 0) {
122 $update_fields =
array(
'member' =>
array(
'integer', $new_status));
123 $update_string = (
'member = ' . $ilDB->quote($new_status,
'integer'));
127 $query =
'SELECT count(*) num FROM obj_members ' .
128 'WHERE obj_id = ' . $ilDB->quote($a_obj_id,
'integer') .
' ' .
129 'AND usr_id = ' . $ilDB->quote($a_usr_id,
'integer');
142 'obj_id' =>
array(
'integer',$a_obj_id),
143 'usr_id' =>
array(
'integer',$a_usr_id)
148 $query =
'UPDATE obj_members SET ' .
149 $update_string .
' ' .
150 'WHERE obj_id = ' . $ilDB->quote($a_obj_id,
'integer') .
' ' .
151 'AND usr_id = ' . $ilDB->quote($a_usr_id,
'integer');
153 $ilDB->manipulate(
$query);
156 $query =
'DELETE from obj_members ' .
157 'WHERE obj_id = ' . $ilDB->quote($a_obj_id,
'integer') .
' ' .
158 'AND usr_id = ' . $ilDB->quote($a_usr_id,
'integer') .
' ' .
159 'AND admin = ' . $ilDB->quote(0,
'integer') .
' ' .
160 'AND tutor = ' . $ilDB->quote(0,
'integer') .
' ' .
161 'AND member = ' . $ilDB->quote(0,
'integer');
162 $ilDB->manipulate(
$query);
174 switch (substr(
$title, 0, 8)) {
177 return self::MEMBERSHIP_ADMIN;
180 return self::MEMBERSHIP_TUTOR;
184 return self::MEMBERSHIP_MEMBER;
201 $query =
'SELECT * FROM obj_members ' .
202 'WHERE obj_id = ' . $ilDB->quote($a_obj_id,
'integer') .
' ' .
203 'AND usr_id = ' . $ilDB->quote($a_usr_id) .
' ';
206 switch ($a_membership_role_type) {
207 case self::MEMBERSHIP_ADMIN:
210 case self::MEMBERSHIP_TUTOR:
213 case self::MEMBERSHIP_MEMBER:
242 return (
bool) $this->participants_status[$this->
getUserId()][
'blocked'];
252 return (
bool) $this->participants_status[$this->
getUserId()][
'contact'];
285 $rbacreview = $DIC[
'rbacreview'];
287 if ($this->numMembers === null) {
288 $this->numMembers = $rbacreview->getNumberOfAssignedUsers($this->member_roles);
300 global $rbacreview,$ilObjDataCache,
$ilLog;
302 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
305 $this->participants =
array();
306 $this->members = $this->admins = $this->tutors =
array();
307 $this->member_roles = [];
309 foreach ($this->roles as $role_id) {
310 $title = $ilObjDataCache->lookupTitle($role_id);
311 switch (substr(
$title, 0, 8)) {
313 $this->member_roles[] = $role_id;
315 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
316 $this->participants =
true;
317 $this->members =
true;
323 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
324 $this->participants =
true;
325 $this->admins =
true;
331 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
332 $this->participants =
true;
333 $this->tutors =
true;
339 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
340 $this->participants =
true;
341 $this->admins =
true;
346 $this->member_roles[] = $role_id;
348 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
349 $this->participants =
true;
350 $this->members =
true;
356 $this->member_roles[] = $role_id;
357 if ($rbacreview->isAssigned($this->getUserId(), $role_id)) {
358 $this->participants =
true;
359 $this->members =
true;
374 $query =
"SELECT * FROM obj_members " .
375 "WHERE obj_id = " . $ilDB->quote($this->obj_id,
'integer') .
" " .
376 'AND usr_id = ' . $ilDB->quote($this->
getUserId(),
'integer');
379 $this->participants_status =
array();
381 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
382 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
383 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
385 $this->participants_status[$this->
getUserId()][
'contact'] =
$row->contact;
400 public function add($a_usr_id, $a_role)
402 global $rbacadmin,
$ilLog,$ilAppEventHandler,$rbacreview;
405 if ($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $this->roles)) {
411 $this->admins =
true;
415 $this->tutors =
true;
419 $this->members =
true;
423 $this->admins =
true;
427 $this->members =
true;
431 $rbacadmin->assignUser($this->role_data[$a_role], $a_usr_id);
437 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
440 $ilLog->write(__METHOD__ .
': Raise new event: ' . $this->
getComponent() .
' addParticipant');
441 $ilAppEventHandler->raise(
445 'obj_id' => $this->obj_id,
446 'usr_id' => $a_usr_id,
447 'role_id' => $a_role)
459 public function delete($a_usr_id)
461 global $rbacadmin,
$ilDB, $ilAppEventHandler;
464 foreach ($this->roles as $role_id) {
465 $rbacadmin->deassignUser($role_id, $a_usr_id);
468 $query =
"DELETE FROM obj_members " .
469 "WHERE usr_id = " . $ilDB->quote($a_usr_id,
'integer') .
" " .
470 "AND obj_id = " . $ilDB->quote($this->obj_id,
'integer');
473 $ilAppEventHandler->raise(
477 'obj_id' => $this->obj_id,
478 'usr_id' => $a_usr_id)
492 $query =
"DELETE FROM il_subscribers " .
493 "WHERE usr_id = " . $ilDB->quote($a_usr_id,
'integer') .
" " .
494 "AND obj_id = " . $ilDB->quote($this->obj_id,
'integer') .
" ";
544 'UPDATE obj_members SET ' .
545 'contact = ' . $ilDB->quote($a_contact,
'integer') .
' ' .
546 'WHERE obj_id = ' . $ilDB->quote($this->obj_id,
'integer') .
' ' .
547 'AND usr_id = ' . $ilDB->quote($a_usr_id,
'integer')
550 $this->participants_status[$a_usr_id][
'contact'] = $a_contact;
567 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
569 $query =
"SELECT * FROM obj_members " .
570 "WHERE obj_id = " . $ilDB->quote($this->obj_id,
'integer') .
" " .
571 "AND usr_id = " . $ilDB->quote($a_usr_id,
'integer');
573 if (
$res->numRows()) {
574 $query =
"UPDATE obj_members SET " .
575 "notification = " . $ilDB->quote((
int) $a_notification,
'integer') .
" " .
576 "WHERE obj_id = " . $ilDB->quote($this->obj_id,
'integer') .
" " .
577 "AND usr_id = " . $ilDB->quote($a_usr_id,
'integer');
579 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
581 $ilDB->quote((
int) $a_notification,
'integer') .
", " .
582 $ilDB->quote($this->obj_id,
'integer') .
", " .
583 $ilDB->quote($a_usr_id,
'integer') .
", " .
584 $ilDB->quote(0,
'integer') .
", " .
585 $ilDB->quote(0,
'integer') .
604 $this->type ==
'crs' ?
610 SELECT COUNT(rolesusers.usr_id) cnt 612 FROM object_data rdata 614 LEFT JOIN rbac_ua rolesusers 615 ON rolesusers.rol_id = rdata.obj_id 617 WHERE rdata.obj_id = %s 620 $query .=
' AND ' . $ilDB->in(
'rolesusers.usr_id', $a_usr_ids,
true,
'integer');
625 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.
Create styles array
The data for the language used.
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.
static getLogger($a_component_id)
Get component logger.
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