ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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_component_name, $a_obj_id, $a_usr_id)
 Singleton Constructor. More...
 
 getComponent ()
 Get component name Used for event handling. 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
 
 $component = ''
 
 $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_component_name,
  $a_obj_id,
  $a_usr_id 
)
protected

Singleton Constructor.

protected

Parameters
intobj_id of container

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

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

59  {
60  global $ilDB,$lng;
61 
62  $this->obj_id = $a_obj_id;
63  $this->usr_id = $a_usr_id;
64  $this->type = ilObject::_lookupType($a_obj_id);
65  $ref_ids = ilObject::_getAllReferences($this->obj_id);
66  $this->ref_id = current($ref_ids);
67 
68  $this->component = $a_component_name;
69 
70  $this->readParticipant();
71  $this->readParticipantStatus();
72  }
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
global $ilDB
+ 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 243 of file class.ilParticipant.php.

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

244  {
245  global $rbacadmin,$ilLog,$ilAppEventHandler,$rbacreview;
246 
247 
248  if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
249  {
250  return false;
251  }
252 
253  switch($a_role)
254  {
255  case IL_CRS_ADMIN:
256  $this->admins = true;
257  break;
258 
259  case IL_CRS_TUTOR:
260  $this->tutors = true;
261  break;
262 
263  case IL_CRS_MEMBER:
264  $this->members = true;
265  break;
266 
267  case IL_GRP_ADMIN:
268  $this->admins = true;
269  break;
270 
271  case IL_GRP_MEMBER:
272  $this->members = true;
273  break;
274  }
275 
276  $rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
277  $this->addDesktopItem($a_usr_id);
278 
279  // Delete subscription request
280  $this->deleteSubscriber($a_usr_id);
281 
282  include_once './Services/Membership/classes/class.ilWaitingList.php';
283  ilWaitingList::deleteUserEntry($a_usr_id,$this->obj_id);
284 
285  $ilLog->write(__METHOD__.': Raise new event: Modules/Course addParticipant');
286  $ilAppEventHandler->raise(
287  $this->getComponent(),
288  "addParticipant",
289  array(
290  'obj_id' => $this->obj_id,
291  'usr_id' => $a_usr_id,
292  'role_id' => $a_role)
293  );
294  return true;
295  }
const IL_GRP_ADMIN
const IL_CRS_TUTOR
deleteSubscriber($a_usr_id)
Delete subsciber.
const IL_GRP_MEMBER
getComponent()
Get component name Used for event handling.
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 353 of file class.ilParticipant.php.

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

Referenced by add().

354  {
355  if(!ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
356  {
357  ilObjUser::_addDesktopItem($a_usr_id, $this->ref_id,$this->type);
358  }
359  return true;
360  }
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 427 of file class.ilParticipant.php.

References $data, $ilDB, $query, $res, IL_CRS_ADMIN, and IL_GRP_ADMIN.

428  {
429  global $ilDB;
430 
431  $admin_role_id =
432  $this->type == 'crs' ?
433  $this->role_data[IL_CRS_ADMIN] :
434  $this->role_data[IL_GRP_ADMIN];
435 
436 
437  $query = "
438  SELECT COUNT(rolesusers.usr_id) cnt
439 
440  FROM object_data rdata
441 
442  LEFT JOIN rbac_ua rolesusers
443  ON rolesusers.rol_id = rdata.obj_id
444 
445  WHERE rdata.obj_id = %s
446  ";
447 
448  $query .= ' AND '.$ilDB->in('rolesusers.usr_id', $a_usr_ids, true, 'integer');
449  $res = $ilDB->queryF($query, array('integer'), array($admin_role_id));
450 
451  $data = $ilDB->fetchAssoc($res);
452 
453  return (int)$data['cnt'] > 0;
454  }
const IL_GRP_ADMIN
const IL_CRS_ADMIN
Base class for course and group participants.
global $ilDB

◆ delete()

ilParticipant::delete (   $a_usr_id)

Drop user from all roles.

public

Parameters
intusr_id

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

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

305  {
306  global $rbacadmin,$ilDB, $ilAppEventHandler;
307 
308  $this->dropDesktopItem($a_usr_id);
309  foreach($this->roles as $role_id)
310  {
311  $rbacadmin->deassignUser($role_id,$a_usr_id);
312  }
313 
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');
317  $res = $ilDB->manipulate($query);
318 
319  $ilAppEventHandler->raise(
320  "Modules/Course",
321  "deleteParticipant",
322  array(
323  'obj_id' => $this->obj_id,
324  'usr_id' => $a_usr_id)
325  );
326  return true;
327  }
dropDesktopItem($a_usr_id)
Drop desktop item.
global $ilDB
+ Here is the call graph for this function:

◆ deleteSubscriber()

ilParticipant::deleteSubscriber (   $a_usr_id)

Delete subsciber.

public

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

References $ilDB, $query, and $res.

Referenced by add().

335  {
336  global $ilDB;
337 
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')." ";
341  $res = $ilDB->manipulate($query);
342 
343  return true;
344  }
global $ilDB
+ Here is the caller graph for this function:

◆ dropDesktopItem()

ilParticipant::dropDesktopItem (   $a_usr_id)

Drop desktop item.

public

Parameters
intusr_id

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

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

Referenced by delete().

370  {
371  if(ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
372  {
373  ilObjUser::_dropDesktopItem($a_usr_id, $this->ref_id,$this->type);
374  }
375 
376  return true;
377  }
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:

◆ getComponent()

ilParticipant::getComponent ( )
protected

Get component name Used for event handling.

Returns
type

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

References $component.

Referenced by add().

80  {
81  return $this->component;
82  }
+ Here is the caller graph for this function:

◆ getNumberOfMembers()

ilParticipant::getNumberOfMembers ( )

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

References $numMembers.

124  {
125  return $this->numMembers;
126  }

◆ getUserId()

ilParticipant::getUserId ( )

get user id

Returns
int

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

References $usr_id.

Referenced by isBlocked(), and readParticipantStatus().

89  {
90  return $this->usr_id;
91  }
+ Here is the caller graph for this function:

◆ isAdmin()

ilParticipant::isAdmin ( )

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

References $admins.

109  {
110  return $this->admins;
111  }

◆ isAssigned()

ilParticipant::isAssigned ( )

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

References $participants.

99  {
100  return (bool) $this->participants;
101  }

◆ isBlocked()

ilParticipant::isBlocked ( )

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

References getUserId().

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

◆ isMember()

ilParticipant::isMember ( )

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

References $members.

104  {
105  return (bool) $this->members;
106  }

◆ isParticipant()

ilParticipant::isParticipant ( )

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

References $participants.

119  {
120  return (bool) $this->participants;
121  }

◆ isTutor()

ilParticipant::isTutor ( )

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

References $tutors.

114  {
115  return (bool) $this->tutors;
116  }

◆ readParticipant()

ilParticipant::readParticipant ( )
protected

Read participant.

Returns
void

Definition at line 133 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().

134  {
135  global $rbacreview,$ilObjDataCache,$ilLog;
136 
137  $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id,false);
138 
139  $users = array();
140  $this->participants = array();
141  $this->members = $this->admins = $this->tutors = array();
142 
143  $member_roles = array();
144 
145  foreach($this->roles as $role_id)
146  {
147  $title = $ilObjDataCache->lookupTitle($role_id);
148  switch(substr($title,0,8))
149  {
150  case 'il_crs_m':
151  $member_roles[] = $role_id;
152  $this->role_data[IL_CRS_MEMBER] = $role_id;
153  if($rbacreview->isAssigned($this->getUserId(),$role_id))
154  {
155  $this->participants = true;
156  $this->members = true;
157  }
158  break;
159 
160  case 'il_crs_a':
161  $this->role_data[IL_CRS_ADMIN] = $role_id;
162  if($rbacreview->isAssigned($this->getUserId(),$role_id))
163  {
164  $this->participants = true;
165  $this->admins = true;
166  }
167  break;
168 
169  case 'il_crs_t':
170  $this->role_data[IL_CRS_TUTOR] = $role_id;
171  if($rbacreview->isAssigned($this->getUserId(),$role_id))
172  {
173  $this->participants = true;
174  $this->tutors = true;
175  }
176  break;
177 
178  case 'il_grp_a':
179  $this->role_data[IL_GRP_ADMIN] = $role_id;
180  if($rbacreview->isAssigned($this->getUserId(),$role_id))
181  {
182  $this->participants = true;
183  $this->admins = true;
184  }
185  break;
186 
187  case 'il_grp_m':
188  $member_roles[] = $role_id;
189  $this->role_data[IL_GRP_MEMBER] = $role_id;
190  if($rbacreview->isAssigned($this->getUserId(),$role_id))
191  {
192  $this->participants = true;
193  $this->members = true;
194  }
195  break;
196 
197  default:
198 
199  $member_roles[] = $role_id;
200  if($rbacreview->isAssigned($this->getUserId(),$role_id))
201  {
202  $this->participants = true;
203  $this->members = true;
204  }
205  break;
206  }
207  }
208  $this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
209  }
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 215 of file class.ilParticipant.php.

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

Referenced by __construct().

216  {
217  global $ilDB;
218 
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');
222 
223  $res = $ilDB->query($query);
224  $this->participants_status = array();
225  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
226  {
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;
230  }
231  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
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 387 of file class.ilParticipant.php.

References $ilDB, $query, and $res.

388  {
389  global $ilDB;
390 
391  $this->participants_status[$a_usr_id]['notification'] = (int) $a_notification;
392 
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');
396  $res = $ilDB->query($query);
397  if($res->numRows())
398  {
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');
403  }
404  else
405  {
406  $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
407  "VALUES ( ".
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').
413  ")";
414 
415  }
416  $res = $ilDB->manipulate($query);
417  return true;
418  }
global $ilDB

Field Documentation

◆ $admins

ilParticipant::$admins = false
private

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

Referenced by isAdmin().

◆ $component

ilParticipant::$component = ''
private

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

Referenced by getComponent().

◆ $members

ilParticipant::$members = false
private

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

Referenced by isMember().

◆ $numMembers

ilParticipant::$numMembers = 0
private

Definition at line 48 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 43 of file class.ilParticipant.php.

Referenced by isAssigned(), and isParticipant().

◆ $participants_status

ilParticipant::$participants_status = array()
private

Definition at line 50 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 45 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: