25 include_once
'./Services/Membership/classes/class.ilParticipants.php';
60 $this->obj_id = $a_obj_id;
61 $this->usr_id = $a_usr_id;
64 $this->ref_id = current($ref_ids);
81 return (
bool) $this->participants_status[$this->
getUserId()][
'blocked'];
121 global $rbacreview,$ilObjDataCache,
$ilLog;
123 $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
125 if(!isset($rolf[
'ref_id']) or !$rolf[
'ref_id'])
127 $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
128 #$ilLog->write(__METHOD__.': Found object without role folder. Ref_id: '.$this->ref_id.', title: '.$title);
133 $this->roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
136 $this->participants = array();
137 $this->members = $this->admins = $this->tutors = array();
139 $member_roles = array();
141 foreach($this->roles as $role_id)
143 $title = $ilObjDataCache->lookupTitle($role_id);
144 switch(substr(
$title,0,8))
147 $member_roles[] = $role_id;
149 if($rbacreview->isAssigned($this->getUserId(),$role_id))
151 $this->participants =
true;
152 $this->members =
true;
158 if($rbacreview->isAssigned($this->getUserId(),$role_id))
160 $this->participants =
true;
161 $this->admins =
true;
167 if($rbacreview->isAssigned($this->getUserId(),$role_id))
169 $this->participants =
true;
170 $this->tutors =
true;
176 if($rbacreview->isAssigned($this->getUserId(),$role_id))
178 $this->participants =
true;
179 $this->admins =
true;
184 $member_roles[] = $role_id;
186 if($rbacreview->isAssigned($this->getUserId(),$role_id))
188 $this->participants =
true;
189 $this->members =
true;
195 $member_roles[] = $role_id;
196 if($rbacreview->isAssigned($this->getUserId(),$role_id))
198 $this->participants =
true;
199 $this->members =
true;
204 $this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
215 $query =
"SELECT * FROM obj_members ".
216 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
217 'AND usr_id = '.$ilDB->quote($this->
getUserId(),
'integer');
220 $this->participants_status = array();
223 $this->participants_status[$this->
getUserId()][
'blocked'] =
$row->blocked;
224 $this->participants_status[$this->
getUserId()][
'notification'] =
$row->notification;
225 $this->participants_status[$this->
getUserId()][
'passed'] =
$row->passed;
239 public function add($a_usr_id,$a_role)
241 global $rbacadmin,
$ilLog,$ilAppEventHandler,$rbacreview;
244 if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
252 $this->admins =
true;
256 $this->tutors =
true;
260 $this->members =
true;
264 $this->admins =
true;
268 $this->members =
true;
272 $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
278 include_once
'./Services/Membership/classes/class.ilWaitingList.php';
281 if($this->type ==
'crs')
284 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addParticipant');
285 $ilAppEventHandler->raise(
"Modules/Course",
"addParticipant", array(
'obj_id' => $this->obj_id,
'usr_id' => $a_usr_id,
'role_id' => $a_role));
297 public function delete($a_usr_id)
299 global $rbacadmin,$ilDB, $ilAppEventHandler;
302 foreach($this->roles as $role_id)
304 $rbacadmin->deassignUser($role_id,$a_usr_id);
307 $query =
"DELETE FROM obj_members ".
308 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
309 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer');
312 if($this->type ==
'crs')
315 $ilAppEventHandler->raise(
"Modules/Course",
"deleteParticipant", array(
'obj_id' => $this->obj_id,
'usr_id' => $a_usr_id));
330 $query =
"DELETE FROM il_subscribers ".
331 "WHERE usr_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
332 "AND obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ";
383 $this->participants_status[$a_usr_id][
'notification'] = (int) $a_notification;
385 $query =
"SELECT * FROM obj_members ".
386 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
387 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
391 $query =
"UPDATE obj_members SET ".
392 "notification = ".$ilDB->quote((
int) $a_notification ,
'integer').
" ".
393 "WHERE obj_id = ".$ilDB->quote($this->obj_id ,
'integer').
" ".
394 "AND usr_id = ".$ilDB->quote($a_usr_id ,
'integer');
398 $query =
"INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
400 $ilDB->quote((
int) $a_notification ,
'integer').
", ".
401 $ilDB->quote($this->obj_id ,
'integer').
", ".
402 $ilDB->quote($a_usr_id ,
'integer').
", ".
403 $ilDB->quote(0,
'integer').
", ".
404 $ilDB->quote(0,
'integer').
424 $this->type ==
'crs' ?
430 SELECT COUNT(rolesusers.usr_id) cnt
432 FROM object_data rdata
434 LEFT JOIN rbac_ua rolesusers
435 ON rolesusers.rol_id = rdata.obj_id
437 WHERE rdata.obj_id = %s
440 $query .=
' AND '.$ilDB->in(
'rolesusers.usr_id', $a_usr_ids,
true,
'integer');
441 $res = $ilDB->queryF(
$query, array(
'integer'), array($admin_role_id));
445 return (
int)
$data[
'cnt'] > 0;