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);
99 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
100 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
101 "JOIN tree t1 ON t1.child = fa.parent ".
102 "JOIN object_reference obr ON t1.parent = obr.ref_id ".
103 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
104 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
105 "AND fa.assign = 'y' ".
106 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
109 while(
$row = $ilDB->fetchObject(
$res))
111 $ref_ids[] =
$row->obj_id;
114 return $ref_ids ? $ref_ids : array();
131 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
132 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
134 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($a_ref_id));
135 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$a_ref_id.
', title: '.
$title);
140 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
142 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
158 $query =
"SELECT * FROM crs_members ".
159 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
160 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
161 "AND blocked = ".$ilDB->quote(1,
'integer');
163 return $res->numRows() ?
true :
false;
179 $query =
"SELECT * FROM crs_members ".
180 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
181 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
184 return $res->numRows() ?
true :
false;
200 $query =
"DELETE FROM crs_members ".
201 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
204 $query =
"DELETE FROM il_subscribers ".
205 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
223 $query =
"DELETE FROM crs_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
226 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
229 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
240 if(!in_array(
$type,array(
'crs',
'grp')))
248 $rolf = $rbacreview->getRoleFolderIdOfObject($a_ref_id);
249 $roles = $rbacreview->getRolesOfRoleFolder($rolf,
false);
254 if(substr(
$title, 0, 13) == (
'il_'.
$type.
'_member'))
272 $query =
"SELECT * FROM crs_members ".
273 "WHERE notification = 1 ".
274 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
280 $recp[] =
$row->usr_id;
283 return $recp ? $recp : array();
294 return count($this->members);
305 return count($this->participants);
319 return $this->participants ? $this->participants : array();
331 return $this->members ? $this->members : array();
341 return $this->admins ? $this->admins : array();
351 return $this->tutors ? $this->tutors : array();
363 return in_array($a_usr_id,$this->admins) ?
true :
false;
375 return in_array($a_usr_id,$this->tutors) ?
true :
false;
387 return in_array($a_usr_id,$this->members) ?
true :
false;
402 return in_array($a_usr_id,$this->participants);
425 return $this->roles ? $this->roles : array();
439 foreach($this->roles as $role)
441 if($rbacreview->isAssigned($a_usr_id,$role))
446 return $assigned ? $assigned : array();
459 global $rbacreview,$rbacadmin;
461 $roles = $a_roles ? $a_roles : array();
463 foreach($this->
getRoles() as $role_id)
465 if($rbacreview->isAssigned($a_usr_id,$role_id))
467 if(!in_array($role_id,
$roles))
469 $rbacadmin->deassignUser($role_id,$a_usr_id);
474 if(in_array($role_id,
$roles))
476 $rbacadmin->assignUser($role_id,$a_usr_id);
495 if(!in_array($admin_id,$a_usr_ids))
512 if(isset($this->participants_status[$a_usr_id]))
514 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
528 if(isset($this->participants_status[$a_usr_id]))
530 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
542 public function delete($a_usr_id)
544 global $rbacadmin,
$ilDB;
547 foreach($this->roles as $role_id)
549 $rbacadmin->deassignUser($role_id,$a_usr_id);
552 $query =
"DELETE FROM crs_members ".
553 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
554 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
575 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
577 $query =
"SELECT * FROM crs_members ".
578 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
579 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
583 $query =
"UPDATE crs_members SET ".
584 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
585 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
586 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
590 $query =
"INSERT INTO crs_members (blocked,obj_id,usr_id,notification,passed) ".
592 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
593 $ilDB->quote($this->obj_id ,
'integer').
", ".
594 $ilDB->quote($a_usr_id ,
'integer').
", ".
595 $ilDB->quote(0,
'integer').
", ".
596 $ilDB->quote(0,
'integer').
616 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
618 $query =
"SELECT * FROM crs_members ".
619 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
620 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
624 $query =
"UPDATE crs_members SET ".
625 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
626 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
627 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
631 $query =
"INSERT INTO crs_members (notification,obj_id,usr_id,passed,blocked) ".
633 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
634 $ilDB->quote($this->obj_id ,
'integer').
", ".
635 $ilDB->quote($a_usr_id ,
'integer').
", ".
636 $ilDB->quote(0,
'integer').
", ".
637 $ilDB->quote(0,
'integer').
656 public function add($a_usr_id,$a_role)
658 global $rbacadmin,
$ilLog,$ilAppEventHandler;
668 $this->admins[] = $a_usr_id;
672 $this->tutors[] = $a_usr_id;
676 $this->members[] = $a_usr_id;
680 $this->admins[] = $a_usr_id;
684 $this->members[] = $a_usr_id;
687 $this->participants[] = $a_usr_id;
688 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
694 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
697 if($this->type ==
'crs') {
699 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
700 $ilAppEventHandler->raise(
"Modules/Course",
"addParticipant", array(
'usr_id' => $a_usr_id,
'role_id' => $a_role));
715 foreach($a_user_ids as $user_id)
717 $this->
delete($user_id);
766 if(isset($this->participants_status[$a_usr_id]))
768 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
783 global $rbacreview,$ilObjDataCache,
$ilLog;
785 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
786 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
788 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
789 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.
$title);
794 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
797 $this->participants = array();
798 $this->members = $this->admins = $this->tutors = array();
799 foreach($this->roles as $role_id)
801 $title = $ilObjDataCache->lookupTitle($role_id);
802 switch(substr(
$title,0,8))
806 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
807 $this->members = array_unique(array_merge($assigned,$this->members));
812 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
813 $this->admins = $rbacreview->assignedUsers($role_id);
818 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
819 $this->tutors = $rbacreview->assignedUsers($role_id);
824 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
825 $this->admins = $rbacreview->assignedUsers($role_id);
830 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
831 $this->members = $rbacreview->assignedUsers($role_id);
835 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
836 $this->members = array_unique(array_merge($assigned,$this->members));
853 $query =
"SELECT * FROM crs_members ".
854 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
856 $this->participants_status = array();
859 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
860 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
861 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
874 global $rbacreview,$ilObjDataCache,
$ilDB;
879 include_once
'./Services/User/classes/class.ilObjUser.php';
885 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
888 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
890 case 'matriculation':
891 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
895 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
904 $query =
"SELECT * FROM usr_data ud ".
905 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
909 return $res->numRows() ?
true :
false;
955 if(!is_array($a_usr_ids) or !count($a_usr_ids))
959 foreach($a_usr_ids as $id)
978 $ilErr->setMessage(
"");
981 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
988 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
995 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1017 foreach($this->subscribers as $subscriber)
1026 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1043 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1045 $ilDB->quote($a_usr_id ,
'integer').
",".
1046 $ilDB->quote($this->obj_id ,
'integer').
", ".
1047 $ilDB->quote(
'',
'text').
", ".
1048 $ilDB->quote(time() ,
'integer').
1065 $query =
"UPDATE il_subscribers ".
1066 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1067 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1068 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1085 $query =
"UPDATE il_subscribers ".
1086 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1087 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1088 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1103 $query =
"DELETE FROM il_subscribers ".
1104 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1105 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1121 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1123 $ilErr->setMessage(
'');
1124 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1128 foreach($a_usr_ids as $id)
1132 $ilErr->appendMessage($this->lng->txt(
"error_delete_subscriber"));
1150 $query =
"SELECT * FROM il_subscribers ".
1151 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1152 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1172 $query =
"SELECT * FROM il_subscribers ".
1173 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1174 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1193 $this->subscribers = array();
1195 $query =
"SELECT usr_id FROM il_subscribers ".
1196 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1197 "ORDER BY sub_time ";
1207 $this->subscribers[] =
$row->usr_id;
1221 $query =
"SELECT * FROM il_subscribers ".
1222 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1223 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";