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);
98 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
99 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
100 "JOIN tree t1 ON t1.child = fa.parent ".
101 "JOIN object_reference obr ON t1.parent = obr.ref_id ".
102 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
103 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
104 "AND fa.assign = 'y' ".
105 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
108 while(
$row = $ilDB->fetchObject(
$res))
110 $ref_ids[] =
$row->obj_id;
113 return $ref_ids ? $ref_ids : array();
130 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
131 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
133 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($a_ref_id));
134 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$a_ref_id.
', title: '.
$title);
139 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
141 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
157 $query =
"SELECT * FROM crs_members ".
158 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
159 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
160 "AND blocked = ".$ilDB->quote(1,
'integer');
162 return $res->numRows() ?
true :
false;
178 $query =
"SELECT * FROM crs_members ".
179 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
180 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
183 return $res->numRows() ?
true :
false;
199 $query =
"DELETE FROM crs_members ".
200 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
203 $query =
"DELETE FROM il_subscribers ".
204 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
222 $query =
"DELETE FROM crs_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
225 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
228 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
239 if(!in_array(
$type,array(
'crs',
'grp')))
247 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
248 $roles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
253 if(substr(
$title, 0, 13) == (
'il_'.
$type.
'_member'))
271 $query =
"SELECT * FROM crs_members ".
272 "WHERE notification = 1 ".
273 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
279 $recp[] =
$row->usr_id;
282 return $recp ? $recp : array();
293 return count($this->members);
304 return count($this->participants);
318 return $this->participants ? $this->participants : array();
330 return $this->members ? $this->members : array();
340 return $this->admins ? $this->admins : array();
361 return $this->tutors ? $this->tutors : array();
373 return in_array($a_usr_id,$this->admins) ?
true :
false;
385 return in_array($a_usr_id,$this->tutors) ?
true :
false;
397 return in_array($a_usr_id,$this->members) ?
true :
false;
412 return in_array($a_usr_id,$this->participants);
435 return $this->roles ? $this->roles : array();
449 foreach($this->roles as $role)
451 if($rbacreview->isAssigned($a_usr_id,$role))
456 return $assigned ? $assigned : array();
469 global $rbacreview,$rbacadmin;
471 $roles = $a_roles ? $a_roles : array();
473 foreach($this->
getRoles() as $role_id)
475 if($rbacreview->isAssigned($a_usr_id,$role_id))
477 if(!in_array($role_id,
$roles))
479 $rbacadmin->deassignUser($role_id,$a_usr_id);
484 if(in_array($role_id,
$roles))
486 $rbacadmin->assignUser($role_id,$a_usr_id);
505 if(!in_array($admin_id,$a_usr_ids))
522 if(isset($this->participants_status[$a_usr_id]))
524 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
538 if(isset($this->participants_status[$a_usr_id]))
540 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
552 public function delete($a_usr_id)
554 global $rbacadmin,
$ilDB;
557 foreach($this->roles as $role_id)
559 $rbacadmin->deassignUser($role_id,$a_usr_id);
562 $query =
"DELETE FROM crs_members ".
563 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
564 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
585 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
587 $query =
"SELECT * FROM crs_members ".
588 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
589 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
593 $query =
"UPDATE crs_members SET ".
594 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
595 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
596 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
600 $query =
"INSERT INTO crs_members (blocked,obj_id,usr_id,notification,passed) ".
602 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
603 $ilDB->quote($this->obj_id ,
'integer').
", ".
604 $ilDB->quote($a_usr_id ,
'integer').
", ".
605 $ilDB->quote(0,
'integer').
", ".
606 $ilDB->quote(0,
'integer').
626 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
628 $query =
"SELECT * FROM crs_members ".
629 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
630 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
634 $query =
"UPDATE crs_members SET ".
635 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
636 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
637 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
641 $query =
"INSERT INTO crs_members (notification,obj_id,usr_id,passed,blocked) ".
643 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
644 $ilDB->quote($this->obj_id ,
'integer').
", ".
645 $ilDB->quote($a_usr_id ,
'integer').
", ".
646 $ilDB->quote(0,
'integer').
", ".
647 $ilDB->quote(0,
'integer').
666 public function add($a_usr_id,$a_role)
668 global $rbacadmin,
$ilLog,$ilAppEventHandler;
678 $this->admins[] = $a_usr_id;
682 $this->tutors[] = $a_usr_id;
686 $this->members[] = $a_usr_id;
690 $this->admins[] = $a_usr_id;
694 $this->members[] = $a_usr_id;
698 $this->participants[] = $a_usr_id;
699 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
705 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
708 if($this->type ==
'crs') {
710 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
711 $ilAppEventHandler->raise(
"Modules/Course",
"addParticipant", array(
'usr_id' => $a_usr_id,
'role_id' => $a_role));
726 foreach($a_user_ids as $user_id)
728 $this->
delete($user_id);
777 if(isset($this->participants_status[$a_usr_id]))
779 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
794 global $rbacreview,$ilObjDataCache,
$ilLog;
796 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
798 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
800 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
801 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.
$title);
806 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
809 $this->participants = array();
810 $this->members = $this->admins = $this->tutors = array();
812 foreach($this->roles as $role_id)
814 $title = $ilObjDataCache->lookupTitle($role_id);
815 switch(substr(
$title,0,8))
819 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
820 $this->members = array_unique(array_merge($assigned,$this->members));
825 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
826 $this->admins = $rbacreview->assignedUsers($role_id);
831 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
832 $this->tutors = $rbacreview->assignedUsers($role_id);
837 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
838 $this->admins = $rbacreview->assignedUsers($role_id);
843 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
844 $this->members = $rbacreview->assignedUsers($role_id);
848 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
849 $this->members = array_unique(array_merge($assigned,$this->members));
866 $query =
"SELECT * FROM crs_members ".
867 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
869 $this->participants_status = array();
872 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
873 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
874 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
887 global $rbacreview,$ilObjDataCache,
$ilDB;
892 include_once
'./Services/User/classes/class.ilObjUser.php';
898 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
901 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
903 case 'matriculation':
904 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
908 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
917 $query =
"SELECT * FROM usr_data ud ".
918 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
922 return $res->numRows() ?
true :
false;
968 if(!is_array($a_usr_ids) or !count($a_usr_ids))
972 foreach($a_usr_ids as $id)
991 $ilErr->setMessage(
"");
994 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1001 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1008 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1030 foreach($this->subscribers as $subscriber)
1039 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1056 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1058 $ilDB->quote($a_usr_id ,
'integer').
",".
1059 $ilDB->quote($this->obj_id ,
'integer').
", ".
1060 $ilDB->quote(
'',
'text').
", ".
1061 $ilDB->quote(time() ,
'integer').
1078 $query =
"UPDATE il_subscribers ".
1079 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1080 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1081 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1098 $query =
"UPDATE il_subscribers ".
1099 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1100 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1101 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1116 $query =
"DELETE FROM il_subscribers ".
1117 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1118 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1134 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1136 $ilErr->setMessage(
'');
1137 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1141 $query =
"DELETE FROM il_subscribers ".
1142 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1143 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1158 $query =
"SELECT * FROM il_subscribers ".
1159 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1160 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1180 $query =
"SELECT * FROM il_subscribers ".
1181 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1182 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1201 $this->subscribers = array();
1203 $query =
"SELECT usr_id FROM il_subscribers ".
1204 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1205 "ORDER BY sub_time ";
1215 $this->subscribers[] =
$row->usr_id;
1229 $query =
"SELECT * FROM il_subscribers ".
1230 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1231 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";