ILIAS  release_8 Revision v8.23
class.ilParticipants.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
30 abstract class ilParticipants
31 {
32  public const IL_CRS_ADMIN = 1;
33  public const IL_CRS_TUTOR = 3;
34  public const IL_CRS_MEMBER = 2;
35  public const IL_GRP_ADMIN = 4;
36  public const IL_GRP_MEMBER = 5;
37  public const IL_SESS_MEMBER = 6;
38  public const IL_LSO_ADMIN = 7;
39  public const IL_LSO_MEMBER = 8;
40  public const IL_ROLE_POSITION_ADMIN = 1;
41  public const IL_ROLE_POSITION_TUTOR = 2;
42  public const IL_ROLE_POSITION_MEMBER = 3;
43 
44  protected string $component = '';
45  protected int $ref_id = 0;
46  protected int $obj_id = 0;
47  protected string $type = '';
48  protected array $roles = [];
49  protected array $role_data = [];
50  protected array $roles_sorted = [];
51  protected array $role_assignments = [];
52  protected array $participants = [];
53  protected array $participants_status = [];
54  protected array $members = [];
55  protected array $tutors = [];
56  protected array $admins = [];
57  protected array $subscribers = [];
62  protected ilDBInterface $ilDB;
63  protected ilLanguage $lng;
64  protected ilLogger $logger;
67 
72  public function __construct(string $a_component_name, int $a_ref_id)
73  {
74  global $DIC;
75 
76  $this->ilDB = $DIC->database();
77  $this->lng = $DIC->language();
78  $this->logger = $DIC->logger()->mmbr();
79  $this->eventHandler = $DIC->event();
80  $this->rbacReview = $DIC->rbac()->review();
81  $this->rbacAdmin = $DIC->rbac()->admin();
82  $this->objectDataCache = $DIC['ilObjDataCache'];
83  $this->error = $DIC['ilErr'];
84  $this->component = $a_component_name;
85  $this->ref_id = $a_ref_id;
86  $this->obj_id = ilObject::_lookupObjId($a_ref_id);
87  $this->type = ilObject::_lookupType($this->obj_id);
88  $this->recommended_content_manager = new ilRecommendedContentManager();
89 
90  $this->readParticipants();
91  $this->readParticipantsStatus();
92  }
93 
94  public static function getInstance(int $a_ref_id): ilParticipants
95  {
96  global $DIC;
97 
98  $logger = $DIC->logger()->mmbr();
99 
100  $obj_id = ilObject::_lookupObjId($a_ref_id);
101  $type = ilObject::_lookupType($obj_id);
102 
103  switch ($type) {
104  case 'crs':
105  case 'grp':
106  case 'lso':
107  return self::getInstanceByObjId($obj_id);
108  case 'sess':
109  return ilSessionParticipants::getInstance($a_ref_id);
110  default:
111  $logger()->mem()->logStack();
112  $logger()->mem()->warning('Invalid ref_id -> obj_id given: ' . $a_ref_id . ' -> ' . $obj_id);
113  throw new InvalidArgumentException('Invalid obj_id given.');
114  }
115  }
116 
122  public static function getInstanceByObjId(int $a_obj_id): ilParticipants
123  {
124  global $DIC;
125 
126  $logger = $DIC->logger()->mmbr();
127 
128  $type = ilObject::_lookupType($a_obj_id);
129  switch ($type) {
130  case 'crs':
132 
133  case 'grp':
135 
136  case 'sess':
138  case 'lso':
140  default:
142  $logger()->mmbr()->warning(': Invalid obj_id given: ' . $a_obj_id);
143  throw new InvalidArgumentException('Invalid obj id given');
144  }
145  }
146 
151  protected function getComponent(): string
152  {
153  return $this->component;
154  }
155 
159  public static function hasParticipantListAccess(int $a_obj_id, int $a_usr_id = null): bool
160  {
161  global $DIC;
162 
163  $access = $DIC->access();
164 
165  if (!$a_usr_id) {
166  $a_usr_id = $DIC->user()->getId();
167  }
168 
169  // if write access granted => return true
170  $refs = ilObject::_getAllReferences($a_obj_id);
171  $ref_id = end($refs);
172 
173  if ($access->checkAccess('manage_members', '', $ref_id)) {
174  return true;
175  }
176  $part = self::getInstance($ref_id);
177  if ($part->isAssigned($a_usr_id)) {
178  if ($part->getType() === 'crs') {
179  if (!ilObjCourse::lookupShowMembersEnabled($a_obj_id)) {
180  return false;
181  }
182  }
183  if ($part->getType() === 'grp') {
184  if (!ilObjGroup::lookupShowMembersEnabled($a_obj_id)) {
185  return false;
186  }
187  }
188  return true;
189  }
190  // User is not assigned to course/group => no read access
191  return false;
192  }
193 
199  public static function canSendMailToMembers(
200  $ref_id_or_instance,
201  ?int $usr_id = null,
202  ?int $mail_obj_ref_id = null
203  ): bool {
204  global $DIC;
205 
206  $access = $DIC->access();
207  $rbacsystem = $DIC->rbac()->system();
208 
209  if (is_null($usr_id)) {
210  $usr_id = $DIC->user()->getId();
211  }
212  if (is_null($mail_obj_ref_id)) {
213  $mail_obj_ref_id = (new ilMail($usr_id))->getMailObjectReferenceId();
214  }
215  if (is_int($ref_id_or_instance)) {
216  $ref_id = $ref_id_or_instance;
217  } elseif ($ref_id_or_instance instanceof ilObject) {
218  $ref_id = (int) $ref_id_or_instance->getRefId();
219  if ($ref_id === 0) {
220  $ref_id = array_keys(ilObject::_getAllReferences($ref_id_or_instance->getId()))[0];
221  }
222  } else {
223  return false;
224  }
225 
226  if (
227  $access->checkAccess('manage_members', '', $ref_id) &&
228  $rbacsystem->checkAccess('internal_mail', $mail_obj_ref_id)
229  ) {
230  return true;
231  }
232 
233  $part = self::getInstance($ref_id);
234  if (!$part->isAssigned($usr_id)) {
235  return false;
236  }
237 
238  $object = $ref_id_or_instance;
239  if (is_int($ref_id_or_instance)) {
240  $object = ilObjectFactory::getInstanceByRefId($ref_id_or_instance);
241  }
242 
243  if ($object instanceof ilObjCourse) {
244  return $object->getMailToMembersType() == ilCourseConstants::MAIL_ALLOWED_ALL;
245  } elseif ($object instanceof ilObjGroup) {
246  return $object->getMailToMembersType() == ilObjGroup::MAIL_ALLOWED_ALL;
247  } elseif ($object instanceof ilObjSession) {
248  return $object->getMailToMembersType() == ilObjSession::MAIL_ALLOWED_ALL;
249  }
250 
251  return false;
252  }
253 
254 
258  public static function getUserMembershipAssignmentsByType(
259  array $a_user_ids,
260  array $a_type,
261  bool $a_only_member_roles
262  ): array {
263  global $DIC;
264 
265  $ilDB = $DIC->database();
266 
267  $j2 = $a2 = '';
268  if ($a_only_member_roles) {
269  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
270  $a2 = 'AND obd2.title = ' . $ilDB->concat(
271  array(
272  array($ilDB->quote('il_', 'text')),
273  array('obd.type'),
274  array($ilDB->quote('_member_', 'text')),
275  array('obr.ref_id'),
276  ),
277  false
278  );
279  }
280 
281  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id,ua.usr_id FROM rbac_ua ua " .
282  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
283  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
284  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
285  $j2 .
286  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") .
287  "AND fa.assign = 'y' " .
288  'AND ' . $ilDB->in('ua.usr_id', $a_user_ids, false, 'integer') . ' ' .
289  $a2;
290 
291  $obj_ids = [];
292  $res = $ilDB->query($query);
293  while ($row = $ilDB->fetchObject($res)) {
294  $obj_ids[(int) $row->obj_id][] = (int) $row->usr_id;
295  }
296  return $obj_ids;
297  }
298 
306  public static function _getMembershipByType(
307  int $a_usr_id,
308  array $a_type,
309  bool $a_only_member_role = false
310  ): array {
311  global $DIC;
312 
313  $ilDB = $DIC['ilDB'];
314 
315  $j2 = '';
316  $a2 = '';
317  // this will also dismiss local roles!
318  if ($a_only_member_role) {
319  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
320  $a2 = 'AND obd2.title = ' . $ilDB->concat(
321  array(
322  array($ilDB->quote('il_', 'text')),
323  array('obd.type'),
324  array($ilDB->quote('_member_', 'text')),
325  array('obr.ref_id'),
326  ),
327  false
328  );
329  }
330 
331  // #14290 - no role folder anymore
332  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
333  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
334  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
335  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
336  $j2 .
337  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") . ' ' .
338  "AND fa.assign = 'y' " .
339  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
340  'AND obr.deleted IS NULL ' .
341  $a2;
342  $res = $ilDB->query($query);
343  $ref_ids = [];
344  while ($row = $ilDB->fetchObject($res)) {
345  $ref_ids[] = (int) $row->obj_id;
346  }
347  return $ref_ids;
348  }
349 
353  public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
354  {
355  global $DIC;
356 
357  $rbacreview = $DIC->rbac()->review();
358  $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
359  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
360  }
361 
365  public static function lookupNumberOfParticipants(int $a_ref_id): int
366  {
367  global $DIC;
368 
369  $rbacreview = $DIC->rbac()->review();
370  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
371  return $rbacreview->getNumberOfAssignedUsers($lroles);
372  }
373 
377  public static function lookupNumberOfMembers(int $a_ref_id): int
378  {
379  global $DIC;
380 
381  $rbacreview = $DIC->rbac()->review();
382  $ilObjDataCache = $DIC['ilObjDataCache'];
383  $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
384  if (!$has_policies) {
385  return 0;
386  }
387  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
388  $memberRoles = array();
389  foreach ($lroles as $role_id) {
390  $title = $ilObjDataCache->lookupTitle($role_id);
391  switch (substr($title, 0, 8)) {
392  case 'il_crs_a':
393  case 'il_crs_t':
394  case 'il_grp_a':
395  case 'il_sess_':
396  break;
397 
398  default:
399  $memberRoles[] = $role_id;
400  break;
401  }
402  }
403  return $rbacreview->getNumberOfAssignedUsers($memberRoles);
404  }
405 
409  public static function _isBlocked(int $a_obj_id, int $a_usr_id): bool
410  {
411  global $DIC;
412 
413  $ilDB = $DIC->database();
414  $query = "SELECT * FROM obj_members " .
415  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
416  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
417  "AND blocked = " . $ilDB->quote(1, 'integer');
418  $res = $ilDB->query($query);
419  return (bool) $res->numRows();
420  }
421 
425  public static function _hasPassed(int $a_obj_id, int $a_usr_id): bool
426  {
427  global $DIC;
428 
429  $ilDB = $DIC->database();
430  $query = "SELECT * FROM obj_members " .
431  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
432  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
433  "AND passed = '1'";
434  $res = $ilDB->query($query);
435  return (bool) $res->numRows();
436  }
437 
442  public static function _deleteAllEntries(int $a_obj_id): void
443  {
444  global $DIC;
445 
446  $ilDB = $DIC->database();
447  $query = "DELETE FROM obj_members " .
448  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
449  $res = $ilDB->manipulate($query);
450 
451  $query = "DELETE FROM il_subscribers " .
452  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
453  $res = $ilDB->manipulate($query);
454 
455  $query = 'DELETE FROM crs_waiting_list ' .
456  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
457  $ilDB->manipulate($query);
458  }
459 
463  public static function _deleteUser(int $a_usr_id): void
464  {
465  global $DIC;
466 
467  $ilDB = $DIC->database();
468  $query = "DELETE FROM obj_members WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
469  $res = $ilDB->manipulate($query);
470 
471  $query = "DELETE FROM il_subscribers WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
472  $res = $ilDB->manipulate($query);
473 
475  }
476 
477  public static function getDefaultMemberRole(int $a_ref_id): int
478  {
479  global $DIC;
480 
481  $rbacreview = $DIC->rbac()->review();
482 
483  $obj_id = ilObject::_lookupObjId($a_ref_id);
484  $type = ilObject::_lookupType($obj_id);
485 
486  if (!in_array($type, array('crs', 'grp'))) {
487  return 0;
488  }
489 
490  $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
491  foreach ($roles as $role) {
492  $title = ilObject::_lookupTitle($role);
493  if (strpos($title, ('il_' . $type . '_member')) === 0) {
494  return $role;
495  }
496  }
497  return 0;
498  }
499 
500  public function getObjId(): int
501  {
502  return $this->obj_id;
503  }
504 
505  public function getType(): string
506  {
507  return $this->type;
508  }
509 
514  public function getNotificationRecipients(): array
515  {
516  $query = "SELECT * FROM obj_members " .
517  "WHERE notification = 1 " .
518  "AND obj_id = " . $this->ilDB->quote($this->obj_id, ilDBConstants::T_INTEGER) . " ";
519  $res = $this->ilDB->query($query);
520  $recp = [];
521  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
522  if ($this->isAdmin((int) $row->usr_id) || $this->isTutor((int) $row->usr_id)) {
523  $recp[] = (int) $row->usr_id;
524  }
525  }
526  return $recp;
527  }
528 
532  public function getCountMembers(): int
533  {
534  return count($this->members);
535  }
536 
540  public function getCountParticipants(): int
541  {
542  return count($this->participants);
543  }
544 
549  public function getParticipants(): array
550  {
551  return $this->participants;
552  }
553 
559  public function getMembers(): array
560  {
561  return $this->members;
562  }
563 
568  public function getAdmins(): array
569  {
570  return $this->admins;
571  }
572 
573  public function getCountAdmins(): int
574  {
575  return count($this->getAdmins());
576  }
577 
582  public function getTutors(): array
583  {
584  return $this->tutors;
585  }
586 
590  public function isAdmin(int $a_usr_id): bool
591  {
592  return in_array($a_usr_id, $this->admins);
593  }
594 
598  public function isTutor(int $a_usr_id): bool
599  {
600  return in_array($a_usr_id, $this->tutors);
601  }
602 
606  public function isMember(int $a_usr_id): bool
607  {
608  return in_array($a_usr_id, $this->members);
609  }
610 
614  public function isAssigned(int $a_usr_id): bool
615  {
616  return in_array($a_usr_id, $this->participants);
617  }
618 
622  public function isLastAdmin(int $a_usr_id): bool
623  {
624  return in_array($a_usr_id, $this->getAdmins()) && count($this->getAdmins()) === 1;
625  }
626 
630  public function getRoles(): array
631  {
632  return $this->roles;
633  }
634 
638  public function getAssignedRoles(int $a_usr_id): array
639  {
640  $assigned = [];
641  foreach ($this->roles as $role) {
642  if ($this->rbacReview->isAssigned($a_usr_id, $role)) {
643  $assigned[] = $role;
644  }
645  }
646  return $assigned;
647  }
648 
655  public function updateRoleAssignments($a_usr_id, $a_roles): void
656  {
657  foreach ($this->getRoles() as $role_id) {
658  if ($this->rbacReview->isAssigned($a_usr_id, $role_id)) {
659  if (!in_array($role_id, $a_roles)) {
660  $this->rbacAdmin->deassignUser($role_id, $a_usr_id);
661  }
662  } elseif (in_array($role_id, $a_roles)) {
663  $this->rbacAdmin->assignUser($role_id, $a_usr_id);
664  }
665  }
666  $this->rbacReview->clearCaches();
667  $this->readParticipants();
668  $this->readParticipantsStatus();
669  }
670 
677  public function checkLastAdmin(array $a_usr_ids): bool
678  {
679  foreach ($this->getAdmins() as $admin_id) {
680  if (!in_array($admin_id, $a_usr_ids)) {
681  return true;
682  }
683  }
684  return false;
685  }
686 
690  public function isBlocked(int $a_usr_id): bool
691  {
692  if (isset($this->participants_status[$a_usr_id])) {
693  return (bool) $this->participants_status[$a_usr_id]['blocked'];
694  }
695  return false;
696  }
697 
701  public function hasPassed(int $a_usr_id): bool
702  {
703  if (isset($this->participants_status[$a_usr_id])) {
704  return (bool) $this->participants_status[$a_usr_id]['passed'];
705  }
706  return false;
707  }
708 
712  public function delete(int $a_usr_id): void
713  {
714  $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->ref_id);
715  foreach ($this->roles as $role_id) {
716  $this->rbacAdmin->deassignUser($role_id, $a_usr_id);
717  }
718 
719  $query = "DELETE FROM obj_members " .
720  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
721  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
722  $res = $this->ilDB->manipulate($query);
723 
724  $this->readParticipants();
725  $this->readParticipantsStatus();
726 
727  $this->eventHandler->raise(
728  $this->getComponent(),
729  "deleteParticipant",
730  [
731  'obj_id' => $this->obj_id,
732  'usr_id' => $a_usr_id
733  ]
734  );
735  }
736 
740  public function updateBlocked(int $a_usr_id, bool $a_blocked): void
741  {
742  $this->participants_status[$a_usr_id]['blocked'] = (int) $a_blocked;
743  $query = "SELECT * FROM obj_members " .
744  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
745  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
746  $res = $this->ilDB->query($query);
747  if ($res->numRows()) {
748  $query = "UPDATE obj_members SET " .
749  "blocked = " . $this->ilDB->quote((int) $a_blocked, 'integer') . " " .
750  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
751  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
752  } else {
753  $query = "INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) " .
754  "VALUES ( " .
755  $this->ilDB->quote((int) $a_blocked, 'integer') . ", " .
756  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
757  $this->ilDB->quote($a_usr_id, 'integer') . ", " .
758  $this->ilDB->quote(0, 'integer') . ", " .
759  $this->ilDB->quote(0, 'integer') .
760  ") ON DUPLICATE KEY UPDATE blocked = VALUES(blocked)";
761  }
762  $res = $this->ilDB->manipulate($query);
763  }
764 
765  public function updateContact(int $a_usr_id, bool $a_contact): void
766  {
767  $this->ilDB->manipulate(
768  'UPDATE obj_members SET ' .
769  'contact = ' . $this->ilDB->quote($a_contact, 'integer') . ' ' .
770  'WHERE obj_id = ' . $this->ilDB->quote($this->obj_id, 'integer') . ' ' .
771  'AND usr_id = ' . $this->ilDB->quote($a_usr_id, 'integer')
772  );
773  $this->participants_status[$a_usr_id]['contact'] = $a_contact;
774  }
775 
780  public function getContacts(): array
781  {
782  $contacts = array();
783  foreach ($this->participants_status as $usr_id => $status) {
784  if ($status['contact']) {
785  $contacts[] = (int) $usr_id;
786  }
787  }
788  return $contacts;
789  }
790 
794  public function updateNotification(int $a_usr_id, bool $a_notification): void
795  {
796  $this->participants_status[$a_usr_id]['notification'] = $a_notification;
797 
798  $query = "SELECT * FROM obj_members " .
799  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
800  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
801  $res = $this->ilDB->query($query);
802  if ($res->numRows()) {
803  $query = "UPDATE obj_members SET " .
804  "notification = " . $this->ilDB->quote((int) $a_notification, 'integer') . " " .
805  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
806  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
807  } else {
808  $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
809  "VALUES ( " .
810  $this->ilDB->quote((int) $a_notification, 'integer') . ", " .
811  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
812  $this->ilDB->quote($a_usr_id, 'integer') . ", " .
813  $this->ilDB->quote(0, 'integer') . ", " .
814  $this->ilDB->quote(0, 'integer') .
815  ") ON DUPLICATE KEY UPDATE notification = VALUES(notification)";
816  }
817  $res = $this->ilDB->manipulate($query);
818  }
819 
820  public function add(int $a_usr_id, int $a_role): bool
821  {
822  if ($this->isAssigned($a_usr_id)) {
823  return false;
824  }
825 
826  switch ($a_role) {
827  case self::IL_LSO_ADMIN:
828  case self::IL_GRP_ADMIN:
829  case self::IL_CRS_ADMIN:
830  $this->admins[] = $a_usr_id;
831  break;
832 
833  case self::IL_CRS_TUTOR:
834  $this->tutors[] = $a_usr_id;
835  break;
836 
837  case self::IL_SESS_MEMBER:
838  case self::IL_LSO_MEMBER:
839  case self::IL_GRP_MEMBER:
840  case self::IL_CRS_MEMBER:
841  $this->members[] = $a_usr_id;
842  break;
843 
844  }
845 
846  $this->participants[] = $a_usr_id;
847  $this->rbacAdmin->assignUser($this->role_data[$a_role], $a_usr_id);
848 
849  // Delete subscription request
850  $this->deleteSubscriber($a_usr_id);
851 
852  ilWaitingList::deleteUserEntry($a_usr_id, $this->obj_id);
853 
854  $this->eventHandler->raise(
855  $this->getComponent(),
856  "addParticipant",
857  array(
858  'obj_id' => $this->obj_id,
859  'usr_id' => $a_usr_id,
860  'role_id' => $a_role
861  )
862  );
863  return true;
864  }
865 
869  public function deleteParticipants(array $a_user_ids): bool
870  {
871  foreach ($a_user_ids as $user_id) {
872  $this->delete($user_id);
873  }
874  return true;
875  }
876 
881  public function addRecommendation(int $a_usr_id): void
882  {
883  // deactivated for now, see discussion at
884  // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
885  // $this->recommended_content_manager->addObjectRecommendation($a_usr_id, $this->ref_id);
886  }
887 
888  public function isNotificationEnabled(int $a_usr_id): bool
889  {
890  if (isset($this->participants_status[$a_usr_id])) {
891  return (bool) $this->participants_status[$a_usr_id]['notification'];
892  }
893  return false;
894  }
895 
896  public function isContact(int $a_usr_id): bool
897  {
898  if (isset($this->participants_status[$a_usr_id])) {
899  return (bool) $this->participants_status[$a_usr_id]['contact'];
900  }
901  return false;
902  }
903 
904  public function getAutoGeneratedRoleId(int $a_role_type): int
905  {
906  if (array_key_exists($a_role_type, $this->role_data)) {
907  return $this->role_data[$a_role_type];
908  }
909  return 0;
910  }
911 
912  protected function readParticipants(): void
913  {
914  $this->roles = $this->rbacReview->getRolesOfRoleFolder($this->ref_id, false);
915  $this->participants = [];
916  $this->members = $this->admins = $this->tutors = [];
917 
918  $additional_roles = [];
919  $auto_generated_roles = [];
920  foreach ($this->roles as $role_id) {
921  $title = $this->objectDataCache->lookupTitle($role_id);
922  switch (substr($title, 0, 8)) {
923  case 'il_crs_m':
924  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
925  $this->role_data[self::IL_CRS_MEMBER] = $role_id;
926  $this->participants = array_unique(array_merge(
927  $assigned = $this->rbacReview->assignedUsers($role_id),
929  ));
930  $this->members = array_unique(array_merge($assigned, $this->members));
931  $this->role_assignments[$role_id] = $assigned;
932  break;
933 
934  case 'il_crs_a':
935  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
936  $this->role_data[self::IL_CRS_ADMIN] = $role_id;
937  $this->participants = array_unique(array_merge(
938  $assigned = $this->rbacReview->assignedUsers($role_id),
940  ));
941  $this->admins = $this->rbacReview->assignedUsers($role_id);
942  $this->role_assignments[$role_id] = $assigned;
943  break;
944 
945  case 'il_crs_t':
946  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_TUTOR;
947  $this->role_data[self::IL_CRS_TUTOR] = $role_id;
948  $this->participants = array_unique(array_merge(
949  $assigned = $this->rbacReview->assignedUsers($role_id),
951  ));
952  $this->tutors = $this->rbacReview->assignedUsers($role_id);
953  $this->role_assignments[$role_id] = $assigned;
954  break;
955 
956  case 'il_grp_a':
957  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
958  $this->role_data[self::IL_GRP_ADMIN] = $role_id;
959  $this->participants = array_unique(array_merge(
960  $assigned = $this->rbacReview->assignedUsers($role_id),
962  ));
963  $this->admins = $this->rbacReview->assignedUsers($role_id);
964  $this->role_assignments[$role_id] = $assigned;
965  break;
966 
967  case 'il_grp_m':
968  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
969  $this->role_data[self::IL_GRP_MEMBER] = $role_id;
970  $this->participants = array_unique(array_merge(
971  $assigned = $this->rbacReview->assignedUsers($role_id),
973  ));
974  $this->members = $this->rbacReview->assignedUsers($role_id);
975  $this->role_assignments[$role_id] = $assigned;
976  break;
977 
978  case 'il_sess_':
979  $this->role_data[self::IL_SESS_MEMBER] = $role_id;
980  $this->participants = array_unique(array_merge(
981  $assigned = $this->rbacReview->assignedUsers($role_id),
983  ));
984  $this->members = $this->rbacReview->assignedUsers($role_id);
985  break;
986 
987  case 'il_lso_m':
988  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
989  $this->role_data[self::IL_LSO_MEMBER] = $role_id;
990  $this->participants = array_unique(array_merge(
991  $assigned = $this->rbacReview->assignedUsers($role_id),
993  ));
994  $this->members = $this->rbacReview->assignedUsers($role_id);
995  $this->role_assignments[$role_id] = $assigned;
996  break;
997 
998  case 'il_lso_a':
999  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
1000  $this->role_data[self::IL_LSO_ADMIN] = $role_id;
1001  $this->participants = array_unique(array_merge(
1002  $assigned = $this->rbacReview->assignedUsers($role_id),
1004  ));
1005  $this->admins = $this->rbacReview->assignedUsers($role_id);
1006  $this->role_assignments[$role_id] = $assigned;
1007  break;
1008 
1009  default:
1010  $additional_roles[$role_id] = $title;
1011  $this->participants = array_unique(array_merge(
1012  $assigned = $this->rbacReview->assignedUsers($role_id),
1014  ));
1015  $this->members = array_unique(array_merge($assigned, $this->members));
1016  $this->role_assignments[$role_id] = $assigned;
1017  break;
1018  }
1019  }
1020  asort($auto_generated_roles);
1021  asort($additional_roles);
1022  $this->roles_sorted = $auto_generated_roles + $additional_roles;
1023  }
1024 
1028  protected function readParticipantsStatus(): void
1029  {
1030  $query = "SELECT * FROM obj_members " .
1031  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1032  $res = $this->ilDB->query($query);
1033  $this->participants_status = [];
1034  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1035  $this->participants_status[(int) $row->usr_id]['blocked'] = (bool) $row->blocked;
1036  $this->participants_status[(int) $row->usr_id]['notification'] = (bool) $row->notification;
1037  $this->participants_status[(int) $row->usr_id]['passed'] = (bool) $row->passed;
1038  $this->participants_status[(int) $row->usr_id]['contact'] = (bool) $row->contact;
1039  }
1040  }
1041 
1045  public function isGroupingMember(int $a_usr_id, string $a_field = ''): bool
1046  {
1047  if ($a_field === '') {
1048  return false;
1049  }
1050  // Used for membership limitations -> check membership by given field
1051  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
1052  if (!$tmp_user instanceof ilObjUser) {
1053  $this->logger->logStack(ilLogLevel::ERROR);
1054  throw new DomainException('Invalid user id given: ' . $a_usr_id);
1055  }
1056  switch ($a_field) {
1057  case 'login':
1058  $and = "AND login = " . $this->ilDB->quote($tmp_user->getLogin(), 'text') . " ";
1059  break;
1060  case 'email':
1061  $and = "AND email = " . $this->ilDB->quote($tmp_user->getEmail(), 'text') . " ";
1062  break;
1063  case 'matriculation':
1064  $and = "AND matriculation = " . $this->ilDB->quote($tmp_user->getMatriculation(), 'text') . " ";
1065  break;
1066 
1067  default:
1068  $and = "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " ";
1069  break;
1070  }
1071 
1072  if (!$this->getParticipants()) {
1073  return false;
1074  }
1075 
1076  $query = "SELECT * FROM usr_data ud " .
1077  "WHERE " . $this->ilDB->in('usr_id', $this->getParticipants(), false, 'integer') . " " .
1078  $and;
1079 
1080  $res = $this->ilDB->query($query);
1081  return (bool) $res->numRows();
1082  }
1083 
1087  public static function lookupSubscribers(int $a_obj_id): array
1088  {
1089  global $DIC;
1090 
1091  $ilDB = $DIC['ilDB'];
1092  $subscribers = array();
1093  $query = "SELECT usr_id FROM il_subscribers " .
1094  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
1095  "ORDER BY sub_time ";
1096 
1097  $res = $ilDB->query($query);
1098  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1099  $subscribers[] = (int) $row->usr_id;
1100  }
1101  return $subscribers;
1102  }
1103 
1108  public function getSubscribers(): array
1109  {
1110  $this->readSubscribers();
1111  return $this->subscribers;
1112  }
1113 
1114  public function getCountSubscribers(): int
1115  {
1116  return count($this->getSubscribers());
1117  }
1118 
1119  public function getSubscriberData(int $a_usr_id): array
1120  {
1121  return $this->readSubscriberData($a_usr_id);
1122  }
1123 
1124  public function assignSubscribers(array $a_usr_ids): bool
1125  {
1126  if (!is_array($a_usr_ids) || !count($a_usr_ids)) {
1127  return false;
1128  }
1129  foreach ($a_usr_ids as $id) {
1130  if (!$this->assignSubscriber($id)) {
1131  return false;
1132  }
1133  }
1134  return true;
1135  }
1136 
1137  public function assignSubscriber(int $a_usr_id): bool
1138  {
1139  $this->error->setMessage("");
1140  if (!$this->isSubscriber($a_usr_id)) {
1141  $this->error->appendMessage($this->lng->txt("crs_user_notsubscribed"));
1142 
1143  return false;
1144  }
1145  if ($this->isAssigned($a_usr_id)) {
1146  $tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id);
1147  $this->error->appendMessage($tmp_obj->getLogin() . ": " . $this->lng->txt("crs_user_already_assigned"));
1148 
1149  return false;
1150  }
1151 
1152  if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id, false)) {
1153  $this->error->appendMessage($this->lng->txt("crs_user_not_exists"));
1154  return false;
1155  }
1156 
1157  if ($this instanceof ilCourseParticipants) {
1158  $this->add($tmp_obj->getId(), self::IL_CRS_MEMBER);
1159  }
1160  if ($this instanceof ilGroupParticipants) {
1161  $this->add($tmp_obj->getId(), self::IL_GRP_MEMBER);
1162  }
1163  if ($this instanceof ilLearningSequenceParticipants) {
1164  $this->add($tmp_obj->getId(), self::IL_LSO_MEMBER);
1165  }
1166  if ($this instanceof ilSessionParticipants) {
1167  $this->register($tmp_obj->getId());
1168  }
1169  $this->deleteSubscriber($a_usr_id);
1170  return true;
1171  }
1172 
1176  public function autoFillSubscribers(): int
1177  {
1178  $this->readSubscribers();
1179  $counter = 0;
1180  foreach ($this->subscribers as $subscriber) {
1181  if (!$this->assignSubscriber($subscriber)) {
1182  continue;
1183  }
1184  ++$counter;
1185  }
1186  return $counter;
1187  }
1188 
1189  public function addSubscriber(int $a_usr_id): void
1190  {
1191  $query = "INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) " .
1192  " VALUES (" .
1193  $this->ilDB->quote($a_usr_id, 'integer') . "," .
1194  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
1195  $this->ilDB->quote('', 'text') . ", " .
1196  $this->ilDB->quote(time(), 'integer') .
1197  ")";
1198  $res = $this->ilDB->manipulate($query);
1199  }
1200 
1201  public function updateSubscriptionTime(int $a_usr_id, int $a_subtime): void
1202  {
1203  $query = "UPDATE il_subscribers " .
1204  "SET sub_time = " . $this->ilDB->quote($a_subtime, 'integer') . " " .
1205  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1206  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1207  $res = $this->ilDB->manipulate($query);
1208  }
1209 
1210  public function updateSubject(int $a_usr_id, string $a_subject): void
1211  {
1212  $query = "UPDATE il_subscribers " .
1213  "SET subject = " . $this->ilDB->quote($a_subject, 'text') . " " .
1214  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1215  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1216  $res = $this->ilDB->manipulate($query);
1217  }
1218 
1219  public function deleteSubscriber(int $a_usr_id): void
1220  {
1221  $query = "DELETE FROM il_subscribers " .
1222  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1223  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1224  $res = $this->ilDB->manipulate($query);
1225  }
1226 
1227  public function deleteSubscribers(array $a_usr_ids): bool
1228  {
1229  if (!count($a_usr_ids)) {
1230  $this->error->setMessage('');
1231  $this->error->appendMessage($this->lng->txt("no_usr_ids_given"));
1232  return false;
1233  }
1234  $query = "DELETE FROM il_subscribers " .
1235  "WHERE " . $this->ilDB->in('usr_id', $a_usr_ids, false, 'integer') . " " .
1236  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
1237  $res = $this->ilDB->query($query);
1238  return true;
1239  }
1240 
1241  public function isSubscriber(int $a_usr_id): bool
1242  {
1243  $query = "SELECT * FROM il_subscribers " .
1244  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1245  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
1246 
1247  $res = $this->ilDB->query($query);
1248  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1249  return true;
1250  }
1251  return false;
1252  }
1253 
1254  public static function _isSubscriber(int $a_obj_id, int $a_usr_id): bool
1255  {
1256  global $DIC;
1257 
1258  $ilDB = $DIC->database();
1259  $query = "SELECT * FROM il_subscribers " .
1260  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1261  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
1262 
1263  $res = $ilDB->query($query);
1264  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1265  return true;
1266  }
1267  return false;
1268  }
1269 
1273  protected function readSubscribers(): void
1274  {
1275  $this->subscribers = [];
1276  $query = "SELECT usr_id FROM il_subscribers " .
1277  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
1278  "ORDER BY sub_time ";
1279 
1280  $res = $this->ilDB->query($query);
1281  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1282  if (!ilObjectFactory::getInstanceByObjId((int) $row->usr_id, false)) {
1283  $this->deleteSubscriber((int) $row->usr_id);
1284  }
1285  $this->subscribers[] = (int) $row->usr_id;
1286  }
1287  }
1288 
1292  protected function readSubscriberData(int $a_usr_id): array
1293  {
1294  $query = "SELECT * FROM il_subscribers " .
1295  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
1296  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
1297 
1298  $res = $this->ilDB->query($query);
1299  $data = [];
1300  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1301  $data["time"] = (int) $row->sub_time;
1302  $data["usr_id"] = (int) $row->usr_id;
1303  $data['subject'] = (string) $row->subject;
1304  }
1305  return $data;
1306  }
1307 
1312  public static function lookupSubscribersData(int $a_obj_id): array
1313  {
1314  global $DIC;
1315 
1316  $ilDB = $DIC->database();
1317  $query = 'SELECT * FROM il_subscribers ' .
1318  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
1319  $res = $ilDB->query($query);
1320 
1321  $data = array();
1322  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1323  $data[$row->usr_id]['time'] = (int) $row->sub_time;
1324  $data[$row->usr_id]['usr_id'] = (int) $row->usr_id;
1325  $data[$row->usr_id]['subject'] = (string) $row->subject;
1326  }
1327  return $data;
1328  }
1329 
1338  public static function _getAllSupportContactsOfUser(int $a_usr_id, string $a_type): array
1339  {
1340  global $DIC;
1341 
1342  $ilDB = $DIC['ilDB'];
1343 
1344  // for the first part
1345 
1346  // this will also dismiss local roles!
1347  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
1348  $a2 = "AND obd2.title LIKE 'il_" . $a_type . "_mem%' ";
1349 
1350  // #14290 - no role folder anymore
1351  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
1352  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
1353  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
1354  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
1355  $j2 .
1356  "WHERE obd.type = " . $ilDB->quote($a_type, 'text') . " " .
1357  "AND fa.assign = 'y' " .
1358  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1359  $a2;
1360 
1361  $res = $ilDB->query($query);
1362  $obj_ids = array();
1363  while ($row = $ilDB->fetchObject($res)) {
1364  $obj_ids[] = (int) $row->obj_id;
1365  }
1366 
1367  $set = $ilDB->query("SELECT obj_id, usr_id FROM obj_members " .
1368  " WHERE " . $ilDB->in("obj_id", $obj_ids, false, "integer") .
1369  " AND contact = " . $ilDB->quote(1, "integer"));
1370  $res = array();
1371  while ($rec = $ilDB->fetchAssoc($set)) {
1372  $res[] = $rec;
1373  }
1374  return $res;
1375  }
1376 
1380  public function setRoleOrderPosition(int $a_user_id): string
1381  {
1382  $counter = 0;
1383  $sortable_assignments = '9999999999';
1384  foreach ($this->roles_sorted as $role_id => $trash) {
1385  if (in_array($a_user_id, (array) $this->role_assignments[$role_id])) {
1386  $sortable_assignments = substr_replace($sortable_assignments, '1', $counter, 1);
1387  }
1388  ++$counter;
1389  }
1390  return $sortable_assignments;
1391  }
1392 }
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
checkLastAdmin(array $a_usr_ids)
Check if users for deletion are last admins public.
getCountMembers()
Get number of members (not participants)
updateContact(int $a_usr_id, bool $a_contact)
ilAppEventHandler $eventHandler
$res
Definition: ltiservices.php:69
Global event handler.
updateNotification(int $a_usr_id, bool $a_notification)
Update notification status.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readParticipantsStatus()
Read status of participants (blocked, notification, passed)
updateSubject(int $a_usr_id, string $a_subject)
deleteParticipants(array $a_user_ids)
warning(string $a_message)
isGroupingMember(int $a_usr_id, string $a_field='')
Check membership for.
logStack(?int $a_level=null, string $a_message='')
readSubscriberData(int $a_usr_id)
static lookupShowMembersEnabled(int $a_obj_id)
fetchAssoc(ilDBStatement $statement)
static _isBlocked(int $a_obj_id, int $a_usr_id)
Check if user is blocked.
static getInstance(int $a_ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
isContact(int $a_usr_id)
static _isSubscriber(int $a_obj_id, int $a_usr_id)
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isAdmin(int $a_usr_id)
check if user is admin
quote($value, string $type)
assignSubscriber(int $a_usr_id)
isAssigned(int $a_usr_id)
check if user is assigned
static getDefaultMemberRole(int $a_ref_id)
static _hasPassed(int $a_obj_id, int $a_usr_id)
Check if user has passed course.
getAutoGeneratedRoleId(int $a_role_type)
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRoleOrderPosition(int $a_user_id)
Set role order position.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(string $a_component_name, int $a_ref_id)
addRecommendation(int $a_usr_id)
Add desktop item public.
static _deleteUser(int $a_usr_id)
Delete user data.
getAssignedRoles(int $a_usr_id)
Get assigned roles.
static lookupSubscribersData(int $a_obj_id)
isNotificationEnabled(int $a_usr_id)
getMembers()
Get all members ids (admins and tutors are not members) Use get participants to fetch all...
static lookupShowMembersEnabled(int $a_obj_id)
static _lookupTitle(int $obj_id)
static _getInstanceByObjId(int $a_obj_id)
updateSubscriptionTime(int $a_usr_id, int $a_subtime)
static getInstance(int $a_ref_id)
static _getAllSupportContactsOfUser(int $a_usr_id, string $a_type)
Get all support contacts for a user.
getCountParticipants()
Get number of participants.
isMember(int $a_usr_id)
is user member
getSubscribers()
get all subscribers int[]
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
getParticipants()
Get all participants ids.
deleteSubscriber(int $a_usr_id)
fetchObject(ilDBStatement $query_result)
updateBlocked(int $a_usr_id, bool $a_blocked)
Update blocked status.
query(string $query)
Run a (read-only) Query on the database.
static _deleteUser(int $a_usr_id)
$query
static deleteUserEntry(int $a_usr_id, int $a_obj_id)
deleteSubscribers(array $a_usr_ids)
static hasParticipantListAccess(int $a_obj_id, int $a_usr_id=null)
Check if (current) user has access to the participant list.
getRoles()
Get object roles.
getSubscriberData(int $a_usr_id)
ilObjectDataCache $objectDataCache
assignSubscribers(array $a_usr_ids)
static _deleteAllEntries(int $a_obj_id)
Delete all entries Normally called in case of object deletion.
ilErrorHandling $error
isSubscriber(int $a_usr_id)
in(string $field, array $values, bool $negate=false, string $type="")
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for course and group participants.
updateRoleAssignments($a_usr_id, $a_roles)
Update role assignments public.
Error Handling & global info handling uses PEAR error class.
static lookupNumberOfMembers(int $a_ref_id)
Lookup number of members.
add(int $a_usr_id, int $a_role)
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
ilRecommendedContentManager $recommended_content_manager
const MAIL_ALLOWED_ALL
getAdmins()
Get all admins ids.
getComponent()
Get component name Used for raising events.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getInstanceByObjId(int $a_obj_id)
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getContacts()
get user ids which are confirgured as contact
static getUserMembershipAssignmentsByType(array $a_user_ids, array $a_type, bool $a_only_member_roles)
Get user membership assignments by type.
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
Class ilObjGroup.
static lookupNumberOfParticipants(int $a_ref_id)
Lookup the number of participants (crs admins, tutors, members, grp admins, members) ...
isLastAdmin(int $a_usr_id)
Check if user is last admin.
Class ilRbacAdmin Core functions for role based access control.
isBlocked(int $a_usr_id)
Check if user is blocked.
addSubscriber(int $a_usr_id)
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
isTutor(int $a_usr_id)
is user tutor
manipulate(string $query)
Run a (write) Query on the database.
static _lookupType(int $id, bool $reference=false)
static lookupSubscribers(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
hasPassed(int $a_usr_id)
Check if user has passed object.
getTutors()
Get all tutors ids.
ilRbacReview $rbacReview
concat(array $values, bool $allow_null=true)