32 define(
"IL_CRS_ADMIN",1);
33 define(
"IL_CRS_TUTOR",3);
34 define(
"IL_CRS_MEMBER",2);
36 define(
'IL_GRP_ADMIN',4);
37 define(
'IL_GRP_MEMBER',5);
75 $this->obj_id = $a_obj_id;
78 $this->ref_id = current($ref_ids);
100 if ($a_only_member_role)
102 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
103 $a2 =
"AND obd2.title LIKE 'il_".$a_type.
"_mem%' ";
106 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
107 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
108 "JOIN tree t1 ON t1.child = fa.parent ".
109 "JOIN object_reference obr ON t1.parent = obr.ref_id ".
110 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
112 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
113 "AND fa.assign = 'y' ".
114 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
119 while(
$row = $ilDB->fetchObject(
$res))
121 $ref_ids[] =
$row->obj_id;
124 return $ref_ids ? $ref_ids : array();
141 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
142 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
144 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($a_ref_id));
145 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$a_ref_id.
', title: '.
$title);
150 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
152 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
166 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
167 $lroles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
168 return $rbacreview->getNumberOfAssignedUsers($lroles);
180 global $rbacreview, $ilObjDataCache;
182 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
188 $lroles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
190 $memberRoles = array();
191 foreach($lroles as $role_id)
193 $title = $ilObjDataCache->lookupTitle($role_id);
194 switch(substr(
$title,0,8))
202 $memberRoles[] = $role_id;
206 return $rbacreview->getNumberOfAssignedUsers($memberRoles);
223 $query =
"SELECT * FROM crs_members ".
224 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
225 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
226 "AND blocked = ".$ilDB->quote(1,
'integer');
228 return $res->numRows() ?
true :
false;
244 $query =
"SELECT * FROM crs_members ".
245 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
246 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
249 return $res->numRows() ?
true :
false;
265 $query =
"DELETE FROM crs_members ".
266 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
269 $query =
"DELETE FROM il_subscribers ".
270 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
273 $query =
'DELETE FROM crs_waiting_list '.
274 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
275 $ilDB->manipulate(
$query);
292 $query =
"DELETE FROM crs_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
295 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
298 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
309 if(!in_array(
$type,array(
'crs',
'grp')))
317 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
318 $roles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
323 if(substr(
$title, 0, 13) == (
'il_'.
$type.
'_member'))
341 $query =
"SELECT * FROM crs_members ".
342 "WHERE notification = 1 ".
343 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
349 $recp[] =
$row->usr_id;
352 return $recp ? $recp : array();
363 return count($this->members);
374 return count($this->participants);
388 return $this->participants ? $this->participants : array();
400 return $this->members ? $this->members : array();
410 return $this->admins ? $this->admins : array();
431 return $this->tutors ? $this->tutors : array();
443 return in_array($a_usr_id,$this->admins) ?
true :
false;
455 return in_array($a_usr_id,$this->tutors) ?
true :
false;
467 return in_array($a_usr_id,$this->members) ?
true :
false;
482 return in_array($a_usr_id,$this->participants);
505 return $this->roles ? $this->roles : array();
519 foreach($this->roles as $role)
521 if($rbacreview->isAssigned($a_usr_id,$role))
526 return $assigned ? $assigned : array();
539 global $rbacreview,$rbacadmin;
541 $roles = $a_roles ? $a_roles : array();
543 foreach($this->
getRoles() as $role_id)
545 if($rbacreview->isAssigned($a_usr_id,$role_id))
547 if(!in_array($role_id,
$roles))
549 $rbacadmin->deassignUser($role_id,$a_usr_id);
554 if(in_array($role_id,
$roles))
556 $rbacadmin->assignUser($role_id,$a_usr_id);
575 if(!in_array($admin_id,$a_usr_ids))
592 if(isset($this->participants_status[$a_usr_id]))
594 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
608 if(isset($this->participants_status[$a_usr_id]))
610 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
622 public function delete($a_usr_id)
624 global $rbacadmin,
$ilDB;
627 foreach($this->roles as $role_id)
629 $rbacadmin->deassignUser($role_id,$a_usr_id);
632 $query =
"DELETE FROM crs_members ".
633 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
634 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
655 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
657 $query =
"SELECT * FROM crs_members ".
658 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
659 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
663 $query =
"UPDATE crs_members SET ".
664 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
665 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
666 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
670 $query =
"INSERT INTO crs_members (blocked,obj_id,usr_id,notification,passed) ".
672 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
673 $ilDB->quote($this->obj_id ,
'integer').
", ".
674 $ilDB->quote($a_usr_id ,
'integer').
", ".
675 $ilDB->quote(0,
'integer').
", ".
676 $ilDB->quote(0,
'integer').
696 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
698 $query =
"SELECT * FROM crs_members ".
699 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
700 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
704 $query =
"UPDATE crs_members SET ".
705 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
706 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
707 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
711 $query =
"INSERT INTO crs_members (notification,obj_id,usr_id,passed,blocked) ".
713 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
714 $ilDB->quote($this->obj_id ,
'integer').
", ".
715 $ilDB->quote($a_usr_id ,
'integer').
", ".
716 $ilDB->quote(0,
'integer').
", ".
717 $ilDB->quote(0,
'integer').
736 public function add($a_usr_id,$a_role)
738 global $rbacadmin,
$ilLog,$ilAppEventHandler;
748 $this->admins[] = $a_usr_id;
752 $this->tutors[] = $a_usr_id;
756 $this->members[] = $a_usr_id;
760 $this->admins[] = $a_usr_id;
764 $this->members[] = $a_usr_id;
768 $this->participants[] = $a_usr_id;
769 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
775 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
778 if($this->type ==
'crs') {
780 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
781 $ilAppEventHandler->raise(
"Modules/Course",
"addParticipant", array(
'usr_id' => $a_usr_id,
'role_id' => $a_role));
796 foreach($a_user_ids as $user_id)
798 $this->
delete($user_id);
847 if(isset($this->participants_status[$a_usr_id]))
849 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
864 global $rbacreview,$ilObjDataCache,
$ilLog;
866 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
868 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
870 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
871 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.
$title);
876 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
879 $this->participants = array();
880 $this->members = $this->admins = $this->tutors = array();
882 foreach($this->roles as $role_id)
884 $title = $ilObjDataCache->lookupTitle($role_id);
885 switch(substr(
$title,0,8))
889 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
890 $this->members = array_unique(array_merge($assigned,$this->members));
895 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
896 $this->admins = $rbacreview->assignedUsers($role_id);
901 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
902 $this->tutors = $rbacreview->assignedUsers($role_id);
907 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
908 $this->admins = $rbacreview->assignedUsers($role_id);
913 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
914 $this->members = $rbacreview->assignedUsers($role_id);
918 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
919 $this->members = array_unique(array_merge($assigned,$this->members));
936 $query =
"SELECT * FROM crs_members ".
937 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
939 $this->participants_status = array();
942 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
943 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
944 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
957 global $rbacreview,$ilObjDataCache,
$ilDB;
962 include_once
'./Services/User/classes/class.ilObjUser.php';
968 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
971 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
973 case 'matriculation':
974 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
978 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
987 $query =
"SELECT * FROM usr_data ud ".
988 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
992 return $res->numRows() ?
true :
false;
1001 $query =
"SELECT usr_id FROM il_subscribers ".
1002 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1003 "ORDER BY sub_time ";
1055 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1059 foreach($a_usr_ids as $id)
1078 $ilErr->setMessage(
"");
1081 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1088 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1095 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1117 foreach($this->subscribers as $subscriber)
1126 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1143 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1145 $ilDB->quote($a_usr_id ,
'integer').
",".
1146 $ilDB->quote($this->obj_id ,
'integer').
", ".
1147 $ilDB->quote(
'',
'text').
", ".
1148 $ilDB->quote(time() ,
'integer').
1165 $query =
"UPDATE il_subscribers ".
1166 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1167 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1168 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1185 $query =
"UPDATE il_subscribers ".
1186 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1187 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1188 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1203 $query =
"DELETE FROM il_subscribers ".
1204 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1205 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1221 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1223 $ilErr->setMessage(
'');
1224 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1228 $query =
"DELETE FROM il_subscribers ".
1229 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1230 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1245 $query =
"SELECT * FROM il_subscribers ".
1246 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1247 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1267 $query =
"SELECT * FROM il_subscribers ".
1268 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1269 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1288 $this->subscribers = array();
1290 $query =
"SELECT usr_id FROM il_subscribers ".
1291 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1292 "ORDER BY sub_time ";
1302 $this->subscribers[] =
$row->usr_id;
1316 $query =
"SELECT * FROM il_subscribers ".
1317 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1318 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1334 $query =
'SELECT * FROM il_subscribers '.
1335 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');