25 include_once
'./Services/Membership/classes/class.ilParticipants.php';
63 protected function __construct($a_component_name, $a_obj_id, $a_usr_id)
67 $this->obj_id = $a_obj_id;
68 $this->usr_id = $a_usr_id;
71 $this->ref_id = current($ref_ids);
73 $this->component = $a_component_name;
90 $a_membership_role_type = self::getMembershipRoleType($a_role_id);
94 switch($a_membership_role_type)
96 case self::MEMBERSHIP_ADMIN:
97 $update_fields = array(
'admin' => array(
'integer', $a_status ? 1 : 0));
98 $update_string = (
'admin = '.$ilDB->quote($a_status ? 1 : 0,
'integer'));
101 case self::MEMBERSHIP_TUTOR:
102 $update_fields = array(
'tutor' => array(
'integer', $a_status ? 1 : 0));
103 $update_string = (
'tutor = '.$ilDB->quote($a_status ? 1 : 0,
'integer'));
106 case self::MEMBERSHIP_MEMBER:
108 $current_status = self::lookupStatusByMembershipRoleType($a_obj_id, $a_usr_id, $a_membership_role_type);
113 $new_status = $current_status + 1;
117 $new_status = $current_status - 1;
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');
147 'obj_id' => array(
'integer',$a_obj_id),
148 'usr_id' => array(
'integer',$a_usr_id)
155 $query =
'UPDATE obj_members SET '.
157 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
158 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer');
160 $ilDB->manipulate(
$query);
171 switch(substr($title, 0, 8))
175 return self::MEMBERSHIP_ADMIN;
178 return self::MEMBERSHIP_TUTOR;
182 return self::MEMBERSHIP_MEMBER;
199 $query =
'SELECT * FROM obj_members '.
200 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
201 'AND usr_id = '.$ilDB->quote($a_usr_id).
' ';
205 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'];
293 global $rbacreview,$ilObjDataCache,
$ilLog;
295 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
298 $this->participants = array();
299 $this->members = $this->admins = $this->tutors = array();
301 $member_roles = array();
303 foreach($this->roles as $role_id)
305 $title = $ilObjDataCache->lookupTitle($role_id);
306 switch(substr($title,0,8))
309 $member_roles[] = $role_id;
311 if($rbacreview->isAssigned($this->getUserId(),$role_id))
313 $this->participants =
true;
314 $this->members =
true;
320 if($rbacreview->isAssigned($this->getUserId(),$role_id))
322 $this->participants =
true;
323 $this->admins =
true;
329 if($rbacreview->isAssigned($this->getUserId(),$role_id))
331 $this->participants =
true;
332 $this->tutors =
true;
338 if($rbacreview->isAssigned($this->getUserId(),$role_id))
340 $this->participants =
true;
341 $this->admins =
true;
346 $member_roles[] = $role_id;
348 if($rbacreview->isAssigned($this->getUserId(),$role_id))
350 $this->participants =
true;
351 $this->members =
true;
357 $member_roles[] = $role_id;
358 if($rbacreview->isAssigned($this->getUserId(),$role_id))
360 $this->participants =
true;
361 $this->members =
true;
366 $this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
377 $query =
"SELECT * FROM obj_members ".
378 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
379 'AND usr_id = '.$ilDB->quote($this->
getUserId(),
'integer');
382 $this->participants_status = array();
385 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
386 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
387 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
389 $this->participants_status[$this->
getUserId()][
'contact'] =
$row->contact;
404 public function add($a_usr_id,$a_role)
406 global $rbacadmin,
$ilLog,$ilAppEventHandler,$rbacreview;
409 if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
417 $this->admins =
true;
421 $this->tutors =
true;
425 $this->members =
true;
429 $this->admins =
true;
433 $this->members =
true;
437 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
443 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
446 $ilLog->write(__METHOD__.
': Raise new event: '.$this->getComponent().
' addParticipant');
447 $ilAppEventHandler->raise(
451 'obj_id' => $this->obj_id,
452 'usr_id' => $a_usr_id,
453 'role_id' => $a_role)
465 public function delete($a_usr_id)
467 global $rbacadmin,
$ilDB, $ilAppEventHandler;
470 foreach($this->roles as $role_id)
472 $rbacadmin->deassignUser($role_id,$a_usr_id);
475 $query =
"DELETE FROM obj_members ".
476 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
477 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
480 $ilAppEventHandler->raise(
484 'obj_id' => $this->obj_id,
485 'usr_id' => $a_usr_id)
499 $query =
"DELETE FROM il_subscribers ".
500 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
501 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
553 'UPDATE obj_members SET '.
554 'contact = '.$ilDB->quote($a_contact,
'integer').
' '.
555 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer').
' '.
556 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer'));
558 $this->participants_status[$a_usr_id][
'contact'] = $a_contact;
575 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
577 $query =
"SELECT * FROM obj_members ".
578 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
579 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
583 $query =
"UPDATE obj_members SET ".
584 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
585 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
586 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
590 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
592 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
593 $ilDB->quote($this->obj_id ,
'integer').
", ".
594 $ilDB->quote($a_usr_id ,
'integer').
", ".
595 $ilDB->quote(0,
'integer').
", ".
596 $ilDB->quote(0,
'integer').
616 $this->type ==
'crs' ?
622 SELECT COUNT(rolesusers.usr_id) cnt 624 FROM object_data rdata 626 LEFT JOIN rbac_ua rolesusers 627 ON rolesusers.rol_id = rdata.obj_id 629 WHERE rdata.obj_id = %s 632 $query .=
' AND '.$ilDB->in(
'rolesusers.usr_id', $a_usr_ids,
true,
'integer');
633 $res = $ilDB->queryF(
$query, array(
'integer'), array($admin_role_id));
637 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
const DB_FETCHMODE_OBJECT
__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