12 define(
"IL_CRS_ADMIN",1);
13 define(
"IL_CRS_TUTOR",3);
14 define(
"IL_CRS_MEMBER",2);
16 define(
'IL_GRP_ADMIN',4);
17 define(
'IL_GRP_MEMBER',5);
57 $this->component = $a_component_name;
59 $this->obj_id = $a_obj_id;
62 $this->ref_id = current($ref_ids);
81 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
85 include_once
'./Modules/Group/classes/class.ilGroupParticipants.php';
89 include_once
'./Modules/Session/classes/class.ilSessionParticipants.php';
94 $GLOBALS[
'ilLog']->write(__METHOD__.
': Invalid obj_id given: '.$a_obj_id);
119 $a_usr_id =
$GLOBALS[
'ilUser']->getId();
130 $part = self::getInstanceByObjId($a_obj_id);
131 if($part->isAssigned($a_usr_id))
133 if($part->getType() ==
'crs')
136 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
163 if (!is_array($a_type))
165 $a_type = array($a_type);
169 if ($a_only_member_role)
171 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
172 $a2 =
'AND obd2.title = '.$ilDB->concat(
174 array($ilDB->quote(
'il_',
'text')),
176 array($ilDB->quote(
'_member_',
'text')),
184 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
185 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
186 "JOIN object_reference obr ON fa.parent = obr.ref_id ".
187 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
189 "WHERE ".$ilDB->in(
"obd.type", $a_type,
false,
"text").
190 "AND fa.assign = 'y' ".
191 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
194 while(
$row = $ilDB->fetchObject(
$res))
196 $ref_ids[] =
$row->obj_id;
199 return $ref_ids ? $ref_ids : array();
216 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
218 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
232 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
233 return $rbacreview->getNumberOfAssignedUsers($lroles);
245 global $rbacreview, $ilObjDataCache;
247 $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
253 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
255 $memberRoles = array();
256 foreach($lroles as $role_id)
258 $title = $ilObjDataCache->lookupTitle($role_id);
259 switch(substr($title,0,8))
267 $memberRoles[] = $role_id;
271 return $rbacreview->getNumberOfAssignedUsers($memberRoles);
288 $query =
"SELECT * FROM obj_members ".
289 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
290 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
291 "AND blocked = ".$ilDB->quote(1,
'integer');
293 return $res->numRows() ? true :
false;
309 $query =
"SELECT * FROM obj_members ".
310 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
311 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
314 return $res->numRows() ? true :
false;
330 $query =
"DELETE FROM obj_members ".
331 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
334 $query =
"DELETE FROM il_subscribers ".
335 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
338 $query =
'DELETE FROM crs_waiting_list '.
339 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
340 $ilDB->manipulate(
$query);
357 $query =
"DELETE FROM obj_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
360 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
363 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
374 if(!in_array(
$type,array(
'crs',
'grp')))
382 $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
387 if(substr($title, 0, 13) == (
'il_'.
$type.
'_member'))
423 $query =
"SELECT * FROM obj_members ".
424 "WHERE notification = 1 ".
425 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
431 $recp[] =
$row->usr_id;
434 return $recp ? $recp : array();
445 return count($this->members);
456 return count($this->participants);
470 return $this->participants ? $this->participants : array();
482 return $this->members ? $this->members : array();
492 return $this->admins ? $this->admins : array();
513 return $this->tutors ? $this->tutors : array();
525 return in_array($a_usr_id,$this->admins) ? true :
false;
537 return in_array($a_usr_id,$this->tutors) ? true :
false;
549 return in_array($a_usr_id,$this->members) ? true :
false;
564 return in_array($a_usr_id,$this->participants);
587 return $this->roles ? $this->roles : array();
601 foreach($this->roles as $role)
603 if($rbacreview->isAssigned($a_usr_id,$role))
608 return $assigned ? $assigned : array();
621 global $rbacreview,$rbacadmin;
623 $roles = $a_roles ? $a_roles : array();
625 foreach($this->
getRoles() as $role_id)
627 if($rbacreview->isAssigned($a_usr_id,$role_id))
629 if(!in_array($role_id,
$roles))
631 $rbacadmin->deassignUser($role_id,$a_usr_id);
636 if(in_array($role_id,
$roles))
638 $rbacadmin->assignUser($role_id,$a_usr_id);
642 $rbacreview->clearCaches();
658 if(!in_array($admin_id,$a_usr_ids))
675 if(isset($this->participants_status[$a_usr_id]))
677 return $this->participants_status[$a_usr_id][
'blocked'] ? true :
false;
691 if(isset($this->participants_status[$a_usr_id]))
693 return $this->participants_status[$a_usr_id][
'passed'] ? true :
false;
705 public function delete($a_usr_id)
707 global $rbacadmin,
$ilDB;
710 foreach($this->roles as $role_id)
712 $rbacadmin->deassignUser($role_id,$a_usr_id);
715 $query =
"DELETE FROM obj_members ".
716 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
717 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
723 $GLOBALS[
'ilAppEventHandler']->raise(
727 'obj_id' => $this->obj_id,
728 'usr_id' => $a_usr_id)
746 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
748 $query =
"SELECT * FROM obj_members ".
749 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
750 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
754 $query =
"UPDATE obj_members SET ".
755 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
756 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
757 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
761 $query =
"INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) ".
763 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
764 $ilDB->quote($this->obj_id ,
'integer').
", ".
765 $ilDB->quote($a_usr_id ,
'integer').
", ".
766 $ilDB->quote(0,
'integer').
", ".
767 $ilDB->quote(0,
'integer').
788 'UPDATE obj_members SET '.
789 'contact = '.$ilDB->quote($a_contact,
'integer').
' '.
790 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer').
' '.
791 'AND usr_id = '.$ilDB->quote($a_usr_id,
'integer'));
793 $this->participants_status[$a_usr_id][
'contact'] = $a_contact;
804 foreach((array) $this->participants_status as $usr_id => $status)
806 if($status[
'contact'])
808 $contacts[] = $usr_id;
829 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
831 $query =
"SELECT * FROM obj_members ".
832 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
833 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
837 $query =
"UPDATE obj_members SET ".
838 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
839 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
840 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
844 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
846 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
847 $ilDB->quote($this->obj_id ,
'integer').
", ".
848 $ilDB->quote($a_usr_id ,
'integer').
", ".
849 $ilDB->quote(0,
'integer').
", ".
850 $ilDB->quote(0,
'integer').
869 public function add($a_usr_id,$a_role)
871 global $rbacadmin,
$ilLog,$ilAppEventHandler;
881 $this->admins[] = $a_usr_id;
885 $this->tutors[] = $a_usr_id;
889 $this->members[] = $a_usr_id;
893 $this->admins[] = $a_usr_id;
897 $this->members[] = $a_usr_id;
901 $this->participants[] = $a_usr_id;
902 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
908 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
911 $ilLog->write(__METHOD__.
': Raise new event: '.$this->getComponent().
' addParticipant');
912 $ilAppEventHandler->raise(
916 'obj_id' => $this->obj_id,
917 'usr_id' => $a_usr_id,
918 'role_id' => $a_role)
933 foreach($a_user_ids as $user_id)
935 $this->
delete($user_id);
984 if(isset($this->participants_status[$a_usr_id]))
986 return $this->participants_status[$a_usr_id][
'notification'] ? true :
false;
998 if(isset($this->participants_status[$a_usr_id]))
1000 return (
bool) $this->participants_status[$a_usr_id][
'contact'];
1017 global $rbacreview,$ilObjDataCache,
$ilLog;
1019 $GLOBALS[
'rbacreview']->clearCaches();
1020 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
1023 $this->participants = array();
1024 $this->members = $this->admins = $this->tutors = array();
1026 foreach($this->roles as $role_id)
1028 $title = $ilObjDataCache->lookupTitle($role_id);
1029 switch(substr($title,0,8))
1033 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1034 $this->members = array_unique(array_merge($assigned,$this->members));
1039 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1040 $this->admins = $rbacreview->assignedUsers($role_id);
1045 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1046 $this->tutors = $rbacreview->assignedUsers($role_id);
1051 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1052 $this->admins = $rbacreview->assignedUsers($role_id);
1057 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1058 $this->members = $rbacreview->assignedUsers($role_id);
1062 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
1063 $this->members = array_unique(array_merge($assigned,$this->members));
1080 $query =
"SELECT * FROM obj_members ".
1081 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1083 $this->participants_status = array();
1086 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
1087 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
1088 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
1090 $this->participants_status[
$row->usr_id][
'contact'] =
$row->contact;
1104 global $rbacreview,$ilObjDataCache,
$ilDB;
1109 include_once
'./Services/User/classes/class.ilObjUser.php';
1115 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
1118 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
1120 case 'matriculation':
1121 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
1125 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
1134 $query =
"SELECT * FROM usr_data ud ".
1135 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
1139 return $res->numRows() ? true :
false;
1148 $query =
"SELECT usr_id FROM il_subscribers ".
1149 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1150 "ORDER BY sub_time ";
1202 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1206 foreach($a_usr_ids as $id)
1225 $ilErr->setMessage(
"");
1228 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1235 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1242 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1264 foreach($this->subscribers as $subscriber)
1273 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber); 1290 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1292 $ilDB->quote($a_usr_id ,
'integer').
",".
1293 $ilDB->quote($this->obj_id ,
'integer').
", ".
1294 $ilDB->quote(
'',
'text').
", ".
1295 $ilDB->quote(time() ,
'integer').
1312 $query =
"UPDATE il_subscribers ".
1313 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1314 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1315 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1332 $query =
"UPDATE il_subscribers ".
1333 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1334 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1335 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1350 $query =
"DELETE FROM il_subscribers ".
1351 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1352 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1368 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1370 $ilErr->setMessage(
'');
1371 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1375 $query =
"DELETE FROM il_subscribers ".
1376 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1377 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1392 $query =
"SELECT * FROM il_subscribers ".
1393 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1394 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1414 $query =
"SELECT * FROM il_subscribers ".
1415 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1416 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1435 $this->subscribers = array();
1437 $query =
"SELECT usr_id FROM il_subscribers ".
1438 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1439 "ORDER BY sub_time ";
1449 $this->subscribers[] =
$row->usr_id;
1463 $query =
"SELECT * FROM il_subscribers ".
1464 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1465 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1481 $query =
'SELECT * FROM il_subscribers '.
1482 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1510 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
1511 $a2 =
"AND obd2.title LIKE 'il_".$a_type.
"_mem%' ";
1514 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
1515 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
1516 "JOIN object_reference obr ON fa.parent = obr.ref_id ".
1517 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
1519 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
1520 "AND fa.assign = 'y' ".
1521 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
1526 while(
$row = $ilDB->fetchObject(
$res))
1528 $obj_ids[] =
$row->obj_id;
1531 $set = $ilDB->query(
"SELECT obj_id, usr_id FROM obj_members ".
1532 " WHERE ".$ilDB->in(
"obj_id", $obj_ids,
false,
"integer").
1533 " AND contact = ".$ilDB->quote(1,
"integer"));
1535 while ($rec = $ilDB->fetchAssoc($set))
getObjId()
get current obj_id
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
getCountMembers()
Get number of members (not participants)
static _getAllSupportContactsOfUser($a_usr_id, $a_type)
Get all support contacts for a user.
addDesktopItem($a_usr_id)
Add desktop item.
static _isSubscriber($a_obj_id, $a_usr_id)
check if user is subscriber
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
autoFillSubscribers()
Assign subscriber.
static lookupNumberOfParticipants($a_ref_id)
Lookup the number of participants (crs admins, tutors, members, grp admins, members) ...
static lookupNumberOfMembers($a_ref_id)
Lookup number of members ilRbacReview $rbacreview <type> $ilObjDataCache.
updateContact($a_usr_id, $a_contact)
Update contact setting type $ilDB.
readParticipantsStatus()
Read status of participants (blocked, notification, passed)
checkLastAdmin($a_usr_ids)
Check if user for deletion are last admins.
deleteParticipants($a_user_ids)
Delete users.
isAssigned($a_usr_id)
check if user is assigned
isLastAdmin($a_usr_id)
Check if user is last admin.
getCountAdmins()
Get number of admins.
static lookupSubscribers($a_obj_id)
updateBlocked($a_usr_id, $a_blocked)
Update blocked status.
static _deleteUser($a_usr_id)
Delete user.
query($sql, $a_handle_error=true)
Query.
assignSubscriber($a_usr_id)
Assign subscriber.
isAdmin($a_usr_id)
is user admin
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
isNotificationEnabled($a_usr_id)
check if notification is enabled
readSubscriberData($a_usr_id)
read subscribers
static _lookupTitle($a_id)
lookup object title
isMember($a_usr_id)
is user member
readSubscribers()
read subscribers
static getDefaultMemberRole($a_ref_id)
static _isBlocked($a_obj_id, $a_usr_id)
Check if user is blocked.
dropDesktopItem($a_usr_id)
Drop desktop item.
deleteSubscriber($a_usr_id)
Delete subsciber.
getAssignedRoles($a_usr_id)
Get assigned roles.
updateSubject($a_usr_id, $a_subject)
update subject
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
add($a_usr_id, $a_role)
Add user to course.
static hasParticipantListAccess($a_obj_id, $a_usr_id=null)
Check if (current) user has access to the participant list.
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
updateNotification($a_usr_id, $a_notification)
Update notification status.
getCountSubscribers()
get number of subscribers
static lookupShowMembersEnabled($a_obj_id)
Check if show member is enabled.
deleteSubscribers($a_usr_ids)
Delete subscibers.
getMembers()
Get all members ids (admins and tutors are not members) Use get participants to fetch all...
__construct($a_component_name, $a_obj_id)
Singleton Constructor.
updateSubscriptionTime($a_usr_id, $a_subtime)
Update subscription time.
isSubscriber($a_usr_id)
check if is subscriber
getCountParticipants()
Get number of participants.
getSubscribers()
get all subscribers
static _lookupObjId($a_id)
getParticipants()
Get all participants ids.
addSubscriber($a_usr_id)
Add subscriber.
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
static _hasPassed($a_obj_id, $a_usr_id)
Check if user has passed course.
isContact($a_usr_id)
Check if user is contact.
const IL_CRS_ADMIN
Base class for course and group participants.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
isBlocked($a_usr_id)
Check if user is blocked.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
hasPassed($a_usr_id)
Check if user has passed course.
getRoles()
Get course roles.
static lookupSubscribersData($a_obj_id)
assignSubscribers($a_usr_ids)
Assign subscribers.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
updateRoleAssignments($a_usr_id, $a_roles)
Update role assignments.
getAdmins()
Get all admins ids.
getComponent()
Get component name Used for raising events.
static _deleteUser($a_usr_id)
Delete user data.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getContacts()
get user ids which are confirgured as contact
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
isGroupingMember($a_usr_id, $a_field='')
Check grouping membership.
getType()
Get object type.
isTutor($a_usr_id)
is user tutor
getSubscriberData($a_usr_id)
get subscriber data
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
readParticipants()
Read participants.
getTutors()
Get all tutors ids.