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');
691 if($this->type ==
'crs')
694 $GLOBALS[
'ilAppEventHandler']->raise(
"Modules/Course",
"deleteParticipant", array(
'obj_id' => $this->obj_id,
'usr_id' => $a_usr_id));
713 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
715 $query =
"SELECT * FROM obj_members ".
716 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
717 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
721 $query =
"UPDATE obj_members SET ".
722 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
723 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
724 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
728 $query =
"INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) ".
730 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
731 $ilDB->quote($this->obj_id ,
'integer').
", ".
732 $ilDB->quote($a_usr_id ,
'integer').
", ".
733 $ilDB->quote(0,
'integer').
", ".
734 $ilDB->quote(0,
'integer').
754 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
756 $query =
"SELECT * FROM obj_members ".
757 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
758 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
762 $query =
"UPDATE obj_members SET ".
763 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
764 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
765 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
769 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
771 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
772 $ilDB->quote($this->obj_id ,
'integer').
", ".
773 $ilDB->quote($a_usr_id ,
'integer').
", ".
774 $ilDB->quote(0,
'integer').
", ".
775 $ilDB->quote(0,
'integer').
794 public function add($a_usr_id,$a_role)
796 global $rbacadmin,
$ilLog,$ilAppEventHandler;
806 $this->admins[] = $a_usr_id;
810 $this->tutors[] = $a_usr_id;
814 $this->members[] = $a_usr_id;
818 $this->admins[] = $a_usr_id;
822 $this->members[] = $a_usr_id;
826 $this->participants[] = $a_usr_id;
827 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
833 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
836 if($this->type ==
'crs') {
838 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
839 $ilAppEventHandler->raise(
843 'obj_id' => $this->obj_id,
844 'usr_id' => $a_usr_id,
845 'role_id' => $a_role)
861 foreach($a_user_ids as $user_id)
863 $this->
delete($user_id);
912 if(isset($this->participants_status[$a_usr_id]))
914 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
929 global $rbacreview,$ilObjDataCache,
$ilLog;
931 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
933 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
935 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
936 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.$title);
941 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
944 $this->participants = array();
945 $this->members = $this->admins = $this->tutors = array();
947 foreach($this->roles as $role_id)
949 $title = $ilObjDataCache->lookupTitle($role_id);
950 switch(substr($title,0,8))
954 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
955 $this->members = array_unique(array_merge($assigned,$this->members));
960 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
961 $this->admins = $rbacreview->assignedUsers($role_id);
966 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
967 $this->tutors = $rbacreview->assignedUsers($role_id);
972 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
973 $this->admins = $rbacreview->assignedUsers($role_id);
978 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
979 $this->members = $rbacreview->assignedUsers($role_id);
983 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
984 $this->members = array_unique(array_merge($assigned,$this->members));
1001 $query =
"SELECT * FROM obj_members ".
1002 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1004 $this->participants_status = array();
1007 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
1008 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
1009 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
1022 global $rbacreview,$ilObjDataCache,
$ilDB;
1027 include_once
'./Services/User/classes/class.ilObjUser.php';
1033 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
1036 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
1038 case 'matriculation':
1039 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
1043 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
1052 $query =
"SELECT * FROM usr_data ud ".
1053 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
1057 return $res->numRows() ?
true :
false;
1066 $query =
"SELECT usr_id FROM il_subscribers ".
1067 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1068 "ORDER BY sub_time ";
1120 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1124 foreach($a_usr_ids as $id)
1143 $ilErr->setMessage(
"");
1146 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1153 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1160 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1182 foreach($this->subscribers as $subscriber)
1191 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1208 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1210 $ilDB->quote($a_usr_id ,
'integer').
",".
1211 $ilDB->quote($this->obj_id ,
'integer').
", ".
1212 $ilDB->quote(
'',
'text').
", ".
1213 $ilDB->quote(time() ,
'integer').
1230 $query =
"UPDATE il_subscribers ".
1231 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1232 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1233 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1250 $query =
"UPDATE il_subscribers ".
1251 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1252 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1253 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1268 $query =
"DELETE FROM il_subscribers ".
1269 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1270 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1286 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1288 $ilErr->setMessage(
'');
1289 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1293 $query =
"DELETE FROM il_subscribers ".
1294 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1295 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1310 $query =
"SELECT * FROM il_subscribers ".
1311 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1312 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1332 $query =
"SELECT * FROM il_subscribers ".
1333 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1334 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1353 $this->subscribers = array();
1355 $query =
"SELECT usr_id FROM il_subscribers ".
1356 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1357 "ORDER BY sub_time ";
1367 $this->subscribers[] =
$row->usr_id;
1381 $query =
"SELECT * FROM il_subscribers ".
1382 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1383 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1388 $data[
"time"] =
$row->sub_time;
1389 $data[
"usr_id"] =
$row->usr_id;
1390 $data[
'subject'] =
$row->subject;
1392 return $data ? $data : array();
1399 $query =
'SELECT * FROM il_subscribers '.
1400 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1406 $data[
$row->usr_id][
'time'] =
$row->sub_time;
1407 $data[
$row->usr_id][
'usr_id'] =
$row->usr_id;
1408 $data[
$row->usr_id][
'subject'] =
$row->subject;