ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilParticipant Class Reference

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

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

Public Member Functions

 getUserId ()
 
 isBlocked ()
 
 isContact ()
 Check if user is contact for current object. More...
 
 isAssigned ()
 
 isMember ()
 
 isAdmin ()
 
 isTutor ()
 
 isParticipant ()
 
 getNumberOfMembers ()
 
 add (int $a_usr_id, int $a_role)
 
 delete (int $a_usr_id)
 
 deleteSubscriber (int $a_usr_id)
 
 addRecommendation ($a_usr_id)
 
 updateContact (int $a_usr_id, bool $a_contact)
 
 updateNotification (int $a_usr_id, bool $a_notification)
 
 checkLastAdmin (array $a_usr_ids)
 

Static Public Member Functions

static updateMemberRoles (int $a_obj_id, int $a_usr_id, int $a_role_id, int $a_status)
 
static getMembershipRoleType (int $a_role_id)
 
static lookupStatusByMembershipRoleType (int $a_obj_id, int $a_usr_id, int $a_membership_role_type)
 

Protected Member Functions

 __construct (string $a_component_name, int $a_obj_id, int $a_usr_id)
 
 getComponent ()
 Get component name Used for event handling. More...
 
 readParticipant ()
 
 readParticipantStatus ()
 

Protected Attributes

const MEMBERSHIP_ADMIN = 1
 
const MEMBERSHIP_TUTOR = 2
 
const MEMBERSHIP_MEMBER = 3
 
string $type = ''
 
ilRecommendedContentManager $recommended_content_manager
 
ilDBInterface $db
 
ilRbacReview $rbacReview
 
ilRbacAdmin $rbacAdmin
 
ilObjectDataCache $objectDataCache
 
ilAppEventHandler $eventHandler
 

Private Attributes

int $obj_id = 0
 
int $usr_id = 0
 
int $ref_id = 0
 
string $component = ''
 
array $roles = []
 
array $role_data = []
 
bool $participants = false
 
bool $admins = false
 
bool $tutors = false
 
bool $members = false
 
int $numMembers = null
 
array $member_roles = []
 
array $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 26 of file class.ilParticipant.php.

Constructor & Destructor Documentation

◆ __construct()

ilParticipant::__construct ( string  $a_component_name,
int  $a_obj_id,
int  $a_usr_id 
)
protected

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

58 {
59 global $DIC;
60
61 $this->obj_id = $a_obj_id;
62 $this->usr_id = $a_usr_id;
63 $this->type = ilObject::_lookupType($a_obj_id);
64 $ref_ids = ilObject::_getAllReferences($this->obj_id);
65 $this->ref_id = current($ref_ids);
66 $this->component = $a_component_name;
67
68 $this->recommended_content_manager = new ilRecommendedContentManager();
69 $this->db = $DIC->database();
70 $this->rbacReview = $DIC->rbac()->review();
71 $this->rbacAdmin = $DIC->rbac()->admin();
72 $this->objectDataCache = $DIC['ilObjDataCache'];
73 $this->eventHandler = $DIC->event();
74
75 $this->readParticipant();
76 $this->readParticipantStatus();
77 }
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\_getAllReferences(), ilObject\_lookupType(), ILIAS\Repository\objectDataCache(), readParticipant(), and readParticipantStatus().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilParticipant::add ( int  $a_usr_id,
int  $a_role 
)

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

335 : bool
336 {
337 if ($this->rbacReview->isAssignedToAtLeastOneGivenRole($a_usr_id, $this->roles)) {
338 return false;
339 }
340
341 switch ($a_role) {
344 $this->admins = true;
345 break;
346
348 $this->tutors = true;
349 break;
350
353 $this->members = true;
354 break;
355 }
356
357 $this->rbacAdmin->assignUser($this->role_data[$a_role], $a_usr_id);
358 $this->addRecommendation($a_usr_id);
359
360 // Delete subscription request
361 $this->deleteSubscriber($a_usr_id);
362
363 ilWaitingList::deleteUserEntry($a_usr_id, $this->obj_id);
364
365 $this->eventHandler->raise(
366 $this->getComponent(),
367 "addParticipant",
368 array(
369 'obj_id' => $this->obj_id,
370 'usr_id' => $a_usr_id,
371 'role_id' => $a_role
372 )
373 );
374 return true;
375 }
addRecommendation($a_usr_id)
getComponent()
Get component name Used for event handling.
deleteSubscriber(int $a_usr_id)
static deleteUserEntry(int $a_usr_id, int $a_obj_id)

References ilWaitingList\deleteUserEntry(), ilParticipants\IL_CRS_ADMIN, ilParticipants\IL_CRS_MEMBER, ilParticipants\IL_CRS_TUTOR, ilParticipants\IL_GRP_ADMIN, and ilParticipants\IL_GRP_MEMBER.

+ Here is the call graph for this function:

◆ addRecommendation()

ilParticipant::addRecommendation (   $a_usr_id)

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

407 : void
408 {
409 // deactivated for now, see discussion at
410 // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
411 //$this->recommended_content_manager->addObjectRecommendation($a_usr_id, $this->ref_id);
412 }

◆ checkLastAdmin()

ilParticipant::checkLastAdmin ( array  $a_usr_ids)

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

451 : bool
452 {
453 $admin_role_id =
454 $this->type === 'crs' ?
455 $this->role_data[ilParticipants::IL_CRS_ADMIN] :
456 $this->role_data[ilParticipants::IL_GRP_ADMIN];
457
458 $query = "
459 SELECT COUNT(rolesusers.usr_id) cnt
460
461 FROM object_data rdata
462
463 LEFT JOIN rbac_ua rolesusers
464 ON rolesusers.rol_id = rdata.obj_id
465
466 WHERE rdata.obj_id = %s
467 ";
468
469 $query .= ' AND ' . $this->db->in('rolesusers.usr_id', $a_usr_ids, true, 'integer');
470 $res = $this->db->queryF($query, array('integer'), array($admin_role_id));
471
472 $data = $this->db->fetchAssoc($res);
473 return $data['cnt'] > 0;
474 }
$res
Definition: ltiservices.php:69

References $data, $res, ilParticipants\IL_CRS_ADMIN, and ilParticipants\IL_GRP_ADMIN.

◆ delete()

ilParticipant::delete ( int  $a_usr_id)

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

377 : void
378 {
379 $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->ref_id);
380 foreach ($this->roles as $role_id) {
381 $this->rbacAdmin->deassignUser($role_id, $a_usr_id);
382 }
383
384 $query = "DELETE FROM obj_members " .
385 "WHERE usr_id = " . $this->db->quote($a_usr_id, 'integer') . " " .
386 "AND obj_id = " . $this->db->quote($this->obj_id, 'integer');
387 $res = $this->db->manipulate($query);
388
389 $this->eventHandler->raise(
390 $this->getComponent(),
391 "deleteParticipant",
392 array(
393 'obj_id' => $this->obj_id,
394 'usr_id' => $a_usr_id
395 )
396 );
397 }

References $res.

◆ deleteSubscriber()

ilParticipant::deleteSubscriber ( int  $a_usr_id)

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

399 : void
400 {
401 $query = "DELETE FROM il_subscribers " .
402 "WHERE usr_id = " . $this->db->quote($a_usr_id, 'integer') . " " .
403 "AND obj_id = " . $this->db->quote($this->obj_id, 'integer') . " ";
404 $res = $this->db->manipulate($query);
405 }

References $res.

◆ getComponent()

ilParticipant::getComponent ( )
protected

Get component name Used for event handling.

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

202 : string
203 {
204 return $this->component;
205 }

◆ getMembershipRoleType()

static ilParticipant::getMembershipRoleType ( int  $a_role_id)
static

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

154 : int
155 {
156 $title = ilObject::_lookupTitle($a_role_id);
157 switch (substr($title, 0, 8)) {
158 case 'il_crs_a':
159 case 'il_grp_a':
161
162 case 'il_crs_t':
164
165 case 'il_crs_m':
166 default:
168 }
169 }
static _lookupTitle(int $obj_id)

References ilObject\_lookupTitle(), MEMBERSHIP_ADMIN, MEMBERSHIP_MEMBER, and MEMBERSHIP_TUTOR.

Referenced by updateMemberRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumberOfMembers()

ilParticipant::getNumberOfMembers ( )

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

250 : int
251 {
252 if ($this->numMembers === null) {
253 $this->numMembers = $this->rbacReview->getNumberOfAssignedUsers($this->member_roles);
254 }
255 return $this->numMembers;
256 }

◆ getUserId()

ilParticipant::getUserId ( )

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

207 : int
208 {
209 return $this->usr_id;
210 }

◆ isAdmin()

ilParticipant::isAdmin ( )

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

235 : bool
236 {
237 return $this->admins;
238 }

◆ isAssigned()

ilParticipant::isAssigned ( )

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

225 : bool
226 {
227 return $this->participants;
228 }

◆ isBlocked()

ilParticipant::isBlocked ( )

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

212 : bool
213 {
214 return (bool) ($this->participants_status[$this->getUserId()]['blocked'] ?? false);
215 }

◆ isContact()

ilParticipant::isContact ( )

Check if user is contact for current object.

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

220 : bool
221 {
222 return (bool) ($this->participants_status[$this->getUserId()]['contact'] ?? false);
223 }

◆ isMember()

ilParticipant::isMember ( )

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

230 : bool
231 {
232 return $this->members;
233 }

◆ isParticipant()

ilParticipant::isParticipant ( )

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

245 : bool
246 {
247 return $this->participants;
248 }

◆ isTutor()

ilParticipant::isTutor ( )

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

240 : bool
241 {
242 return $this->tutors;
243 }

◆ lookupStatusByMembershipRoleType()

static ilParticipant::lookupStatusByMembershipRoleType ( int  $a_obj_id,
int  $a_usr_id,
int  $a_membership_role_type 
)
static

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

175 : int {
176 global $DIC;
177
178 $ilDB = $DIC->database();
179 $query = 'SELECT * FROM obj_members ' .
180 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
181 'AND usr_id = ' . $ilDB->quote($a_usr_id, ilDBConstants::T_INTEGER) . ' ';
182 $res = $ilDB->query($query);
183 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
184 switch ($a_membership_role_type) {
186 return (int) $row->admin;
187
189 return (int) $row->tutor;
190
192 return (int) $row->member;
193 }
194 }
195 return 0;
196 }

References MEMBERSHIP_ADMIN, MEMBERSHIP_MEMBER, and MEMBERSHIP_TUTOR.

Referenced by updateMemberRoles().

+ Here is the caller graph for this function:

◆ readParticipant()

ilParticipant::readParticipant ( )
protected

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

258 : void
259 {
260 $this->roles = $this->rbacReview->getRolesOfRoleFolder($this->ref_id, false);
261 $this->member_roles = [];
262 foreach ($this->roles as $role_id) {
263 $title = $this->objectDataCache->lookupTitle($role_id);
264 switch (substr($title, 0, 8)) {
265 case 'il_crs_m':
266 $this->member_roles[] = $role_id;
267 $this->role_data[ilParticipants::IL_CRS_MEMBER] = $role_id;
268 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
269 $this->participants = true;
270 $this->members = true;
271 }
272 break;
273
274 case 'il_crs_a':
275 $this->role_data[ilParticipants::IL_CRS_ADMIN] = $role_id;
276 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
277 $this->participants = true;
278 $this->admins = true;
279 }
280 break;
281
282 case 'il_crs_t':
283 $this->role_data[ilParticipants::IL_CRS_TUTOR] = $role_id;
284 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
285 $this->participants = true;
286 $this->tutors = true;
287 }
288 break;
289
290 case 'il_grp_a':
291 $this->role_data[ilParticipants::IL_GRP_ADMIN] = $role_id;
292 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
293 $this->participants = true;
294 $this->admins = true;
295 }
296 break;
297
298 case 'il_grp_m':
299 $this->member_roles[] = $role_id;
300 $this->role_data[ilParticipants::IL_GRP_MEMBER] = $role_id;
301 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
302 $this->participants = true;
303 $this->members = true;
304 }
305 break;
306
307 default:
308
309 $this->member_roles[] = $role_id;
310 if ($this->rbacReview->isAssigned($this->getUserId(), $role_id)) {
311 $this->participants = true;
312 $this->members = true;
313 }
314 break;
315 }
316 }
317 }

References ilParticipants\IL_CRS_ADMIN, ilParticipants\IL_CRS_MEMBER, ilParticipants\IL_CRS_TUTOR, ilParticipants\IL_GRP_ADMIN, ilParticipants\IL_GRP_MEMBER, and ILIAS\Repository\objectDataCache().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readParticipantStatus()

ilParticipant::readParticipantStatus ( )
protected

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

319 : void
320 {
321 $query = "SELECT * FROM obj_members " .
322 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
323 'AND usr_id = ' . $this->db->quote($this->getUserId(), 'integer');
324
325 $res = $this->db->query($query);
326 $this->participants_status = array();
327 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
328 $this->participants_status[$this->getUserId()]['blocked'] = (bool) $row->blocked;
329 $this->participants_status[$this->getUserId()]['notification'] = (bool) $row->notification;
330 $this->participants_status[$this->getUserId()]['passed'] = (bool) $row->passed;
331 $this->participants_status[$this->getUserId()]['contact'] = (bool) $row->contact;
332 }
333 }

References $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ updateContact()

ilParticipant::updateContact ( int  $a_usr_id,
bool  $a_contact 
)

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

414 : void
415 {
416 $this->db->manipulate(
417 'UPDATE obj_members SET ' .
418 'contact = ' . $this->db->quote($a_contact, 'integer') . ' ' .
419 'WHERE obj_id = ' . $this->db->quote($this->obj_id, 'integer') . ' ' .
420 'AND usr_id = ' . $this->db->quote($a_usr_id, 'integer')
421 );
422 $this->participants_status[$a_usr_id]['contact'] = $a_contact;
423 }

◆ updateMemberRoles()

static ilParticipant::updateMemberRoles ( int  $a_obj_id,
int  $a_usr_id,
int  $a_role_id,
int  $a_status 
)
static

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

79 : void
80 {
81 global $DIC;
82
83 $ilDB = $DIC->database();
84
85 $a_membership_role_type = self::getMembershipRoleType($a_role_id);
86 switch ($a_membership_role_type) {
88 $update_fields = array('admin' => array('integer', $a_status ? 1 : 0));
89 $update_string = ('admin = ' . $ilDB->quote($a_status ? 1 : 0, 'integer'));
90 break;
91
93 $update_fields = array('tutor' => array('integer', $a_status ? 1 : 0));
94 $update_string = ('tutor = ' . $ilDB->quote($a_status ? 1 : 0, 'integer'));
95 break;
96
98 default:
99 $current_status = self::lookupStatusByMembershipRoleType($a_obj_id, $a_usr_id, $a_membership_role_type);
100
101 if ($a_status) {
102 $new_status = $current_status + 1;
103 }
104 if (!$a_status) {
105 $new_status = $current_status - 1;
106 if ($new_status < 0) {
107 $new_status = 0;
108 }
109 }
110
111 $update_fields = array('member' => array('integer', $new_status));
112 $update_string = ('member = ' . $ilDB->quote($new_status, 'integer'));
113 break;
114 }
115
116 $query = 'SELECT count(*) num FROM obj_members ' .
117 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
118 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer');
119 $res = $ilDB->query($query);
120
121 $found = false;
122 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
123 if ($row->num) {
124 $found = true;
125 }
126 }
127 if (!$found) {
128 $ilDB->replace(
129 'obj_members',
130 array(
131 'obj_id' => array('integer', $a_obj_id),
132 'usr_id' => array('integer', $a_usr_id)
133 ),
134 $update_fields
135 );
136 } else {
137 $query = 'UPDATE obj_members SET ' .
138 $update_string . ' ' .
139 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
140 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer');
141
142 $ilDB->manipulate($query);
143 }
144
145 $query = 'DELETE from obj_members ' .
146 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
147 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer') . ' ' .
148 'AND admin = ' . $ilDB->quote(0, 'integer') . ' ' .
149 'AND tutor = ' . $ilDB->quote(0, 'integer') . ' ' .
150 'AND member = ' . $ilDB->quote(0, 'integer');
151 $ilDB->manipulate($query);
152 }
static getMembershipRoleType(int $a_role_id)
static lookupStatusByMembershipRoleType(int $a_obj_id, int $a_usr_id, int $a_membership_role_type)

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, getMembershipRoleType(), lookupStatusByMembershipRoleType(), MEMBERSHIP_ADMIN, MEMBERSHIP_MEMBER, and MEMBERSHIP_TUTOR.

Referenced by ilCourseAppEventListener\handleUserAssignments(), and ilGroupAppEventListener\handleUserAssignments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateNotification()

ilParticipant::updateNotification ( int  $a_usr_id,
bool  $a_notification 
)

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

425 : void
426 {
427 $this->participants_status[$a_usr_id]['notification'] = $a_notification;
428
429 $query = "SELECT * FROM obj_members " .
430 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
431 "AND usr_id = " . $this->db->quote($a_usr_id, 'integer');
432 $res = $this->db->query($query);
433 if ($res->numRows()) {
434 $query = "UPDATE obj_members SET " .
435 "notification = " . $this->db->quote((int) $a_notification, 'integer') . " " .
436 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
437 "AND usr_id = " . $this->db->quote($a_usr_id, 'integer');
438 } else {
439 $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
440 "VALUES ( " .
441 $this->db->quote((int) $a_notification, 'integer') . ", " .
442 $this->db->quote($this->obj_id, 'integer') . ", " .
443 $this->db->quote($a_usr_id, 'integer') . ", " .
444 $this->db->quote(0, 'integer') . ", " .
445 $this->db->quote(0, 'integer') .
446 ") ON DUPLICATE KEY UPDATE notification = VALUES(notification)";
447 }
448 $this->db->manipulate($query);
449 }

References $res.

Field Documentation

◆ $admins

bool ilParticipant::$admins = false
private

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

◆ $component

string ilParticipant::$component = ''
private

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

◆ $db

ilDBInterface ilParticipant::$db
protected

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

◆ $eventHandler

ilAppEventHandler ilParticipant::$eventHandler
protected

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

◆ $member_roles

array ilParticipant::$member_roles = []
private

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

◆ $members

bool ilParticipant::$members = false
private

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

◆ $numMembers

int ilParticipant::$numMembers = null
private

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

◆ $obj_id

int ilParticipant::$obj_id = 0
private

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

◆ $objectDataCache

ilObjectDataCache ilParticipant::$objectDataCache
protected

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

◆ $participants

bool ilParticipant::$participants = false
private

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

◆ $participants_status

array ilParticipant::$participants_status = array()
private

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

◆ $rbacAdmin

ilRbacAdmin ilParticipant::$rbacAdmin
protected

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

◆ $rbacReview

ilRbacReview ilParticipant::$rbacReview
protected

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

◆ $recommended_content_manager

ilRecommendedContentManager ilParticipant::$recommended_content_manager
protected

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

◆ $ref_id

int ilParticipant::$ref_id = 0
private

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

◆ $role_data

array ilParticipant::$role_data = []
private

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

◆ $roles

array ilParticipant::$roles = []
private

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

◆ $tutors

bool ilParticipant::$tutors = false
private

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

◆ $type

string ilParticipant::$type = ''
protected

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

◆ $usr_id

int ilParticipant::$usr_id = 0
private

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

◆ MEMBERSHIP_ADMIN

const ilParticipant::MEMBERSHIP_ADMIN = 1
protected

◆ MEMBERSHIP_MEMBER

const ilParticipant::MEMBERSHIP_MEMBER = 3
protected

◆ MEMBERSHIP_TUTOR

const ilParticipant::MEMBERSHIP_TUTOR = 2
protected

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