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);
95 throw new InvalidArgumentException(
'Invalid obj id given');
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';
164 if ($a_only_member_role)
166 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
167 $a2 =
"AND obd2.title LIKE 'il_".$a_type.
"_mem%' ";
171 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
172 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
173 "JOIN object_reference obr ON fa.parent = obr.ref_id ".
174 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
176 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
177 "AND fa.assign = 'y' ".
178 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
182 while(
$row = $ilDB->fetchObject(
$res))
184 $ref_ids[] =
$row->obj_id;
187 return $ref_ids ? $ref_ids : array();
204 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
206 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
220 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
221 return $rbacreview->getNumberOfAssignedUsers($lroles);
233 global $rbacreview, $ilObjDataCache;
235 $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
241 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
243 $memberRoles = array();
244 foreach($lroles as $role_id)
246 $title = $ilObjDataCache->lookupTitle($role_id);
247 switch(substr($title,0,8))
255 $memberRoles[] = $role_id;
259 return $rbacreview->getNumberOfAssignedUsers($memberRoles);
276 $query =
"SELECT * FROM obj_members ".
277 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
278 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
279 "AND blocked = ".$ilDB->quote(1,
'integer');
281 return $res->numRows() ? true :
false;
297 $query =
"SELECT * FROM obj_members ".
298 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
299 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
302 return $res->numRows() ? true :
false;
318 $query =
"DELETE FROM obj_members ".
319 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
322 $query =
"DELETE FROM il_subscribers ".
323 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
326 $query =
'DELETE FROM crs_waiting_list '.
327 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
328 $ilDB->manipulate(
$query);
345 $query =
"DELETE FROM obj_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
348 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
351 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
362 if(!in_array(
$type,array(
'crs',
'grp')))
370 $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
375 if(substr($title, 0, 13) == (
'il_'.
$type.
'_member'))
411 $query =
"SELECT * FROM obj_members ".
412 "WHERE notification = 1 ".
413 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
419 $recp[] =
$row->usr_id;
422 return $recp ? $recp : array();
433 return count($this->members);
444 return count($this->participants);
458 return $this->participants ? $this->participants : array();
470 return $this->members ? $this->members : array();
480 return $this->admins ? $this->admins : array();
501 return $this->tutors ? $this->tutors : array();
513 return in_array($a_usr_id,$this->admins) ? true :
false;
525 return in_array($a_usr_id,$this->tutors) ? true :
false;
537 return in_array($a_usr_id,$this->members) ? true :
false;
552 return in_array($a_usr_id,$this->participants);
575 return $this->roles ? $this->roles : array();
589 foreach($this->roles as $role)
591 if($rbacreview->isAssigned($a_usr_id,$role))
596 return $assigned ? $assigned : array();
609 global $rbacreview,$rbacadmin;
611 $roles = $a_roles ? $a_roles : array();
613 foreach($this->
getRoles() as $role_id)
615 if($rbacreview->isAssigned($a_usr_id,$role_id))
617 if(!in_array($role_id,
$roles))
619 $rbacadmin->deassignUser($role_id,$a_usr_id);
624 if(in_array($role_id,
$roles))
626 $rbacadmin->assignUser($role_id,$a_usr_id);
645 if(!in_array($admin_id,$a_usr_ids))
662 if(isset($this->participants_status[$a_usr_id]))
664 return $this->participants_status[$a_usr_id][
'blocked'] ? true :
false;
678 if(isset($this->participants_status[$a_usr_id]))
680 return $this->participants_status[$a_usr_id][
'passed'] ? true :
false;
692 public function delete($a_usr_id)
694 global $rbacadmin,
$ilDB;
697 foreach($this->roles as $role_id)
699 $rbacadmin->deassignUser($role_id,$a_usr_id);
702 $query =
"DELETE FROM obj_members ".
703 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
704 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
710 $GLOBALS[
'ilAppEventHandler']->raise(
714 'obj_id' => $this->obj_id,
715 'usr_id' => $a_usr_id)
733 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
735 $query =
"SELECT * FROM obj_members ".
736 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
737 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
741 $query =
"UPDATE obj_members SET ".
742 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
743 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
744 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
748 $query =
"INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) ".
750 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
751 $ilDB->quote($this->obj_id ,
'integer').
", ".
752 $ilDB->quote($a_usr_id ,
'integer').
", ".
753 $ilDB->quote(0,
'integer').
", ".
754 $ilDB->quote(0,
'integer').
774 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
776 $query =
"SELECT * FROM obj_members ".
777 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
778 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
782 $query =
"UPDATE obj_members SET ".
783 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
784 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
785 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
789 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
791 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
792 $ilDB->quote($this->obj_id ,
'integer').
", ".
793 $ilDB->quote($a_usr_id ,
'integer').
", ".
794 $ilDB->quote(0,
'integer').
", ".
795 $ilDB->quote(0,
'integer').
814 public function add($a_usr_id,$a_role)
816 global $rbacadmin,
$ilLog,$ilAppEventHandler;
826 $this->admins[] = $a_usr_id;
830 $this->tutors[] = $a_usr_id;
834 $this->members[] = $a_usr_id;
838 $this->admins[] = $a_usr_id;
842 $this->members[] = $a_usr_id;
846 $this->participants[] = $a_usr_id;
847 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
853 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
856 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course|Group addParticipant');
857 $ilAppEventHandler->raise(
861 'obj_id' => $this->obj_id,
862 'usr_id' => $a_usr_id,
863 'role_id' => $a_role)
878 foreach($a_user_ids as $user_id)
880 $this->
delete($user_id);
929 if(isset($this->participants_status[$a_usr_id]))
931 return $this->participants_status[$a_usr_id][
'notification'] ? true :
false;
946 global $rbacreview,$ilObjDataCache,
$ilLog;
948 $GLOBALS[
'rbacreview']->clearCaches();
949 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
952 $this->participants = array();
953 $this->members = $this->admins = $this->tutors = array();
955 foreach($this->roles as $role_id)
957 $title = $ilObjDataCache->lookupTitle($role_id);
958 switch(substr($title,0,8))
962 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
963 $this->members = array_unique(array_merge($assigned,$this->members));
968 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
969 $this->admins = $rbacreview->assignedUsers($role_id);
974 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
975 $this->tutors = $rbacreview->assignedUsers($role_id);
980 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
981 $this->admins = $rbacreview->assignedUsers($role_id);
986 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
987 $this->members = $rbacreview->assignedUsers($role_id);
991 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
992 $this->members = array_unique(array_merge($assigned,$this->members));
1009 $query =
"SELECT * FROM obj_members ".
1010 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1012 $this->participants_status = array();
1015 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
1016 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
1017 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
1030 global $rbacreview,$ilObjDataCache,
$ilDB;
1035 include_once
'./Services/User/classes/class.ilObjUser.php';
1041 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
1044 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
1046 case 'matriculation':
1047 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
1051 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
1060 $query =
"SELECT * FROM usr_data ud ".
1061 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
1065 return $res->numRows() ? true :
false;
1074 $query =
"SELECT usr_id FROM il_subscribers ".
1075 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1076 "ORDER BY sub_time ";
1128 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1132 foreach($a_usr_ids as $id)
1151 $ilErr->setMessage(
"");
1154 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1161 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1168 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1190 foreach($this->subscribers as $subscriber)
1199 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber); 1216 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1218 $ilDB->quote($a_usr_id ,
'integer').
",".
1219 $ilDB->quote($this->obj_id ,
'integer').
", ".
1220 $ilDB->quote(
'',
'text').
", ".
1221 $ilDB->quote(time() ,
'integer').
1238 $query =
"UPDATE il_subscribers ".
1239 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1240 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1241 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1258 $query =
"UPDATE il_subscribers ".
1259 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1260 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1261 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1276 $query =
"DELETE FROM il_subscribers ".
1277 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1278 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1294 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1296 $ilErr->setMessage(
'');
1297 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1301 $query =
"DELETE FROM il_subscribers ".
1302 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1303 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1318 $query =
"SELECT * FROM il_subscribers ".
1319 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1320 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1340 $query =
"SELECT * FROM il_subscribers ".
1341 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1342 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1361 $this->subscribers = array();
1363 $query =
"SELECT usr_id FROM il_subscribers ".
1364 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1365 "ORDER BY sub_time ";
1375 $this->subscribers[] =
$row->usr_id;
1389 $query =
"SELECT * FROM il_subscribers ".
1390 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1391 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1407 $query =
'SELECT * FROM il_subscribers '.
1408 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
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)
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.
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.
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.
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
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.