ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
198  public static function canSendMailToMembers(
199  int|ilObject $ref_id_or_instance,
200  ?int $usr_id = null,
201  ?int $mail_obj_ref_id = null
202  ): bool {
203  global $DIC;
204 
205  $access = $DIC->access();
206  $rbacsystem = $DIC->rbac()->system();
207 
208  if (is_null($usr_id)) {
209  $usr_id = $DIC->user()->getId();
210  }
211  if (is_null($mail_obj_ref_id)) {
212  $mail_obj_ref_id = (new ilMail($usr_id))->getMailObjectReferenceId();
213  }
214  if (is_int($ref_id_or_instance)) {
215  $ref_id = $ref_id_or_instance;
216  } elseif ($ref_id_or_instance instanceof ilObject) {
217  $ref_id = (int) $ref_id_or_instance->getRefId();
218  if ($ref_id === 0) {
219  $ref_id = array_keys(ilObject::_getAllReferences($ref_id_or_instance->getId()))[0];
220  }
221  } else {
222  return false;
223  }
224 
225  if (
226  $access->checkAccess('manage_members', '', $ref_id) &&
227  $rbacsystem->checkAccess('internal_mail', $mail_obj_ref_id)
228  ) {
229  return true;
230  }
231 
232  $part = self::getInstance($ref_id);
233  if (!$part->isAssigned($usr_id)) {
234  return false;
235  }
236 
237  $object = $ref_id_or_instance;
238  if (is_int($ref_id_or_instance)) {
239  $object = ilObjectFactory::getInstanceByRefId($ref_id_or_instance);
240  }
241 
242  if ($object instanceof ilObjCourse) {
243  return $object->getMailToMembersType() == ilCourseConstants::MAIL_ALLOWED_ALL;
244  } elseif ($object instanceof ilObjGroup) {
245  return $object->getMailToMembersType() == ilObjGroup::MAIL_ALLOWED_ALL;
246  } elseif ($object instanceof ilObjSession) {
247  return $object->getMailToMembersType() == ilObjSession::MAIL_ALLOWED_ALL;
248  }
249 
250  return false;
251  }
252 
253 
257  public static function getUserMembershipAssignmentsByType(
258  array $a_user_ids,
259  array $a_type,
260  bool $a_only_member_roles
261  ): array {
262  global $DIC;
263 
264  $ilDB = $DIC->database();
265 
266  $j2 = $a2 = '';
267  if ($a_only_member_roles) {
268  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
269  $a2 = 'AND obd2.title = ' . $ilDB->concat(
270  array(
271  array($ilDB->quote('il_', 'text')),
272  array('obd.type'),
273  array($ilDB->quote('_member_', 'text')),
274  array('obr.ref_id'),
275  ),
276  false
277  );
278  }
279 
280  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id,ua.usr_id FROM rbac_ua ua " .
281  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
282  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
283  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
284  $j2 .
285  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") .
286  "AND fa.assign = 'y' " .
287  'AND ' . $ilDB->in('ua.usr_id', $a_user_ids, false, 'integer') . ' ' .
288  $a2;
289 
290  $obj_ids = [];
291  $res = $ilDB->query($query);
292  while ($row = $ilDB->fetchObject($res)) {
293  $obj_ids[(int) $row->obj_id][] = (int) $row->usr_id;
294  }
295  return $obj_ids;
296  }
297 
305  public static function _getMembershipByType(
306  int $a_usr_id,
307  array $a_type,
308  bool $a_only_member_role = false
309  ): array {
310  global $DIC;
311 
312  $ilDB = $DIC['ilDB'];
313 
314  $j2 = '';
315  $a2 = '';
316  // this will also dismiss local roles!
317  if ($a_only_member_role) {
318  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
319  $a2 = 'AND obd2.title = ' . $ilDB->concat(
320  array(
321  array($ilDB->quote('il_', 'text')),
322  array('obd.type'),
323  array($ilDB->quote('_member_', 'text')),
324  array('obr.ref_id'),
325  ),
326  false
327  );
328  }
329 
330  // #14290 - no role folder anymore
331  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
332  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
333  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
334  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
335  $j2 .
336  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") . ' ' .
337  "AND fa.assign = 'y' " .
338  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
339  'AND obr.deleted IS NULL ' .
340  $a2;
341  $res = $ilDB->query($query);
342  $ref_ids = [];
343  while ($row = $ilDB->fetchObject($res)) {
344  $ref_ids[] = (int) $row->obj_id;
345  }
346  return $ref_ids;
347  }
348 
352  public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
353  {
354  global $DIC;
355 
356  $rbacreview = $DIC->rbac()->review();
357  $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
358  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
359  }
360 
364  public static function lookupNumberOfParticipants(int $a_ref_id): int
365  {
366  global $DIC;
367 
368  $rbacreview = $DIC->rbac()->review();
369  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
370  return $rbacreview->getNumberOfAssignedUsers($lroles);
371  }
372 
376  public static function lookupNumberOfMembers(int $a_ref_id): int
377  {
378  global $DIC;
379 
380  $rbacreview = $DIC->rbac()->review();
381  $ilObjDataCache = $DIC['ilObjDataCache'];
382  $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
383  if (!$has_policies) {
384  return 0;
385  }
386  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
387  $memberRoles = array();
388  foreach ($lroles as $role_id) {
389  $title = $ilObjDataCache->lookupTitle($role_id);
390  switch (substr($title, 0, 8)) {
391  case 'il_crs_a':
392  case 'il_crs_t':
393  case 'il_grp_a':
394  case 'il_sess_':
395  break;
396 
397  default:
398  $memberRoles[] = $role_id;
399  break;
400  }
401  }
402  return $rbacreview->getNumberOfAssignedUsers($memberRoles);
403  }
404 
408  public static function _isBlocked(int $a_obj_id, int $a_usr_id): bool
409  {
410  global $DIC;
411 
412  $ilDB = $DIC->database();
413  $query = "SELECT * FROM obj_members " .
414  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
415  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
416  "AND blocked = " . $ilDB->quote(1, 'integer');
417  $res = $ilDB->query($query);
418  return (bool) $res->numRows();
419  }
420 
424  public static function _hasPassed(int $a_obj_id, int $a_usr_id): bool
425  {
426  global $DIC;
427 
428  $ilDB = $DIC->database();
429  $query = "SELECT * FROM obj_members " .
430  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
431  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
432  "AND passed = '1'";
433  $res = $ilDB->query($query);
434  return (bool) $res->numRows();
435  }
436 
441  public static function _deleteAllEntries(int $a_obj_id): void
442  {
443  global $DIC;
444 
445  $ilDB = $DIC->database();
446  $query = "DELETE FROM obj_members " .
447  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
448  $res = $ilDB->manipulate($query);
449 
450  $query = "DELETE FROM il_subscribers " .
451  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
452  $res = $ilDB->manipulate($query);
453 
454  $query = 'DELETE FROM crs_waiting_list ' .
455  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
456  $ilDB->manipulate($query);
457  }
458 
462  public static function _deleteUser(int $a_usr_id): void
463  {
464  global $DIC;
465 
466  $ilDB = $DIC->database();
467  $query = "DELETE FROM obj_members WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
468  $res = $ilDB->manipulate($query);
469 
470  $query = "DELETE FROM il_subscribers WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
471  $res = $ilDB->manipulate($query);
472 
474  }
475 
476  public static function getDefaultMemberRole(int $a_ref_id): int
477  {
478  global $DIC;
479 
480  $rbacreview = $DIC->rbac()->review();
481 
482  $obj_id = ilObject::_lookupObjId($a_ref_id);
483  $type = ilObject::_lookupType($obj_id);
484 
485  if (!in_array($type, array('crs', 'grp'))) {
486  return 0;
487  }
488 
489  $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
490  foreach ($roles as $role) {
491  $title = ilObject::_lookupTitle($role);
492  if (strpos($title, ('il_' . $type . '_member')) === 0) {
493  return $role;
494  }
495  }
496  return 0;
497  }
498 
499  public function getObjId(): int
500  {
501  return $this->obj_id;
502  }
503 
504  public function getType(): string
505  {
506  return $this->type;
507  }
508 
513  public function getNotificationRecipients(): array
514  {
515  $query = "SELECT * FROM obj_members " .
516  "WHERE notification = 1 " .
517  "AND obj_id = " . $this->ilDB->quote($this->obj_id, ilDBConstants::T_INTEGER) . " ";
518  $res = $this->ilDB->query($query);
519  $recp = [];
520  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
521  if ($this->isAdmin((int) $row->usr_id) || $this->isTutor((int) $row->usr_id)) {
522  $recp[] = (int) $row->usr_id;
523  }
524  }
525  return $recp;
526  }
527 
531  public function getCountMembers(): int
532  {
533  return count($this->members);
534  }
535 
539  public function getCountParticipants(): int
540  {
541  return count($this->participants);
542  }
543 
548  public function getParticipants(): array
549  {
550  return $this->participants;
551  }
552 
558  public function getMembers(): array
559  {
560  return $this->members;
561  }
562 
567  public function getAdmins(): array
568  {
569  return $this->admins;
570  }
571 
572  public function getCountAdmins(): int
573  {
574  return count($this->getAdmins());
575  }
576 
581  public function getTutors(): array
582  {
583  return $this->tutors;
584  }
585 
589  public function isAdmin(int $a_usr_id): bool
590  {
591  return in_array($a_usr_id, $this->admins);
592  }
593 
597  public function isTutor(int $a_usr_id): bool
598  {
599  return in_array($a_usr_id, $this->tutors);
600  }
601 
605  public function isMember(int $a_usr_id): bool
606  {
607  return in_array($a_usr_id, $this->members);
608  }
609 
613  public function isAssigned(int $a_usr_id): bool
614  {
615  return in_array($a_usr_id, $this->participants);
616  }
617 
621  public function isLastAdmin(int $a_usr_id): bool
622  {
623  return in_array($a_usr_id, $this->getAdmins()) && count($this->getAdmins()) === 1;
624  }
625 
629  public function getRoles(): array
630  {
631  return $this->roles;
632  }
633 
637  public function getAssignedRoles(int $a_usr_id): array
638  {
639  $assigned = [];
640  foreach ($this->roles as $role) {
641  if ($this->rbacReview->isAssigned($a_usr_id, $role)) {
642  $assigned[] = $role;
643  }
644  }
645  return $assigned;
646  }
647 
654  public function updateRoleAssignments($a_usr_id, $a_roles): void
655  {
656  foreach ($this->getRoles() as $role_id) {
657  if ($this->rbacReview->isAssigned($a_usr_id, $role_id)) {
658  if (!in_array($role_id, $a_roles)) {
659  $this->rbacAdmin->deassignUser($role_id, $a_usr_id);
660  }
661  } elseif (in_array($role_id, $a_roles)) {
662  $this->rbacAdmin->assignUser($role_id, $a_usr_id);
663  }
664  }
665  $this->rbacReview->clearCaches();
666  $this->readParticipants();
667  $this->readParticipantsStatus();
668  }
669 
676  public function checkLastAdmin(array $a_usr_ids): bool
677  {
678  foreach ($this->getAdmins() as $admin_id) {
679  if (!in_array($admin_id, $a_usr_ids)) {
680  return true;
681  }
682  }
683  return false;
684  }
685 
689  public function isBlocked(int $a_usr_id): bool
690  {
691  if (isset($this->participants_status[$a_usr_id])) {
692  return (bool) $this->participants_status[$a_usr_id]['blocked'];
693  }
694  return false;
695  }
696 
700  public function hasPassed(int $a_usr_id): bool
701  {
702  if (isset($this->participants_status[$a_usr_id])) {
703  return (bool) $this->participants_status[$a_usr_id]['passed'];
704  }
705  return false;
706  }
707 
711  public function delete(int $a_usr_id): void
712  {
713  $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->ref_id);
714  foreach ($this->roles as $role_id) {
715  $this->rbacAdmin->deassignUser($role_id, $a_usr_id);
716  }
717 
718  $query = "DELETE FROM obj_members " .
719  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
720  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
721  $res = $this->ilDB->manipulate($query);
722 
723  $this->readParticipants();
724  $this->readParticipantsStatus();
725 
726  $this->eventHandler->raise(
727  $this->getComponent(),
728  "deleteParticipant",
729  [
730  'obj_id' => $this->obj_id,
731  'usr_id' => $a_usr_id
732  ]
733  );
734  }
735 
739  public function updateBlocked(int $a_usr_id, bool $a_blocked): void
740  {
741  $this->participants_status[$a_usr_id]['blocked'] = (int) $a_blocked;
742  $query = "SELECT * FROM obj_members " .
743  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
744  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
745  $res = $this->ilDB->query($query);
746  if ($res->numRows()) {
747  $query = "UPDATE obj_members SET " .
748  "blocked = " . $this->ilDB->quote((int) $a_blocked, 'integer') . " " .
749  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
750  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
751  } else {
752  $query = "INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) " .
753  "VALUES ( " .
754  $this->ilDB->quote((int) $a_blocked, 'integer') . ", " .
755  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
756  $this->ilDB->quote($a_usr_id, 'integer') . ", " .
757  $this->ilDB->quote(0, 'integer') . ", " .
758  $this->ilDB->quote(0, 'integer') .
759  ") ON DUPLICATE KEY UPDATE blocked = VALUES(blocked)";
760  }
761  $res = $this->ilDB->manipulate($query);
762  }
763 
764  public function updateContact(int $a_usr_id, bool $a_contact): void
765  {
766  $this->ilDB->manipulate(
767  'UPDATE obj_members SET ' .
768  'contact = ' . $this->ilDB->quote($a_contact, 'integer') . ' ' .
769  'WHERE obj_id = ' . $this->ilDB->quote($this->obj_id, 'integer') . ' ' .
770  'AND usr_id = ' . $this->ilDB->quote($a_usr_id, 'integer')
771  );
772  $this->participants_status[$a_usr_id]['contact'] = $a_contact;
773  }
774 
779  public function getContacts(): array
780  {
781  $contacts = array();
782  foreach ($this->participants_status as $usr_id => $status) {
783  if ($status['contact']) {
784  $contacts[] = (int) $usr_id;
785  }
786  }
787  return $contacts;
788  }
789 
793  public function updateNotification(int $a_usr_id, bool $a_notification): void
794  {
795  $this->participants_status[$a_usr_id]['notification'] = $a_notification;
796 
797  $query = "SELECT * FROM obj_members " .
798  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
799  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
800  $res = $this->ilDB->query($query);
801  if ($res->numRows()) {
802  $query = "UPDATE obj_members SET " .
803  "notification = " . $this->ilDB->quote((int) $a_notification, 'integer') . " " .
804  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
805  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
806  } else {
807  $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
808  "VALUES ( " .
809  $this->ilDB->quote((int) $a_notification, 'integer') . ", " .
810  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
811  $this->ilDB->quote($a_usr_id, 'integer') . ", " .
812  $this->ilDB->quote(0, 'integer') . ", " .
813  $this->ilDB->quote(0, 'integer') .
814  ") ON DUPLICATE KEY UPDATE notification = VALUES(notification)";
815  }
816  $res = $this->ilDB->manipulate($query);
817  }
818 
819  public function add(int $a_usr_id, int $a_role): bool
820  {
821  if ($this->isAssigned($a_usr_id)) {
822  return false;
823  }
824 
825  switch ($a_role) {
826  case self::IL_LSO_ADMIN:
827  case self::IL_GRP_ADMIN:
828  case self::IL_CRS_ADMIN:
829  $this->admins[] = $a_usr_id;
830  break;
831 
832  case self::IL_CRS_TUTOR:
833  $this->tutors[] = $a_usr_id;
834  break;
835 
836  case self::IL_SESS_MEMBER:
837  case self::IL_LSO_MEMBER:
838  case self::IL_GRP_MEMBER:
839  case self::IL_CRS_MEMBER:
840  $this->members[] = $a_usr_id;
841  break;
842  }
843 
844  $this->participants[] = $a_usr_id;
845  $this->rbacAdmin->assignUser($this->role_data[$a_role], $a_usr_id);
846 
847  // Delete subscription request
848  $this->deleteSubscriber($a_usr_id);
849 
850  ilWaitingList::deleteUserEntry($a_usr_id, $this->obj_id);
851 
852  $this->eventHandler->raise(
853  $this->getComponent(),
854  "addParticipant",
855  array(
856  'obj_id' => $this->obj_id,
857  'usr_id' => $a_usr_id,
858  'role_id' => $a_role
859  )
860  );
861  return true;
862  }
863 
867  public function deleteParticipants(array $a_user_ids): bool
868  {
869  foreach ($a_user_ids as $user_id) {
870  $this->delete($user_id);
871  }
872  return true;
873  }
874 
879  public function addRecommendation(int $a_usr_id): void
880  {
881  // deactivated for now, see discussion at
882  // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
883  // $this->recommended_content_manager->addObjectRecommendation($a_usr_id, $this->ref_id);
884  }
885 
886  public function isNotificationEnabled(int $a_usr_id): bool
887  {
888  if (isset($this->participants_status[$a_usr_id])) {
889  return (bool) $this->participants_status[$a_usr_id]['notification'];
890  }
891  return false;
892  }
893 
894  public function isContact(int $a_usr_id): bool
895  {
896  if (isset($this->participants_status[$a_usr_id])) {
897  return (bool) $this->participants_status[$a_usr_id]['contact'];
898  }
899  return false;
900  }
901 
902  public function getAutoGeneratedRoleId(int $a_role_type): int
903  {
904  if (array_key_exists($a_role_type, $this->role_data)) {
905  return $this->role_data[$a_role_type];
906  }
907  return 0;
908  }
909 
910  protected function readParticipants(): void
911  {
912  $this->roles = $this->rbacReview->getRolesOfRoleFolder($this->ref_id, false);
913  $this->participants = [];
914  $this->members = $this->admins = $this->tutors = [];
915 
916  $additional_roles = [];
917  $auto_generated_roles = [];
918  foreach ($this->roles as $role_id) {
919  $title = $this->objectDataCache->lookupTitle($role_id);
920  switch (substr($title, 0, 8)) {
921  case 'il_crs_m':
922  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
923  $this->role_data[self::IL_CRS_MEMBER] = $role_id;
924  $this->participants = array_unique(array_merge(
925  $assigned = $this->rbacReview->assignedUsers($role_id),
927  ));
928  $this->members = array_unique(array_merge($assigned, $this->members));
929  $this->role_assignments[$role_id] = $assigned;
930  break;
931 
932  case 'il_crs_a':
933  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
934  $this->role_data[self::IL_CRS_ADMIN] = $role_id;
935  $this->participants = array_unique(array_merge(
936  $assigned = $this->rbacReview->assignedUsers($role_id),
938  ));
939  $this->admins = $this->rbacReview->assignedUsers($role_id);
940  $this->role_assignments[$role_id] = $assigned;
941  break;
942 
943  case 'il_crs_t':
944  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_TUTOR;
945  $this->role_data[self::IL_CRS_TUTOR] = $role_id;
946  $this->participants = array_unique(array_merge(
947  $assigned = $this->rbacReview->assignedUsers($role_id),
949  ));
950  $this->tutors = $this->rbacReview->assignedUsers($role_id);
951  $this->role_assignments[$role_id] = $assigned;
952  break;
953 
954  case 'il_grp_a':
955  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
956  $this->role_data[self::IL_GRP_ADMIN] = $role_id;
957  $this->participants = array_unique(array_merge(
958  $assigned = $this->rbacReview->assignedUsers($role_id),
960  ));
961  $this->admins = $this->rbacReview->assignedUsers($role_id);
962  $this->role_assignments[$role_id] = $assigned;
963  break;
964 
965  case 'il_grp_m':
966  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
967  $this->role_data[self::IL_GRP_MEMBER] = $role_id;
968  $this->participants = array_unique(array_merge(
969  $assigned = $this->rbacReview->assignedUsers($role_id),
971  ));
972  $this->members = $this->rbacReview->assignedUsers($role_id);
973  $this->role_assignments[$role_id] = $assigned;
974  break;
975 
976  case 'il_sess_':
977  $this->role_data[self::IL_SESS_MEMBER] = $role_id;
978  $this->participants = array_unique(array_merge(
979  $assigned = $this->rbacReview->assignedUsers($role_id),
981  ));
982  $this->members = $this->rbacReview->assignedUsers($role_id);
983  break;
984 
985  case 'il_lso_m':
986  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_MEMBER;
987  $this->role_data[self::IL_LSO_MEMBER] = $role_id;
988  $this->participants = array_unique(array_merge(
989  $assigned = $this->rbacReview->assignedUsers($role_id),
991  ));
992  $this->members = $this->rbacReview->assignedUsers($role_id);
993  $this->role_assignments[$role_id] = $assigned;
994  break;
995 
996  case 'il_lso_a':
997  $auto_generated_roles[$role_id] = self::IL_ROLE_POSITION_ADMIN;
998  $this->role_data[self::IL_LSO_ADMIN] = $role_id;
999  $this->participants = array_unique(array_merge(
1000  $assigned = $this->rbacReview->assignedUsers($role_id),
1002  ));
1003  $this->admins = $this->rbacReview->assignedUsers($role_id);
1004  $this->role_assignments[$role_id] = $assigned;
1005  break;
1006 
1007  default:
1008  $additional_roles[$role_id] = $title;
1009  $this->participants = array_unique(array_merge(
1010  $assigned = $this->rbacReview->assignedUsers($role_id),
1012  ));
1013  $this->members = array_unique(array_merge($assigned, $this->members));
1014  $this->role_assignments[$role_id] = $assigned;
1015  break;
1016  }
1017  }
1018  asort($auto_generated_roles);
1019  asort($additional_roles);
1020  $this->roles_sorted = $auto_generated_roles + $additional_roles;
1021  }
1022 
1026  protected function readParticipantsStatus(): void
1027  {
1028  $query = "SELECT * FROM obj_members " .
1029  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1030  $res = $this->ilDB->query($query);
1031  $this->participants_status = [];
1032  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1033  $this->participants_status[(int) $row->usr_id]['blocked'] = (bool) $row->blocked;
1034  $this->participants_status[(int) $row->usr_id]['notification'] = (bool) $row->notification;
1035  $this->participants_status[(int) $row->usr_id]['passed'] = (bool) $row->passed;
1036  $this->participants_status[(int) $row->usr_id]['contact'] = (bool) $row->contact;
1037  }
1038  }
1039 
1043  public function isGroupingMember(int $a_usr_id, string $a_field = ''): bool
1044  {
1045  if ($a_field === '') {
1046  return false;
1047  }
1048  // Used for membership limitations -> check membership by given field
1049  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
1050  if (!$tmp_user instanceof ilObjUser) {
1051  $this->logger->logStack(ilLogLevel::ERROR);
1052  throw new DomainException('Invalid user id given: ' . $a_usr_id);
1053  }
1054  switch ($a_field) {
1055  case 'login':
1056  $and = "AND login = " . $this->ilDB->quote($tmp_user->getLogin(), 'text') . " ";
1057  break;
1058  case 'email':
1059  $and = "AND email = " . $this->ilDB->quote($tmp_user->getEmail(), 'text') . " ";
1060  break;
1061  case 'matriculation':
1062  $and = "AND matriculation = " . $this->ilDB->quote($tmp_user->getMatriculation(), 'text') . " ";
1063  break;
1064 
1065  default:
1066  $and = "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " ";
1067  break;
1068  }
1069 
1070  if (!$this->getParticipants()) {
1071  return false;
1072  }
1073 
1074  $query = "SELECT * FROM usr_data ud " .
1075  "WHERE " . $this->ilDB->in('usr_id', $this->getParticipants(), false, 'integer') . " " .
1076  $and;
1077 
1078  $res = $this->ilDB->query($query);
1079  return (bool) $res->numRows();
1080  }
1081 
1085  public static function lookupSubscribers(int $a_obj_id): array
1086  {
1087  global $DIC;
1088 
1089  $ilDB = $DIC['ilDB'];
1090  $subscribers = array();
1091  $query = "SELECT usr_id FROM il_subscribers " .
1092  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
1093  "ORDER BY sub_time ";
1094 
1095  $res = $ilDB->query($query);
1096  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1097  $subscribers[] = (int) $row->usr_id;
1098  }
1099  return $subscribers;
1100  }
1101 
1106  public function getSubscribers(): array
1107  {
1108  $this->readSubscribers();
1109  return $this->subscribers;
1110  }
1111 
1112  public function getCountSubscribers(): int
1113  {
1114  return count($this->getSubscribers());
1115  }
1116 
1117  public function getSubscriberData(int $a_usr_id): array
1118  {
1119  return $this->readSubscriberData($a_usr_id);
1120  }
1121 
1122  public function assignSubscribers(array $a_usr_ids): bool
1123  {
1124  if (!is_array($a_usr_ids) || !count($a_usr_ids)) {
1125  return false;
1126  }
1127  foreach ($a_usr_ids as $id) {
1128  if (!$this->assignSubscriber($id)) {
1129  return false;
1130  }
1131  }
1132  return true;
1133  }
1134 
1135  public function assignSubscriber(int $a_usr_id): bool
1136  {
1137  $this->error->setMessage("");
1138  if (!$this->isSubscriber($a_usr_id)) {
1139  $this->error->appendMessage($this->lng->txt("crs_user_notsubscribed"));
1140 
1141  return false;
1142  }
1143  if ($this->isAssigned($a_usr_id)) {
1144  $tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id);
1145  $this->error->appendMessage($tmp_obj->getLogin() . ": " . $this->lng->txt("crs_user_already_assigned"));
1146 
1147  return false;
1148  }
1149 
1150  if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id, false)) {
1151  $this->error->appendMessage($this->lng->txt("crs_user_not_exists"));
1152  return false;
1153  }
1154 
1155  if ($this instanceof ilCourseParticipants) {
1156  $this->add($tmp_obj->getId(), self::IL_CRS_MEMBER);
1157  }
1158  if ($this instanceof ilGroupParticipants) {
1159  $this->add($tmp_obj->getId(), self::IL_GRP_MEMBER);
1160  }
1161  if ($this instanceof ilLearningSequenceParticipants) {
1162  $this->add($tmp_obj->getId(), self::IL_LSO_MEMBER);
1163  }
1164  if ($this instanceof ilSessionParticipants) {
1165  $this->register($tmp_obj->getId());
1166  }
1167  $this->deleteSubscriber($a_usr_id);
1168  return true;
1169  }
1170 
1174  public function autoFillSubscribers(): int
1175  {
1176  $this->readSubscribers();
1177  $counter = 0;
1178  foreach ($this->subscribers as $subscriber) {
1179  if (!$this->assignSubscriber($subscriber)) {
1180  continue;
1181  }
1182  ++$counter;
1183  }
1184  return $counter;
1185  }
1186 
1187  public function addSubscriber(int $a_usr_id): void
1188  {
1189  $query = "INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) " .
1190  " VALUES (" .
1191  $this->ilDB->quote($a_usr_id, 'integer') . "," .
1192  $this->ilDB->quote($this->obj_id, 'integer') . ", " .
1193  $this->ilDB->quote('', 'text') . ", " .
1194  $this->ilDB->quote(time(), 'integer') .
1195  ")";
1196  $res = $this->ilDB->manipulate($query);
1197  }
1198 
1199  public function updateSubscriptionTime(int $a_usr_id, int $a_subtime): void
1200  {
1201  $query = "UPDATE il_subscribers " .
1202  "SET sub_time = " . $this->ilDB->quote($a_subtime, 'integer') . " " .
1203  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1204  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1205  $res = $this->ilDB->manipulate($query);
1206  }
1207 
1208  public function updateSubject(int $a_usr_id, string $a_subject): void
1209  {
1210  $query = "UPDATE il_subscribers " .
1211  "SET subject = " . $this->ilDB->quote($a_subject, 'text') . " " .
1212  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1213  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1214  $res = $this->ilDB->manipulate($query);
1215  }
1216 
1217  public function deleteSubscriber(int $a_usr_id): void
1218  {
1219  $query = "DELETE FROM il_subscribers " .
1220  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1221  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " ";
1222  $res = $this->ilDB->manipulate($query);
1223  }
1224 
1225  public function deleteSubscribers(array $a_usr_ids): bool
1226  {
1227  if (!count($a_usr_ids)) {
1228  $this->error->setMessage('');
1229  $this->error->appendMessage($this->lng->txt("no_usr_ids_given"));
1230  return false;
1231  }
1232  $query = "DELETE FROM il_subscribers " .
1233  "WHERE " . $this->ilDB->in('usr_id', $a_usr_ids, false, 'integer') . " " .
1234  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
1235  $res = $this->ilDB->query($query);
1236  return true;
1237  }
1238 
1239  public function isSubscriber(int $a_usr_id): bool
1240  {
1241  $query = "SELECT * FROM il_subscribers " .
1242  "WHERE usr_id = " . $this->ilDB->quote($a_usr_id, 'integer') . " " .
1243  "AND obj_id = " . $this->ilDB->quote($this->obj_id, 'integer');
1244 
1245  $res = $this->ilDB->query($query);
1246  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1247  return true;
1248  }
1249  return false;
1250  }
1251 
1252  public static function _isSubscriber(int $a_obj_id, int $a_usr_id): bool
1253  {
1254  global $DIC;
1255 
1256  $ilDB = $DIC->database();
1257  $query = "SELECT * FROM il_subscribers " .
1258  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1259  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
1260 
1261  $res = $ilDB->query($query);
1262  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1263  return true;
1264  }
1265  return false;
1266  }
1267 
1271  protected function readSubscribers(): void
1272  {
1273  $this->subscribers = [];
1274  $query = "SELECT usr_id FROM il_subscribers " .
1275  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
1276  "ORDER BY sub_time ";
1277 
1278  $res = $this->ilDB->query($query);
1279  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1280  if (!ilObjectFactory::getInstanceByObjId((int) $row->usr_id, false)) {
1281  $this->deleteSubscriber((int) $row->usr_id);
1282  }
1283  $this->subscribers[] = (int) $row->usr_id;
1284  }
1285  }
1286 
1290  protected function readSubscriberData(int $a_usr_id): array
1291  {
1292  $query = "SELECT * FROM il_subscribers " .
1293  "WHERE obj_id = " . $this->ilDB->quote($this->obj_id, 'integer') . " " .
1294  "AND usr_id = " . $this->ilDB->quote($a_usr_id, 'integer');
1295 
1296  $res = $this->ilDB->query($query);
1297  $data = [];
1298  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1299  $data["time"] = (int) $row->sub_time;
1300  $data["usr_id"] = (int) $row->usr_id;
1301  $data['subject'] = (string) $row->subject;
1302  }
1303  return $data;
1304  }
1305 
1310  public static function lookupSubscribersData(int $a_obj_id): array
1311  {
1312  global $DIC;
1313 
1314  $ilDB = $DIC->database();
1315  $query = 'SELECT * FROM il_subscribers ' .
1316  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
1317  $res = $ilDB->query($query);
1318 
1319  $data = array();
1320  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1321  $data[$row->usr_id]['time'] = (int) $row->sub_time;
1322  $data[$row->usr_id]['usr_id'] = (int) $row->usr_id;
1323  $data[$row->usr_id]['subject'] = (string) $row->subject;
1324  }
1325  return $data;
1326  }
1327 
1336  public static function _getAllSupportContactsOfUser(int $a_usr_id, string $a_type): array
1337  {
1338  global $DIC;
1339 
1340  $ilDB = $DIC['ilDB'];
1341 
1342  // for the first part
1343 
1344  // this will also dismiss local roles!
1345  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
1346  $a2 = "AND obd2.title LIKE 'il_" . $a_type . "_mem%' ";
1347 
1348  // #14290 - no role folder anymore
1349  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
1350  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
1351  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
1352  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
1353  $j2 .
1354  "WHERE obd.type = " . $ilDB->quote($a_type, 'text') . " " .
1355  "AND fa.assign = 'y' " .
1356  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1357  $a2;
1358 
1359  $res = $ilDB->query($query);
1360  $obj_ids = array();
1361  while ($row = $ilDB->fetchObject($res)) {
1362  $obj_ids[] = (int) $row->obj_id;
1363  }
1364 
1365  $set = $ilDB->query("SELECT obj_id, usr_id FROM obj_members " .
1366  " WHERE " . $ilDB->in("obj_id", $obj_ids, false, "integer") .
1367  " AND contact = " . $ilDB->quote(1, "integer"));
1368  $res = array();
1369  while ($rec = $ilDB->fetchAssoc($set)) {
1370  $res[] = $rec;
1371  }
1372  return $res;
1373  }
1374 
1378  public function setRoleOrderPosition(int $a_user_id): string
1379  {
1380  $counter = 0;
1381  $sortable_assignments = '9999999999';
1382  foreach ($this->roles_sorted as $role_id => $trash) {
1383  if (in_array($a_user_id, (array) $this->role_assignments[$role_id])) {
1384  $sortable_assignments = substr_replace($sortable_assignments, '1', $counter, 1);
1385  }
1386  ++$counter;
1387  }
1388  return $sortable_assignments;
1389  }
1390 }
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:66
Global event handler.
updateNotification(int $a_usr_id, bool $a_notification)
Update notification status.
Session participation handling.
readParticipantsStatus()
Read status of participants (blocked, notification, passed)
updateSubject(int $a_usr_id, string $a_subject)
deleteParticipants(array $a_user_ids)
isGroupingMember(int $a_usr_id, string $a_field='')
Check membership for.
readSubscriberData(int $a_usr_id)
logStack(?int $level=null, string $message='', array $context=[])
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.
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.
warning(string $message, array $context=[])
getAutoGeneratedRoleId(int $a_role_type)
static _lookupObjId(int $ref_id)
setRoleOrderPosition(int $a_user_id)
Set role order position.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__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.
global $DIC
Definition: shib_login.php:22
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)
static deleteUserEntry(int $a_usr_id, int $a_obj_id)
static hasParticipantListAccess(int $a_obj_id, ?int $a_usr_id=null)
Check if (current) user has access to the participant list.
deleteSubscribers(array $a_usr_ids)
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.
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.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
ilRecommendedContentManager $recommended_content_manager
const MAIL_ALLOWED_ALL
getAdmins()
Get all admins ids.
getComponent()
Get component name Used for raising events.
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
static canSendMailToMembers(int|ilObject $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.
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)