ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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 27 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 58 of file class.ilParticipant.php.

59 {
60 global $DIC;
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 $this->component = $a_component_name;
68
69 $this->recommended_content_manager = new ilRecommendedContentManager();
70 $this->db = $DIC->database();
71 $this->rbacReview = $DIC->rbac()->review();
72 $this->rbacAdmin = $DIC->rbac()->admin();
73 $this->objectDataCache = $DIC['ilObjDataCache'];
74 $this->eventHandler = $DIC->event();
75
76 $this->readParticipant();
77 $this->readParticipantStatus();
78 }
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 336 of file class.ilParticipant.php.

336 : bool
337 {
338 if ($this->rbacReview->isAssignedToAtLeastOneGivenRole($a_usr_id, $this->roles)) {
339 return false;
340 }
341
342 switch ($a_role) {
345 $this->admins = true;
346 break;
347
349 $this->tutors = true;
350 break;
351
354 $this->members = true;
355 break;
356 }
357
358 $this->rbacAdmin->assignUser($this->role_data[$a_role], $a_usr_id);
359 $this->addRecommendation($a_usr_id);
360
361 // Delete subscription request
362 $this->deleteSubscriber($a_usr_id);
363
364 ilWaitingList::deleteUserEntry($a_usr_id, $this->obj_id);
365
366 $this->eventHandler->raise(
367 $this->getComponent(),
368 "addParticipant",
369 array(
370 'obj_id' => $this->obj_id,
371 'usr_id' => $a_usr_id,
372 'role_id' => $a_role
373 )
374 );
375 return true;
376 }
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 408 of file class.ilParticipant.php.

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

◆ checkLastAdmin()

ilParticipant::checkLastAdmin ( array  $a_usr_ids)

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

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

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

References $res.

◆ deleteSubscriber()

ilParticipant::deleteSubscriber ( int  $a_usr_id)

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

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

References $res.

◆ getComponent()

ilParticipant::getComponent ( )
protected

Get component name Used for event handling.

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

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

◆ getMembershipRoleType()

static ilParticipant::getMembershipRoleType ( int  $a_role_id)
static

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

155 : int
156 {
157 $title = ilObject::_lookupTitle($a_role_id);
158 switch (substr($title, 0, 8)) {
159 case 'il_crs_a':
160 case 'il_grp_a':
162
163 case 'il_crs_t':
165
166 case 'il_crs_m':
167 default:
169 }
170 }
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 251 of file class.ilParticipant.php.

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

◆ getUserId()

ilParticipant::getUserId ( )

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

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

◆ isAdmin()

ilParticipant::isAdmin ( )

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

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

◆ isAssigned()

ilParticipant::isAssigned ( )

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

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

◆ isBlocked()

ilParticipant::isBlocked ( )

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

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

◆ isContact()

ilParticipant::isContact ( )

Check if user is contact for current object.

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

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

◆ isMember()

ilParticipant::isMember ( )

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

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

◆ isParticipant()

ilParticipant::isParticipant ( )

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

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

◆ isTutor()

ilParticipant::isTutor ( )

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

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

◆ lookupStatusByMembershipRoleType()

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

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

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

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 259 of file class.ilParticipant.php.

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

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 320 of file class.ilParticipant.php.

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

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 415 of file class.ilParticipant.php.

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

◆ updateMemberRoles()

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

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

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

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

References $res.

Field Documentation

◆ $admins

bool ilParticipant::$admins = false
private

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

◆ $component

string ilParticipant::$component = ''
private

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

◆ $db

ilDBInterface ilParticipant::$db
protected

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

◆ $eventHandler

ilAppEventHandler ilParticipant::$eventHandler
protected

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

◆ $member_roles

array ilParticipant::$member_roles = []
private

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

◆ $members

bool ilParticipant::$members = false
private

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

◆ $numMembers

int ilParticipant::$numMembers = null
private

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

◆ $obj_id

int ilParticipant::$obj_id = 0
private

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

◆ $objectDataCache

ilObjectDataCache ilParticipant::$objectDataCache
protected

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

◆ $participants

bool ilParticipant::$participants = false
private

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

◆ $participants_status

array ilParticipant::$participants_status = array()
private

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

◆ $rbacAdmin

ilRbacAdmin ilParticipant::$rbacAdmin
protected

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

◆ $rbacReview

ilRbacReview ilParticipant::$rbacReview
protected

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

◆ $recommended_content_manager

ilRecommendedContentManager ilParticipant::$recommended_content_manager
protected

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

◆ $ref_id

int ilParticipant::$ref_id = 0
private

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

◆ $role_data

array ilParticipant::$role_data = []
private

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

◆ $roles

array ilParticipant::$roles = []
private

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

◆ $tutors

bool ilParticipant::$tutors = false
private

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

◆ $type

string ilParticipant::$type = ''
protected

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

◆ $usr_id

int ilParticipant::$usr_id = 0
private

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