ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSessionParticipants.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
31 {
32  public const COMPONENT_NAME = 'Modules/Session';
33 
34  protected static array $instances = [];
35 
37 
38  public function __construct(int $a_ref_id)
39  {
40  $this->event_part = new ilEventParticipants(ilObject::_lookupObjId($a_ref_id));
41  parent::__construct(self::COMPONENT_NAME, $a_ref_id);
42  }
43 
44  public static function _getInstanceByObjId(int $a_obj_id): ilSessionParticipants
45  {
46  $refs = ilObject::_getAllReferences($a_obj_id);
47  return self::getInstance(array_pop($refs));
48  }
49 
50  public static function getInstance(int $a_ref_id): ilSessionParticipants
51  {
52  if (isset(self::$instances[$a_ref_id]) && self::$instances[$a_ref_id] instanceof self) {
53  return self::$instances[$a_ref_id];
54  }
55  return self::$instances[$a_ref_id] = new self($a_ref_id);
56  }
57 
59  {
60  return $this->event_part;
61  }
62 
67  public function checkLastAdmin(array $a_usr_ids): bool
68  {
69  return false;
70  }
71 
72  public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
73  {
74  $obj_id = ilObject::_lookupObjId($a_ref_id);
76  }
77 
78  protected function readParticipantsStatus(): void
79  {
80  $this->participants_status = [];
81  foreach ($this->getEventParticipants()->getParticipants() as $mem_uid => $info) {
82  $this->participants_status[$mem_uid]['blocked'] = false;
83  $this->participants_status[$mem_uid]['notification_enabled'] = (bool) $info['notification_enabled'];
84  $this->participants_status[$mem_uid]['passed'] = false;
85  $this->participants_status[$mem_uid]['contact'] = (bool) $info['contact'];
86  }
87  }
88 
92  public function add(int $a_usr_id, int $a_role = 0): bool
93  {
94  if (parent::add($a_usr_id, $a_role)) {
95  return true;
96  }
97  return false;
98  }
99 
100  public function register(int $a_usr_id): bool
101  {
102  $this->logger->debug('Registering user: ' . $a_usr_id . ' for session: ' . $this->getObjId());
103  $this->add($a_usr_id, ilParticipants::IL_SESS_MEMBER);
104  // in any (already participant since status attended) case register user.
105  $this->getEventParticipants()->register($a_usr_id);
106  return true;
107  }
108 
109  public function unregister(int $a_usr_id): bool
110  {
111  // participated users are not dropped from role
112  if (!$this->getEventParticipants()->hasParticipated($a_usr_id)) {
113  $this->delete($a_usr_id);
114  }
115  $this->getEventParticipants()->unregister($a_usr_id);
116  return true;
117  }
118 
119  public function sendNotification(int $a_type, int $a_usr_id, bool $a_force_email = false): void
120  {
122 
123  switch ($a_type) {
126  $mail->setRefId($this->ref_id);
127  $mail->setRecipients([$a_usr_id]);
128  $mail->send();
129  break;
130 
131  default:
132  $this->logger->warning('Invalid notfication type given: ' . $a_type);
133  $this->logger->logStack(ilLogLevel::WARNING);
134  break;
135  }
136  }
137 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
static _isParticipant(int $a_ref_id, int $a_usr_id)
sendNotification(int $a_type, int $a_usr_id, bool $a_force_email=false)
static _lookupObjId(int $ref_id)
checkLastAdmin(array $a_usr_ids)
no last admin restrictions for sessions
static _isRegistered(int $a_usr_id, int $a_event_id)
static getInstance(int $a_ref_id)
getParticipants()
Get all participants ids.
add(int $a_usr_id, int $a_role=0)
Add user to session member role.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for course and group participants.
__construct(Container $dic, ilPlugin $plugin)
static _getInstanceByObjId(int $a_obj_id)