25 include_once
'./Services/Membership/classes/class.ilParticipants.php';
58 protected function __construct($a_component_name, $a_obj_id, $a_usr_id)
62 $this->obj_id = $a_obj_id;
63 $this->usr_id = $a_usr_id;
66 $this->ref_id = current($ref_ids);
68 $this->component = $a_component_name;
95 return (
bool) $this->participants_status[$this->
getUserId()][
'blocked'];
135 global $rbacreview,$ilObjDataCache,
$ilLog;
137 $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,
false);
140 $this->participants = array();
141 $this->members = $this->admins = $this->tutors = array();
143 $member_roles = array();
145 foreach($this->roles as $role_id)
147 $title = $ilObjDataCache->lookupTitle($role_id);
148 switch(substr($title,0,8))
151 $member_roles[] = $role_id;
153 if($rbacreview->isAssigned($this->getUserId(),$role_id))
155 $this->participants =
true;
156 $this->members =
true;
162 if($rbacreview->isAssigned($this->getUserId(),$role_id))
164 $this->participants =
true;
165 $this->admins =
true;
171 if($rbacreview->isAssigned($this->getUserId(),$role_id))
173 $this->participants =
true;
174 $this->tutors =
true;
180 if($rbacreview->isAssigned($this->getUserId(),$role_id))
182 $this->participants =
true;
183 $this->admins =
true;
188 $member_roles[] = $role_id;
190 if($rbacreview->isAssigned($this->getUserId(),$role_id))
192 $this->participants =
true;
193 $this->members =
true;
199 $member_roles[] = $role_id;
200 if($rbacreview->isAssigned($this->getUserId(),$role_id))
202 $this->participants =
true;
203 $this->members =
true;
208 $this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
219 $query =
"SELECT * FROM obj_members ".
220 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
221 'AND usr_id = '.$ilDB->quote($this->
getUserId(),
'integer');
224 $this->participants_status = array();
227 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
228 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
229 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
243 public function add($a_usr_id,$a_role)
245 global $rbacadmin,
$ilLog,$ilAppEventHandler,$rbacreview;
248 if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
256 $this->admins =
true;
260 $this->tutors =
true;
264 $this->members =
true;
268 $this->admins =
true;
272 $this->members =
true;
276 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
282 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
285 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
286 $ilAppEventHandler->raise(
290 'obj_id' => $this->obj_id,
291 'usr_id' => $a_usr_id,
292 'role_id' => $a_role)
304 public function delete($a_usr_id)
306 global $rbacadmin,
$ilDB, $ilAppEventHandler;
309 foreach($this->roles as $role_id)
311 $rbacadmin->deassignUser($role_id,$a_usr_id);
314 $query =
"DELETE FROM obj_members ".
315 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
316 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
319 $ilAppEventHandler->raise(
323 'obj_id' => $this->obj_id,
324 'usr_id' => $a_usr_id)
338 $query =
"DELETE FROM il_subscribers ".
339 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
340 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
391 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
393 $query =
"SELECT * FROM obj_members ".
394 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
395 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
399 $query =
"UPDATE obj_members SET ".
400 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
401 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
402 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
406 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
408 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
409 $ilDB->quote($this->obj_id ,
'integer').
", ".
410 $ilDB->quote($a_usr_id ,
'integer').
", ".
411 $ilDB->quote(0,
'integer').
", ".
412 $ilDB->quote(0,
'integer').
432 $this->type ==
'crs' ?
438 SELECT COUNT(rolesusers.usr_id) cnt
440 FROM object_data rdata
442 LEFT JOIN rbac_ua rolesusers
443 ON rolesusers.rol_id = rdata.obj_id
445 WHERE rdata.obj_id = %s
448 $query .=
' AND '.$ilDB->in(
'rolesusers.usr_id', $a_usr_ids,
true,
'integer');
449 $res = $ilDB->queryF(
$query, array(
'integer'), array($admin_role_id));
451 $data = $ilDB->fetchAssoc(
$res);
453 return (
int)$data[
'cnt'] > 0;