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);
57 $this->component = $a_component_name;
59 $this->obj_id = $a_obj_id;
62 $this->ref_id = current($ref_ids);
81 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
85 include_once
'./Modules/Group/classes/class.ilGroupParticipants.php';
89 include_once
'./Modules/Session/classes/class.ilSessionParticipants.php';
94 $GLOBALS[
'ilLog']->write(__METHOD__.
': Invalid obj_id given: '.$a_obj_id);
95 throw new InvalidArgumentException(
'Invalid obj id given');
119 $a_usr_id =
$GLOBALS[
'ilUser']->getId();
131 if($part->isAssigned($a_usr_id))
133 if($part->getType() ==
'crs')
136 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
164 if ($a_only_member_role)
166 $j2 =
"JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
167 $a2 =
"AND obd2.title LIKE 'il_".$a_type.
"_mem%' ";
171 $query =
"SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua ".
172 "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id ".
173 "JOIN object_reference obr ON fa.parent = obr.ref_id ".
174 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
176 "WHERE obd.type = ".$ilDB->quote($a_type,
'text').
" ".
177 "AND fa.assign = 'y' ".
178 "AND ua.usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
182 while(
$row = $ilDB->fetchObject(
$res))
184 $ref_ids[] =
$row->obj_id;
187 return $ref_ids ? $ref_ids : array();
204 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
206 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
220 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
221 return $rbacreview->getNumberOfAssignedUsers($lroles);
233 global $rbacreview, $ilObjDataCache;
235 $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
241 $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
243 $memberRoles = array();
244 foreach($lroles as $role_id)
246 $title = $ilObjDataCache->lookupTitle($role_id);
247 switch(substr($title,0,8))
255 $memberRoles[] = $role_id;
259 return $rbacreview->getNumberOfAssignedUsers($memberRoles);
276 $query =
"SELECT * FROM obj_members ".
277 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
278 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ".
279 "AND blocked = ".$ilDB->quote(1,
'integer');
281 return $res->numRows() ?
true :
false;
297 $query =
"SELECT * FROM obj_members ".
298 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
299 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
302 return $res->numRows() ?
true :
false;
318 $query =
"DELETE FROM obj_members ".
319 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
322 $query =
"DELETE FROM il_subscribers ".
323 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
326 $query =
'DELETE FROM crs_waiting_list '.
327 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
328 $ilDB->manipulate(
$query);
345 $query =
"DELETE FROM obj_members WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
348 $query =
"DELETE FROM il_subscribers WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
351 include_once
'./Modules/Course/classes/class.ilCourseWaitingList.php';
362 if(!in_array(
$type,array(
'crs',
'grp')))
370 $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
375 if(substr($title, 0, 13) == (
'il_'.
$type.
'_member'))
411 $query =
"SELECT * FROM obj_members ".
412 "WHERE notification = 1 ".
413 "AND obj_id = ".$ilDB->quote($this->obj_id).
" ";
419 $recp[] =
$row->usr_id;
422 return $recp ? $recp : array();
433 return count($this->members);
444 return count($this->participants);
458 return $this->participants ? $this->participants : array();
470 return $this->members ? $this->members : array();
480 return $this->admins ? $this->admins : array();
501 return $this->tutors ? $this->tutors : array();
513 return in_array($a_usr_id,$this->admins) ?
true :
false;
525 return in_array($a_usr_id,$this->tutors) ?
true :
false;
537 return in_array($a_usr_id,$this->members) ?
true :
false;
552 return in_array($a_usr_id,$this->participants);
575 return $this->roles ? $this->roles : array();
589 foreach($this->roles as $role)
591 if($rbacreview->isAssigned($a_usr_id,$role))
596 return $assigned ? $assigned : array();
609 global $rbacreview,$rbacadmin;
611 $roles = $a_roles ? $a_roles : array();
613 foreach($this->
getRoles() as $role_id)
615 if($rbacreview->isAssigned($a_usr_id,$role_id))
617 if(!in_array($role_id,
$roles))
619 $rbacadmin->deassignUser($role_id,$a_usr_id);
624 if(in_array($role_id,
$roles))
626 $rbacadmin->assignUser($role_id,$a_usr_id);
645 if(!in_array($admin_id,$a_usr_ids))
662 if(isset($this->participants_status[$a_usr_id]))
664 return $this->participants_status[$a_usr_id][
'blocked'] ?
true :
false;
678 if(isset($this->participants_status[$a_usr_id]))
680 return $this->participants_status[$a_usr_id][
'passed'] ?
true :
false;
692 public function delete($a_usr_id)
694 global $rbacadmin,
$ilDB;
697 foreach($this->roles as $role_id)
699 $rbacadmin->deassignUser($role_id,$a_usr_id);
702 $query =
"DELETE FROM obj_members ".
703 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
704 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
710 $GLOBALS[
'ilAppEventHandler']->raise(
714 'obj_id' => $this->obj_id,
715 'usr_id' => $a_usr_id)
733 $this->participants_status[$a_usr_id][
'blocked'] = (int) $a_blocked;
735 $query =
"SELECT * FROM obj_members ".
736 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
737 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
741 $query =
"UPDATE obj_members SET ".
742 "blocked = ".$ilDB->quote((
int) $a_blocked ,
'integer').
" ".
743 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
744 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
748 $query =
"INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) ".
750 $ilDB->quote((
int) $a_blocked ,
'integer').
", ".
751 $ilDB->quote($this->obj_id ,
'integer').
", ".
752 $ilDB->quote($a_usr_id ,
'integer').
", ".
753 $ilDB->quote(0,
'integer').
", ".
754 $ilDB->quote(0,
'integer').
774 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
776 $query =
"SELECT * FROM obj_members ".
777 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
778 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
782 $query =
"UPDATE obj_members SET ".
783 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
784 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
785 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
789 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
791 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
792 $ilDB->quote($this->obj_id ,
'integer').
", ".
793 $ilDB->quote($a_usr_id ,
'integer').
", ".
794 $ilDB->quote(0,
'integer').
", ".
795 $ilDB->quote(0,
'integer').
814 public function add($a_usr_id,$a_role)
816 global $rbacadmin,
$ilLog,$ilAppEventHandler;
826 $this->admins[] = $a_usr_id;
830 $this->tutors[] = $a_usr_id;
834 $this->members[] = $a_usr_id;
838 $this->admins[] = $a_usr_id;
842 $this->members[] = $a_usr_id;
846 $this->participants[] = $a_usr_id;
847 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
853 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
856 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course|Group addParticipant');
857 $ilAppEventHandler->raise(
861 'obj_id' => $this->obj_id,
862 'usr_id' => $a_usr_id,
863 'role_id' => $a_role)
878 foreach($a_user_ids as $user_id)
880 $this->
delete($user_id);
929 if(isset($this->participants_status[$a_usr_id]))
931 return $this->participants_status[$a_usr_id][
'notification'] ?
true :
false;
946 global $rbacreview,$ilObjDataCache,
$ilLog;
948 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
951 $this->participants = array();
952 $this->members = $this->admins = $this->tutors = array();
954 foreach($this->roles as $role_id)
956 $title = $ilObjDataCache->lookupTitle($role_id);
957 switch(substr($title,0,8))
961 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
962 $this->members = array_unique(array_merge($assigned,$this->members));
967 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
968 $this->admins = $rbacreview->assignedUsers($role_id);
973 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
974 $this->tutors = $rbacreview->assignedUsers($role_id);
979 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
980 $this->admins = $rbacreview->assignedUsers($role_id);
985 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
986 $this->members = $rbacreview->assignedUsers($role_id);
990 $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id),
$this->participants));
991 $this->members = array_unique(array_merge($assigned,$this->members));
1008 $query =
"SELECT * FROM obj_members ".
1009 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1011 $this->participants_status = array();
1014 $this->participants_status[
$row->usr_id][
'blocked'] =
$row->blocked;
1015 $this->participants_status[
$row->usr_id][
'notification'] =
$row->notification;
1016 $this->participants_status[
$row->usr_id][
'passed'] =
$row->passed;
1029 global $rbacreview,$ilObjDataCache,
$ilDB;
1034 include_once
'./Services/User/classes/class.ilObjUser.php';
1040 $and =
"AND login = ".$ilDB->quote($tmp_user->getLogin(),
'text').
" ";
1043 $and =
"AND email = ".$ilDB->quote($tmp_user->getEmail(),
'text').
" ";
1045 case 'matriculation':
1046 $and =
"AND matriculation = ".$ilDB->quote($tmp_user->getMatriculation(),
'text').
" ";
1050 $and =
"AND usr_id = ".$ilDB->quote($a_usr_id,
'integer').
" ";
1059 $query =
"SELECT * FROM usr_data ud ".
1060 "WHERE ".$ilDB->in(
'usr_id',$this->
getParticipants(),
false,
'integer').
" ".
1064 return $res->numRows() ?
true :
false;
1073 $query =
"SELECT usr_id FROM il_subscribers ".
1074 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
1075 "ORDER BY sub_time ";
1127 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1131 foreach($a_usr_ids as $id)
1150 $ilErr->setMessage(
"");
1153 $ilErr->appendMessage($this->lng->txt(
"crs_user_notsubscribed"));
1160 $ilErr->appendMessage($tmp_obj->getLogin().
": ".$this->lng->txt(
"crs_user_already_assigned"));
1167 $ilErr->appendMessage($this->lng->txt(
"crs_user_not_exists"));
1189 foreach($this->subscribers as $subscriber)
1198 #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1215 $query =
"INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) ".
1217 $ilDB->quote($a_usr_id ,
'integer').
",".
1218 $ilDB->quote($this->obj_id ,
'integer').
", ".
1219 $ilDB->quote(
'',
'text').
", ".
1220 $ilDB->quote(time() ,
'integer').
1237 $query =
"UPDATE il_subscribers ".
1238 "SET sub_time = ".$ilDB->quote($a_subtime ,
'integer').
" ".
1239 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1240 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1257 $query =
"UPDATE il_subscribers ".
1258 "SET subject = ".$ilDB->quote($a_subject ,
'text').
" ".
1259 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1260 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1275 $query =
"DELETE FROM il_subscribers ".
1276 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1277 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
1293 if(!is_array($a_usr_ids) or !count($a_usr_ids))
1295 $ilErr->setMessage(
'');
1296 $ilErr->appendMessage($this->lng->txt(
"no_usr_ids_given"));
1300 $query =
"DELETE FROM il_subscribers ".
1301 "WHERE ".$ilDB->in(
'usr_id',(array) $a_usr_ids,
false,
'integer').
" ".
1302 "AND obj_id = ".$ilDB->quote($this->obj_id,
'integer');
1317 $query =
"SELECT * FROM il_subscribers ".
1318 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1319 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
"";
1339 $query =
"SELECT * FROM il_subscribers ".
1340 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
1341 "AND obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
"";
1360 $this->subscribers = array();
1362 $query =
"SELECT usr_id FROM il_subscribers ".
1363 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1364 "ORDER BY sub_time ";
1374 $this->subscribers[] =
$row->usr_id;
1388 $query =
"SELECT * FROM il_subscribers ".
1389 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
1390 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
"";
1395 $data[
"time"] =
$row->sub_time;
1396 $data[
"usr_id"] =
$row->usr_id;
1397 $data[
'subject'] =
$row->subject;
1399 return $data ? $data : array();
1406 $query =
'SELECT * FROM il_subscribers '.
1407 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1413 $data[
$row->usr_id][
'time'] =
$row->sub_time;
1414 $data[
$row->usr_id][
'usr_id'] =
$row->usr_id;
1415 $data[
$row->usr_id][
'subject'] =
$row->subject;