ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilParticipant Class Reference

Base class for course and group participant. More...

+ Inheritance diagram for ilParticipant:
+ Collaboration diagram for ilParticipant:

Public Member Functions

 getUserId ()
 get user id More...
 
 isBlocked ()
 
 isAssigned ()
 
 isMember ()
 
 isAdmin ()
 
 isTutor ()
 
 isParticipant ()
 
 getNumberOfMembers ()
 
 add ($a_usr_id, $a_role)
 Add user to course. More...
 
 delete ($a_usr_id)
 Drop user from all roles. More...
 
 deleteSubscriber ($a_usr_id)
 Delete subsciber. More...
 
 addDesktopItem ($a_usr_id)
 Add desktop item. More...
 
 dropDesktopItem ($a_usr_id)
 Drop desktop item. More...
 
 updateNotification ($a_usr_id, $a_notification)
 Update notification status. More...
 
 checkLastAdmin ($a_usr_ids)
 Check if user for deletion are last admins. More...
 

Protected Member Functions

 __construct ($a_obj_id, $a_usr_id)
 Singleton Constructor. More...
 
 readParticipant ()
 Read participant. More...
 
 readParticipantStatus ()
 Read participant status ilDB $ilDB. More...
 

Protected Attributes

 $type = ''
 

Private Attributes

 $obj_id = 0
 
 $usr_id = 0
 
 $ref_id = 0
 
 $participants = false
 
 $admins = false
 
 $tutors = false
 
 $members = false
 
 $numMembers = 0
 
 $participants_status = array()
 

Detailed Description

Base class for course and group participant.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 34 of file class.ilParticipant.php.

Constructor & Destructor Documentation

◆ __construct()

ilParticipant::__construct (   $a_obj_id,
  $a_usr_id 
)
protected

Singleton Constructor.

protected

Parameters
intobj_id of container

Definition at line 56 of file class.ilParticipant.php.

References $lng, ilObject\_getAllReferences(), ilObject\_lookupType(), readParticipant(), and readParticipantStatus().

57  {
58  global $ilDB,$lng;
59 
60  $this->obj_id = $a_obj_id;
61  $this->usr_id = $a_usr_id;
62  $this->type = ilObject::_lookupType($a_obj_id);
63  $ref_ids = ilObject::_getAllReferences($this->obj_id);
64  $this->ref_id = current($ref_ids);
65 
66  $this->readParticipant();
67  $this->readParticipantStatus();
68  }
readParticipantStatus()
Read participant status ilDB $ilDB.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
readParticipant()
Read participant.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilParticipant::add (   $a_usr_id,
  $a_role 
)

Add user to course.

public

Parameters
intuser id
introle IL_CRS_ADMIN || IL_CRS_TUTOR || IL_CRS_MEMBER

global ilRbacReview $rbacreview

Definition at line 239 of file class.ilParticipant.php.

References $ilLog, addDesktopItem(), deleteSubscriber(), ilWaitingList\deleteUserEntry(), IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, IL_GRP_ADMIN, and IL_GRP_MEMBER.

240  {
241  global $rbacadmin,$ilLog,$ilAppEventHandler,$rbacreview;
242 
243 
244  if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
245  {
246  return false;
247  }
248 
249  switch($a_role)
250  {
251  case IL_CRS_ADMIN:
252  $this->admins = true;
253  break;
254 
255  case IL_CRS_TUTOR:
256  $this->tutors = true;
257  break;
258 
259  case IL_CRS_MEMBER:
260  $this->members = true;
261  break;
262 
263  case IL_GRP_ADMIN:
264  $this->admins = true;
265  break;
266 
267  case IL_GRP_MEMBER:
268  $this->members = true;
269  break;
270  }
271 
272  $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
273  $this->addDesktopItem($a_usr_id);
274 
275  // Delete subscription request
276  $this->deleteSubscriber($a_usr_id);
277 
278  include_once './Services/Membership/classes/class.ilWaitingList.php';
279  ilWaitingList::deleteUserEntry($a_usr_id,$this->obj_id);
280 
281  if($this->type == 'crs')
282  {
283  // Add event: used for ecs accounts
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));
286  }
287  return true;
288  }
const IL_GRP_ADMIN
const IL_CRS_TUTOR
deleteSubscriber($a_usr_id)
Delete subsciber.
const IL_GRP_MEMBER
const IL_CRS_MEMBER
const IL_CRS_ADMIN
Base class for course and group participants.
addDesktopItem($a_usr_id)
Add desktop item.
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
+ Here is the call graph for this function:

◆ addDesktopItem()

ilParticipant::addDesktopItem (   $a_usr_id)

Add desktop item.

public

Parameters
intusr_id

Definition at line 345 of file class.ilParticipant.php.

References ilObjUser\_addDesktopItem(), and ilObjUser\_isDesktopItem().

Referenced by add().

346  {
347  if(!ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
348  {
349  ilObjUser::_addDesktopItem($a_usr_id, $this->ref_id,$this->type);
350  }
351  return true;
352  }
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkLastAdmin()

ilParticipant::checkLastAdmin (   $a_usr_ids)

Check if user for deletion are last admins.

public

Parameters
arrayarray of user ids for deletion

Definition at line 419 of file class.ilParticipant.php.

References $data, $query, $res, ilDB\fetchAssoc(), IL_CRS_ADMIN, and IL_GRP_ADMIN.

420  {
421  global $ilDB;
422 
423  $admin_role_id =
424  $this->type == 'crs' ?
425  $this->role_data[IL_CRS_ADMIN] :
426  $this->role_data[IL_GRP_ADMIN];
427 
428 
429  $query = "
430  SELECT COUNT(rolesusers.usr_id) cnt
431 
432  FROM object_data rdata
433 
434  LEFT JOIN rbac_ua rolesusers
435  ON rolesusers.rol_id = rdata.obj_id
436 
437  WHERE rdata.obj_id = %s
438  ";
439 
440  $query .= ' AND '.$ilDB->in('rolesusers.usr_id', $a_usr_ids, true, 'integer');
441  $res = $ilDB->queryF($query, array('integer'), array($admin_role_id));
442 
443  $data = $ilDB->fetchAssoc($res);
444 
445  return (int)$data['cnt'] > 0;
446  }
const IL_GRP_ADMIN
fetchAssoc($a_set)
Fetch row as associative array from result set.
const IL_CRS_ADMIN
Base class for course and group participants.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ delete()

ilParticipant::delete (   $a_usr_id)

Drop user from all roles.

public

Parameters
intusr_id

Definition at line 297 of file class.ilParticipant.php.

References $query, $res, and dropDesktopItem().

298  {
299  global $rbacadmin,$ilDB, $ilAppEventHandler;
300 
301  $this->dropDesktopItem($a_usr_id);
302  foreach($this->roles as $role_id)
303  {
304  $rbacadmin->deassignUser($role_id,$a_usr_id);
305  }
306 
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');
310  $res = $ilDB->manipulate($query);
311 
312  if($this->type == 'crs')
313  {
314  // Add event: used for ecs accounts
315  $ilAppEventHandler->raise("Modules/Course", "deleteParticipant", array('obj_id' => $this->obj_id, 'usr_id' => $a_usr_id));
316  }
317 
318  return true;
319  }
dropDesktopItem($a_usr_id)
Drop desktop item.
+ Here is the call graph for this function:

◆ deleteSubscriber()

ilParticipant::deleteSubscriber (   $a_usr_id)

Delete subsciber.

public

Definition at line 326 of file class.ilParticipant.php.

References $query, and $res.

Referenced by add().

327  {
328  global $ilDB;
329 
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')." ";
333  $res = $ilDB->manipulate($query);
334 
335  return true;
336  }
+ Here is the caller graph for this function:

◆ dropDesktopItem()

ilParticipant::dropDesktopItem (   $a_usr_id)

Drop desktop item.

public

Parameters
intusr_id

Definition at line 361 of file class.ilParticipant.php.

References ilObjUser\_dropDesktopItem(), and ilObjUser\_isDesktopItem().

Referenced by delete().

362  {
363  if(ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
364  {
365  ilObjUser::_dropDesktopItem($a_usr_id, $this->ref_id,$this->type);
366  }
367 
368  return true;
369  }
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
static _isDesktopItem($a_usr_id, $a_item_id, $a_type)
check wether an item is on the users desktop or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumberOfMembers()

ilParticipant::getNumberOfMembers ( )

Definition at line 109 of file class.ilParticipant.php.

References $numMembers.

110  {
111  return $this->numMembers;
112  }

◆ getUserId()

ilParticipant::getUserId ( )

get user id

Returns
int

Definition at line 74 of file class.ilParticipant.php.

References $usr_id.

Referenced by isBlocked(), and readParticipantStatus().

75  {
76  return $this->usr_id;
77  }
+ Here is the caller graph for this function:

◆ isAdmin()

ilParticipant::isAdmin ( )

Definition at line 94 of file class.ilParticipant.php.

References $admins.

95  {
96  return $this->admins;
97  }

◆ isAssigned()

ilParticipant::isAssigned ( )

Definition at line 84 of file class.ilParticipant.php.

References $participants.

85  {
86  return (bool) $this->participants;
87  }

◆ isBlocked()

ilParticipant::isBlocked ( )

Definition at line 79 of file class.ilParticipant.php.

References getUserId().

80  {
81  return (bool) $this->participants_status[$this->getUserId()]['blocked'];
82  }
getUserId()
get user id
+ Here is the call graph for this function:

◆ isMember()

ilParticipant::isMember ( )

Definition at line 89 of file class.ilParticipant.php.

References $members.

90  {
91  return (bool) $this->members;
92  }

◆ isParticipant()

ilParticipant::isParticipant ( )

Definition at line 104 of file class.ilParticipant.php.

References $participants.

105  {
106  return (bool) $this->participants;
107  }

◆ isTutor()

ilParticipant::isTutor ( )

Definition at line 99 of file class.ilParticipant.php.

References $tutors.

100  {
101  return (bool) $this->tutors;
102  }

◆ readParticipant()

ilParticipant::readParticipant ( )
protected

Read participant.

Returns
void

Definition at line 119 of file class.ilParticipant.php.

References $ilLog, IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, IL_GRP_ADMIN, and IL_GRP_MEMBER.

Referenced by __construct().

120  {
121  global $rbacreview,$ilObjDataCache,$ilLog;
122 
123  $rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
124 
125  if(!isset($rolf['ref_id']) or !$rolf['ref_id'])
126  {
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);
129  #$ilLog->logStack();
130  return false;
131  }
132 
133  $this->roles = $rbacreview->getRolesOfRoleFolder($rolf['ref_id'],false);
134 
135  $users = array();
136  $this->participants = array();
137  $this->members = $this->admins = $this->tutors = array();
138 
139  $member_roles = array();
140 
141  foreach($this->roles as $role_id)
142  {
143  $title = $ilObjDataCache->lookupTitle($role_id);
144  switch(substr($title,0,8))
145  {
146  case 'il_crs_m':
147  $member_roles[] = $role_id;
148  $this->role_data[IL_CRS_MEMBER] = $role_id;
149  if($rbacreview->isAssigned($this->getUserId(),$role_id))
150  {
151  $this->participants = true;
152  $this->members = true;
153  }
154  break;
155 
156  case 'il_crs_a':
157  $this->role_data[IL_CRS_ADMIN] = $role_id;
158  if($rbacreview->isAssigned($this->getUserId(),$role_id))
159  {
160  $this->participants = true;
161  $this->admins = true;
162  }
163  break;
164 
165  case 'il_crs_t':
166  $this->role_data[IL_CRS_TUTOR] = $role_id;
167  if($rbacreview->isAssigned($this->getUserId(),$role_id))
168  {
169  $this->participants = true;
170  $this->tutors = true;
171  }
172  break;
173 
174  case 'il_grp_a':
175  $this->role_data[IL_GRP_ADMIN] = $role_id;
176  if($rbacreview->isAssigned($this->getUserId(),$role_id))
177  {
178  $this->participants = true;
179  $this->admins = true;
180  }
181  break;
182 
183  case 'il_grp_m':
184  $member_roles[] = $role_id;
185  $this->role_data[IL_GRP_MEMBER] = $role_id;
186  if($rbacreview->isAssigned($this->getUserId(),$role_id))
187  {
188  $this->participants = true;
189  $this->members = true;
190  }
191  break;
192 
193  default:
194 
195  $member_roles[] = $role_id;
196  if($rbacreview->isAssigned($this->getUserId(),$role_id))
197  {
198  $this->participants = true;
199  $this->members = true;
200  }
201  break;
202  }
203  }
204  $this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
205  }
const IL_GRP_ADMIN
const IL_CRS_TUTOR
const IL_GRP_MEMBER
const IL_CRS_MEMBER
const IL_CRS_ADMIN
Base class for course and group participants.
+ Here is the caller graph for this function:

◆ readParticipantStatus()

ilParticipant::readParticipantStatus ( )
protected

Read participant status ilDB $ilDB.

Definition at line 211 of file class.ilParticipant.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getUserId().

Referenced by __construct().

212  {
213  global $ilDB;
214 
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');
218 
219  $res = $ilDB->query($query);
220  $this->participants_status = array();
221  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
222  {
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;
226  }
227  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
getUserId()
get user id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateNotification()

ilParticipant::updateNotification (   $a_usr_id,
  $a_notification 
)

Update notification status.

public

Parameters
intusr_id
boolpassed

Definition at line 379 of file class.ilParticipant.php.

References $query, and $res.

380  {
381  global $ilDB;
382 
383  $this->participants_status[$a_usr_id]['notification'] = (int) $a_notification;
384 
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');
388  $res = $ilDB->query($query);
389  if($res->numRows())
390  {
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');
395  }
396  else
397  {
398  $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
399  "VALUES ( ".
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').
405  ")";
406 
407  }
408  $res = $ilDB->manipulate($query);
409  return true;
410  }

Field Documentation

◆ $admins

ilParticipant::$admins = false
private

Definition at line 42 of file class.ilParticipant.php.

Referenced by isAdmin().

◆ $members

ilParticipant::$members = false
private

Definition at line 44 of file class.ilParticipant.php.

Referenced by isMember().

◆ $numMembers

ilParticipant::$numMembers = 0
private

Definition at line 46 of file class.ilParticipant.php.

Referenced by getNumberOfMembers().

◆ $obj_id

ilParticipant::$obj_id = 0
private

Definition at line 36 of file class.ilParticipant.php.

◆ $participants

ilParticipant::$participants = false
private

Definition at line 41 of file class.ilParticipant.php.

Referenced by isAssigned(), and isParticipant().

◆ $participants_status

ilParticipant::$participants_status = array()
private

Definition at line 48 of file class.ilParticipant.php.

◆ $ref_id

ilParticipant::$ref_id = 0
private

Definition at line 39 of file class.ilParticipant.php.

◆ $tutors

ilParticipant::$tutors = false
private

Definition at line 43 of file class.ilParticipant.php.

Referenced by isTutor().

◆ $type

ilParticipant::$type = ''
protected

Definition at line 38 of file class.ilParticipant.php.

◆ $usr_id

ilParticipant::$usr_id = 0
private

Definition at line 37 of file class.ilParticipant.php.

Referenced by getUserId().


The documentation for this class was generated from the following file: