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);
55 $this->obj_id = $a_obj_id;
58 $this->ref_id = current($ref_ids);
76 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
80 include_once
'./Modules/Group/classes/class.ilGroupParticipants.php';
97 $a_usr_id =
$GLOBALS[
'ilUser']->getId();
109 if($part->isAssigned($a_usr_id))
111 if($part->getType() ==
'crs')
114 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
142 if ($a_only_member_role)
144 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
145 $a2 =
"AND obd2.title LIKE 'il_".$a_type.
"_mem%' ";
148 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
149 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
150 "JOIN tree t1 ON t1.child = fa.parent ".
151 "JOIN object_reference obr ON t1.parent = obr.ref_id ".
152 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
154 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
155 "AND fa.assign = 'y' ".
156 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
161 while(
$row = $ilDB->fetchObject(
$res))
163 $ref_ids[] =
$row->obj_id;
166 return $ref_ids ? $ref_ids : array();
183 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
184 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
186 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($a_ref_id));
187 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$a_ref_id.
', title: '.
$title);
192 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
194 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
208 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
209 $lroles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
210 return $rbacreview->getNumberOfAssignedUsers($lroles);
222 global $rbacreview, $ilObjDataCache;
224 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
230 $lroles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
232 $memberRoles = array();
233 foreach($lroles as $role_id)
235 $title = $ilObjDataCache->lookupTitle($role_id);
236 switch(substr(
$title,0,8))
244 $memberRoles[] = $role_id;
248 return $rbacreview->getNumberOfAssignedUsers($memberRoles);
265 $query =
"SELECT * FROM obj_members ".
266 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
267 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
268 "AND blocked = ".$ilDB->quote(1,
'integer');
270 return $res->numRows() ?
true :
false;
286 $query =
"SELECT * FROM obj_members ".
287 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
288 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
291 return $res->numRows() ?
true :
false;
307 $query =
"DELETE FROM obj_members ".
308 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
311 $query =
"DELETE FROM il_subscribers ".
312 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
315 $query =
'DELETE FROM crs_waiting_list '.
316 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
317 $ilDB->manipulate(
$query);
334 $query =
"DELETE FROM obj_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
337 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
340 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
351 if(!in_array(
$type,array(
'crs',
'grp')))
359 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
360 $roles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
365 if(substr(
$title, 0, 13) == (
'il_'.
$type.
'_member'))
392 $query =
"SELECT * FROM obj_members ".
393 "WHERE notification = 1 ".
394 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
400 $recp[] =
$row->usr_id;
403 return $recp ? $recp : array();
414 return count($this->members);
425 return count($this->participants);
439 return $this->participants ? $this->participants : array();
451 return $this->members ? $this->members : array();
461 return $this->admins ? $this->admins : array();
482 return $this->tutors ? $this->tutors : array();
494 return in_array($a_usr_id,$this->admins) ?
true :
false;
506 return in_array($a_usr_id,$this->tutors) ?
true :
false;
518 return in_array($a_usr_id,$this->members) ?
true :
false;
533 return in_array($a_usr_id,$this->participants);
556 return $this->roles ? $this->roles : array();
570 foreach($this->roles as $role)
572 if($rbacreview->isAssigned($a_usr_id,$role))
577 return $assigned ? $assigned : array();
590 global $rbacreview,$rbacadmin;
592 $roles = $a_roles ? $a_roles : array();
594 foreach($this->
getRoles() as $role_id)
596 if($rbacreview->isAssigned($a_usr_id,$role_id))
598 if(!in_array($role_id,
$roles))
600 $rbacadmin->deassignUser($role_id,$a_usr_id);
605 if(in_array($role_id,
$roles))
607 $rbacadmin->assignUser($role_id,$a_usr_id);
626 if(!in_array($admin_id,$a_usr_ids))
643 if(isset($this->participants_status[$a_usr_id]))
645 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
659 if(isset($this->participants_status[$a_usr_id]))
661 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
673 public function delete($a_usr_id)
675 global $rbacadmin,
$ilDB;
678 foreach($this->roles as $role_id)
680 $rbacadmin->deassignUser($role_id,$a_usr_id);
683 $query =
"DELETE FROM obj_members ".
684 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
685 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
706 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
708 $query =
"SELECT * FROM obj_members ".
709 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
710 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
714 $query =
"UPDATE obj_members SET ".
715 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
716 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
717 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
721 $query =
"INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) ".
723 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
724 $ilDB->quote($this->obj_id ,
'integer').
", ".
725 $ilDB->quote($a_usr_id ,
'integer').
", ".
726 $ilDB->quote(0,
'integer').
", ".
727 $ilDB->quote(0,
'integer').
747 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
749 $query =
"SELECT * FROM obj_members ".
750 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
751 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
755 $query =
"UPDATE obj_members SET ".
756 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
757 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
758 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
762 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
764 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
765 $ilDB->quote($this->obj_id ,
'integer').
", ".
766 $ilDB->quote($a_usr_id ,
'integer').
", ".
767 $ilDB->quote(0,
'integer').
", ".
768 $ilDB->quote(0,
'integer').
787 public function add($a_usr_id,$a_role)
789 global $rbacadmin,
$ilLog,$ilAppEventHandler;
799 $this->admins[] = $a_usr_id;
803 $this->tutors[] = $a_usr_id;
807 $this->members[] = $a_usr_id;
811 $this->admins[] = $a_usr_id;
815 $this->members[] = $a_usr_id;
819 $this->participants[] = $a_usr_id;
820 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
826 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
829 if($this->type ==
'crs') {
831 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
832 $ilAppEventHandler->raise(
836 'obj_id' => $this->obj_id,
837 'usr_id' => $a_usr_id,
838 'role_id' => $a_role)
854 foreach($a_user_ids as $user_id)
856 $this->
delete($user_id);
905 if(isset($this->participants_status[$a_usr_id]))
907 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
922 global $rbacreview,$ilObjDataCache,
$ilLog;
924 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
926 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
928 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
929 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.
$title);
934 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
937 $this->participants = array();
938 $this->members = $this->admins = $this->tutors = array();
940 foreach($this->roles as $role_id)
942 $title = $ilObjDataCache->lookupTitle($role_id);
943 switch(substr(
$title,0,8))
947 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
948 $this->members = array_unique(array_merge($assigned,$this->members));
953 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
954 $this->admins = $rbacreview->assignedUsers($role_id);
959 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
960 $this->tutors = $rbacreview->assignedUsers($role_id);
965 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
966 $this->admins = $rbacreview->assignedUsers($role_id);
971 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
972 $this->members = $rbacreview->assignedUsers($role_id);
976 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
977 $this->members = array_unique(array_merge($assigned,$this->members));
994 $query =
"SELECT * FROM obj_members ".
995 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
997 $this->participants_status = array();
1000 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
1001 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
1002 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
1015 global $rbacreview,$ilObjDataCache,
$ilDB;
1020 include_once
'./Services/User/classes/class.ilObjUser.php';
1026 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
1029 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
1031 case 'matriculation':
1032 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
1036 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
1045 $query =
"SELECT * FROM usr_data ud ".
1046 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
1050 return $res->numRows() ?
true :
false;
1059 $query =
"SELECT usr_id FROM il_subscribers ".
1060 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1061 "ORDER BY sub_time ";
1113 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1117 foreach($a_usr_ids as $id)
1136 $ilErr->setMessage(
"");
1139 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1146 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1153 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1175 foreach($this->subscribers as $subscriber)
1184 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1201 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1203 $ilDB->quote($a_usr_id ,
'integer').
",".
1204 $ilDB->quote($this->obj_id ,
'integer').
", ".
1205 $ilDB->quote(
'',
'text').
", ".
1206 $ilDB->quote(time() ,
'integer').
1223 $query =
"UPDATE il_subscribers ".
1224 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1225 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1226 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1243 $query =
"UPDATE il_subscribers ".
1244 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1245 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1246 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1261 $query =
"DELETE FROM il_subscribers ".
1262 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1263 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1279 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1281 $ilErr->setMessage(
'');
1282 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1286 $query =
"DELETE FROM il_subscribers ".
1287 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1288 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1303 $query =
"SELECT * FROM il_subscribers ".
1304 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1305 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1325 $query =
"SELECT * FROM il_subscribers ".
1326 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1327 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1346 $this->subscribers = array();
1348 $query =
"SELECT usr_id FROM il_subscribers ".
1349 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1350 "ORDER BY sub_time ";
1360 $this->subscribers[] =
$row->usr_id;
1374 $query =
"SELECT * FROM il_subscribers ".
1375 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1376 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1392 $query =
'SELECT * FROM il_subscribers '.
1393 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');