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 AS ua ".
100 "JOIN rbac_fa AS fa ON ua.rol_id = fa.rol_id ".
101 "JOIN tree AS t1 ON t1.child = fa.parent ".
102 "JOIN object_reference AS obr ON t1.parent = obr.ref_id ".
103 "JOIN object_data AS obd ON obr.obj_id = obd.obj_id ".
104 "WHERE obd.type = ".$ilDB->quote($a_type).
" ".
105 "AND fa.assign = 'y' ".
106 "AND ua.usr_id = ".$ilDB->quote($a_usr_id).
" ";
107 $res = $ilDB->query($query);
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).
" ".
160 "AND usr_id = ".$ilDB->quote($a_usr_id).
" ".
162 $res = $ilDB->query($query);
163 return $res->numRows() ?
true :
false;
179 $query =
"SELECT * FROM crs_members ".
180 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ".
181 "AND usr_id = ".$ilDB->quote($a_usr_id).
" ".
183 $res = $ilDB->query($query);
184 return $res->numRows() ?
true :
false;
200 $query =
"DELETE FROM crs_members ".
201 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ";
203 $ilDB->query($query);
205 $query =
"DELETE FROM il_subscribers ".
206 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
"";
208 $ilDB->query($query);
225 $query =
"DELETE FROM crs_members WHERE usr_id = ".$ilDB->quote($a_usr_id).
"";
226 $ilDB->query($query);
228 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id).
"";
229 $ilDB->query($query);
231 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
245 $query =
"SELECT * FROM crs_members ".
246 "WHERE notification = 1 ".
247 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
248 $res = $ilDB->query($query);
253 $recp[] = $row->usr_id;
256 return $recp ? $recp : array();
267 return count($this->members);
278 return count($this->participants);
292 return $this->participants ? $this->participants : array();
304 return $this->members ? $this->members : array();
314 return $this->admins ? $this->admins : array();
324 return $this->tutors ? $this->tutors : array();
336 return in_array($a_usr_id,$this->admins) ?
true :
false;
348 return in_array($a_usr_id,$this->tutors) ?
true :
false;
360 return in_array($a_usr_id,$this->members) ?
true :
false;
375 return in_array($a_usr_id,$this->participants);
387 return $this->roles ? $this->roles : array();
401 foreach($this->roles as $role)
403 if($rbacreview->isAssigned($a_usr_id,$role))
408 return $assigned ? $assigned : array();
421 global $rbacreview,$rbacadmin;
423 $roles = $a_roles ? $a_roles : array();
425 foreach($this->
getRoles() as $role_id)
427 if($rbacreview->isAssigned($a_usr_id,$role_id))
429 if(!in_array($role_id,
$roles))
431 $rbacadmin->deassignUser($role_id,$a_usr_id);
436 if(in_array($role_id,
$roles))
438 $rbacadmin->assignUser($role_id,$a_usr_id);
457 if(!in_array($admin_id,$a_usr_ids))
474 if(isset($this->participants_status[$a_usr_id]))
476 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
490 if(isset($this->participants_status[$a_usr_id]))
492 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
504 public function delete($a_usr_id)
506 global $rbacadmin,
$ilDB;
509 foreach($this->roles as $role_id)
511 $rbacadmin->deassignUser($role_id,$a_usr_id);
514 $query =
"DELETE FROM crs_members ".
515 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
516 "AND obj_id = ".$ilDB->quote($this->obj_id);
517 $ilDB->query($query);
537 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
539 $query =
"SELECT * FROM crs_members ".
540 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
541 "AND usr_id = ".$ilDB->quote($a_usr_id);
542 $res = $ilDB->query($query);
545 $query =
"UPDATE crs_members SET ".
546 "blocked = ".$ilDB->quote((
int) $a_blocked).
" ".
547 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
548 "AND usr_id = ".$ilDB->quote($a_usr_id);
552 $query =
"INSERT INTO crs_members SET ".
553 "blocked = ".$ilDB->quote((
int) $a_blocked).
", ".
554 "obj_id = ".$ilDB->quote($this->obj_id).
", ".
555 "usr_id = ".$ilDB->quote($a_usr_id);
558 $res = $ilDB->query($query);
574 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
576 $query =
"SELECT * FROM crs_members ".
577 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
578 "AND usr_id = ".$ilDB->quote($a_usr_id);
579 $res = $ilDB->query($query);
582 $query =
"UPDATE crs_members SET ".
583 "notification = ".$ilDB->quote((
int) $a_notification).
" ".
584 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
585 "AND usr_id = ".$ilDB->quote($a_usr_id);
589 $query =
"INSERT INTO crs_members SET ".
590 "notification = ".$ilDB->quote((
int) $a_notification).
", ".
591 "obj_id = ".$ilDB->quote($this->obj_id).
", ".
592 "usr_id = ".$ilDB->quote($a_usr_id).
", ".
596 $res = $ilDB->query($query);
611 public function add($a_usr_id,$a_role)
613 global $rbacadmin,
$ilLog,$ilAppEventHandler;
623 $this->admins[] = $a_usr_id;
627 $this->tutors[] = $a_usr_id;
631 $this->members[] = $a_usr_id;
635 $this->admins[] = $a_usr_id;
639 $this->members[] = $a_usr_id;
642 $this->participants[] = $a_usr_id;
643 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
646 if($this->type ==
'crs') {
648 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
649 $ilAppEventHandler->raise(
"Modules/Course",
"addParticipant", array(
'usr_id' => $a_usr_id,
'role_id' => $a_role));
664 foreach($a_user_ids as $user_id)
666 $this->
delete($user_id);
715 if(isset($this->participants_status[$a_usr_id]))
717 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
732 global $rbacreview,$ilObjDataCache,
$ilLog;
734 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
735 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
737 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
738 $ilLog->write(__METHOD__.
': Found object without role folder. Ref_id: '.$this->ref_id.
', title: '.
$title);
743 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
746 $this->participants = array();
747 $this->members = $this->admins = $this->tutors = array();
748 foreach($this->roles as $role_id)
750 $title = $ilObjDataCache->lookupTitle($role_id);
751 switch(substr(
$title,0,8))
755 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
756 $this->members = array_unique(array_merge($assigned,$this->members));
761 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
762 $this->admins = $rbacreview->assignedUsers($role_id);
767 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
768 $this->tutors = $rbacreview->assignedUsers($role_id);
773 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
774 $this->admins = $rbacreview->assignedUsers($role_id);
779 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
780 $this->members = $rbacreview->assignedUsers($role_id);
784 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
785 $this->members = array_unique(array_merge($assigned,$this->members));
802 $query =
"SELECT * FROM crs_members ".
803 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ";
804 $res = $ilDB->query($query);
805 $this->participants_status = array();
808 $this->participants_status[$row->usr_id][
'blocked'] = $row->blocked;
809 $this->participants_status[$row->usr_id][
'notification'] = $row->notification;
810 $this->participants_status[$row->usr_id][
'passed'] = $row->passed;
823 global $rbacreview,$ilObjDataCache,
$ilDB;
828 include_once
'./Services/User/classes/class.ilObjUser.php';
834 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin()).
" ";
837 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail()).
" ";
839 case 'matriculation':
840 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation()).
" ";
844 $and =
"AND usr_id = '".$a_usr_id.
"'";
853 $query =
"SELECT * FROM usr_data as ud ".
856 $res = $ilDB->query($query);
857 return $res->numRows() ?
true :
false;
903 if(!is_array($a_usr_ids) or !count($a_usr_ids))
907 foreach($a_usr_ids as $id)
926 $ilErr->setMessage(
"");
929 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
936 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
943 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
965 foreach($this->subscribers as $subscriber)
974 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
991 $query =
"INSERT INTO il_subscribers ".
992 " VALUES (".$ilDB->quote($a_usr_id).
",".$ilDB->quote($this->obj_id).
",'', ".$ilDB->quote(time()).
")";
993 $res = $this->ilDB->query($query);
1008 $query =
"UPDATE il_subscribers ".
1009 "SET sub_time = ".$ilDB->quote($a_subtime).
" ".
1010 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
1011 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
1013 $ilDB->query($query);
1029 $query =
"UPDATE il_subscribers ".
1030 "SET subject = ".$ilDB->quote($a_subject).
" ".
1031 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
1032 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
1033 $ilDB->query($query);
1047 $query =
"DELETE FROM il_subscribers ".
1048 "WHERE usr_id = ".$a_usr_id.
" ".
1049 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
1051 $res = $ilDB->query($query);
1066 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1068 $ilErr->setMessage(
'');
1069 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1073 foreach($a_usr_ids as $id)
1077 $ilErr->appendMessage($this->lng->txt(
"error_delete_subscriber"));
1095 $query =
"SELECT * FROM il_subscribers ".
1096 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
1097 "AND obj_id = ".$ilDB->quote($this->obj_id).
"";
1099 $res = $ilDB->query($query);
1118 $query =
"SELECT * FROM il_subscribers ".
1119 "WHERE usr_id = ".$ilDB->quote($a_usr_id).
" ".
1120 "AND obj_id = ".$ilDB->quote($a_obj_id).
"";
1122 $res = $ilDB->query($query);
1140 $this->subscribers = array();
1142 $query =
"SELECT usr_id FROM il_subscribers ".
1143 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
1144 "ORDER BY sub_time ";
1146 $res = $this->ilDB->query($query);
1154 $this->subscribers[] = $row->usr_id;
1168 $query =
"SELECT * FROM il_subscribers ".
1169 "WHERE obj_id = ".$ilDB->quote($this->obj_id).
" ".
1170 "AND usr_id = ".$ilDB->quote($a_usr_id).
"";
1172 $res = $this->ilDB->query($query);
1175 $data[
"time"] = $row->sub_time;
1176 $data[
"usr_id"] = $row->usr_id;
1177 $data[
'subject'] = $row->subject;