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);
163 $query =
'DELETE from obj_members '.
164 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
165 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer').
' '.
166 'AND admin = '.$ilDB->quote(0,
'integer').
' '.
167 'AND tutor = '.$ilDB->quote(0,
'integer').
' '.
168 'AND member = '.$ilDB->quote(0,
'integer');
169 $ilDB->manipulate(
$query);
183 switch(substr(
$title, 0, 8))
187 return self::MEMBERSHIP_ADMIN;
190 return self::MEMBERSHIP_TUTOR;
194 return self::MEMBERSHIP_MEMBER;
211 $query =
'SELECT * FROM obj_members '.
212 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer').
' '.
213 'AND usr_id = '.$ilDB->quote($a_usr_id).
' ';
217 switch($a_membership_role_type)
219 case self::MEMBERSHIP_ADMIN:
222 case self::MEMBERSHIP_TUTOR:
225 case self::MEMBERSHIP_MEMBER:
254 return (
bool) $this->participants_status[$this->
getUserId()][
'blocked'];
264 return (
bool) $this->participants_status[$this->
getUserId()][
'contact'];
305 global $rbacreview,$ilObjDataCache,
$ilLog;
307 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
310 $this->participants =
array();
311 $this->members = $this->admins = $this->tutors =
array();
313 $member_roles =
array();
315 foreach($this->roles as $role_id)
317 $title = $ilObjDataCache->lookupTitle($role_id);
318 switch(substr(
$title,0,8))
321 $member_roles[] = $role_id;
323 if($rbacreview->isAssigned($this->getUserId(),$role_id))
325 $this->participants =
true;
326 $this->members =
true;
332 if($rbacreview->isAssigned($this->getUserId(),$role_id))
334 $this->participants =
true;
335 $this->admins =
true;
341 if($rbacreview->isAssigned($this->getUserId(),$role_id))
343 $this->participants =
true;
344 $this->tutors =
true;
350 if($rbacreview->isAssigned($this->getUserId(),$role_id))
352 $this->participants =
true;
353 $this->admins =
true;
358 $member_roles[] = $role_id;
360 if($rbacreview->isAssigned($this->getUserId(),$role_id))
362 $this->participants =
true;
363 $this->members =
true;
369 $member_roles[] = $role_id;
370 if($rbacreview->isAssigned($this->getUserId(),$role_id))
372 $this->participants =
true;
373 $this->members =
true;
378 $this->numMembers = $rbacreview->getNumberOfAssignedUsers((
array) $member_roles);
389 $query =
"SELECT * FROM obj_members ".
390 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
391 'AND usr_id = '.$ilDB->quote($this->
getUserId(),
'integer');
394 $this->participants_status =
array();
397 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
398 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
399 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
401 $this->participants_status[$this->
getUserId()][
'contact'] =
$row->contact;
416 public function add($a_usr_id,$a_role)
418 global $rbacadmin,
$ilLog,$ilAppEventHandler,$rbacreview;
421 if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
429 $this->admins =
true;
433 $this->tutors =
true;
437 $this->members =
true;
441 $this->admins =
true;
445 $this->members =
true;
449 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
455 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
458 $ilLog->write(__METHOD__.
': Raise new event: '.$this->getComponent().
' addParticipant');
459 $ilAppEventHandler->raise(
463 'obj_id' => $this->obj_id,
464 'usr_id' => $a_usr_id,
465 'role_id' => $a_role)
477 public function delete($a_usr_id)
479 global $rbacadmin,
$ilDB, $ilAppEventHandler;
482 foreach($this->roles as $role_id)
484 $rbacadmin->deassignUser($role_id,$a_usr_id);
487 $query =
"DELETE FROM obj_members ".
488 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
489 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
492 $ilAppEventHandler->raise(
496 'obj_id' => $this->obj_id,
497 'usr_id' => $a_usr_id)
511 $query =
"DELETE FROM il_subscribers ".
512 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
513 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
565 'UPDATE obj_members SET '.
566 'contact = '.$ilDB->quote($a_contact,
'integer').
' '.
567 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer').
' '.
568 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer'));
570 $this->participants_status[$a_usr_id][
'contact'] = $a_contact;
587 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
589 $query =
"SELECT * FROM obj_members ".
590 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
591 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
595 $query =
"UPDATE obj_members SET ".
596 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
597 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
598 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
602 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
604 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
605 $ilDB->quote($this->obj_id ,
'integer').
", ".
606 $ilDB->quote($a_usr_id ,
'integer').
", ".
607 $ilDB->quote(0,
'integer').
", ".
608 $ilDB->quote(0,
'integer').
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
__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