ILIAS  release_8 Revision v8.24
class.ilGroupParticipants.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
32{
33 protected const COMPONENT_NAME = 'Modules/Group';
34
35 protected static array $instances = [];
36
43 public function __construct(int $a_obj_id)
44 {
45 global $DIC;
46
47 $this->logger = $DIC->logger()->grp();
48
49 // ref based constructor
50 $refs = ilObject::_getAllReferences($a_obj_id);
51 parent::__construct(self::COMPONENT_NAME, array_pop($refs));
52 }
53
57 public static function _getInstanceByObjId(int $a_obj_id): ilGroupParticipants
58 {
59 if (isset(self::$instances[$a_obj_id]) && self::$instances[$a_obj_id]) {
60 return self::$instances[$a_obj_id];
61 }
62 return self::$instances[$a_obj_id] = new ilGroupParticipants($a_obj_id);
63 }
64
68 public static function getMemberRoles(int $a_ref_id): array
69 {
70 global $DIC;
71
72 $rbacreview = $DIC['rbacreview'];
73
74 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
75
76 $roles = array();
77 foreach ($lrol as $role) {
78 $title = ilObject::_lookupTitle($role);
79 switch (substr($title, 0, 8)) {
80 case 'il_grp_a':
81 case 'il_grp_m':
82 continue 2;
83
84 default:
85 $roles[$role] = $role;
86 }
87 }
88 return $roles;
89 }
90
91 public function add(int $a_usr_id, int $a_role): bool
92 {
93 if (parent::add($a_usr_id, $a_role)) {
94 $this->addRecommendation($a_usr_id);
95 return true;
96 }
97 return false;
98 }
99
100 public function addSubscriber(int $a_usr_id): void
101 {
102 parent::addSubscriber($a_usr_id);
103
104 $this->logger->info('Raise new event: Modules/Group addSubscriber.');
105 $this->eventHandler->raise(
106 "Modules/Group",
107 'addSubscriber',
108 array(
109 'obj_id' => $this->getObjId(),
110 'usr_id' => $a_usr_id
111 )
112 );
113 }
114
115
116
120 public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
121 {
122 global $DIC;
123
124 $rbacreview = $DIC->rbac()->review();
125 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
126 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
127 }
128
129 public function sendNotification(int $a_type, int $a_usr_id, bool $a_force_sending_mail = false): void
130 {
132 $mail->forceSendingMail($a_force_sending_mail);
133
134 switch ($a_type) {
136
138 $mail->setRefId($this->ref_id);
139 $mail->setRecipients(array($a_usr_id));
140 $mail->send();
141 break;
142
144
146 $mail->setRefId($this->ref_id);
147 $mail->setRecipients(array($a_usr_id));
148 $mail->send();
149 break;
150
152
154 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
155 $mail->setRefId($this->ref_id);
156 $mail->setRecipients($this->getNotificationRecipients());
157 $mail->send();
158 break;
159
161
163 $mail->setRefId($this->ref_id);
164 $mail->setRecipients(array($a_usr_id));
165 $mail->send();
166 break;
167
169
171 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
172 $mail->setRefId($this->ref_id);
173 $mail->setRecipients($this->getNotificationRecipients());
174 $mail->send();
175 break;
176
178
180 $mail->setRefId($this->ref_id);
181 $mail->setRecipients(array($a_usr_id));
182 $mail->send();
183 break;
184
186
188 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
189 $mail->setRefId($this->ref_id);
190 $mail->setRecipients($this->getNotificationRecipients());
191 $mail->send();
192 break;
193
195
197 $mail->setRefId($this->ref_id);
198 $mail->setRecipients(array($a_usr_id));
199 $mail->send();
200 break;
201
203
205 $mail->setRefId($this->ref_id);
206 $mail->setRecipients(array($a_usr_id));
207 $mail->send();
208 break;
209
211
212 $wl = new ilGroupWaitingList($this->obj_id);
213 $pos = $wl->getPosition($a_usr_id);
214
216 $mail->setRefId($this->ref_id);
217 $mail->setRecipients(array($a_usr_id));
218 $mail->setAdditionalInformation(array('position' => $pos));
219 $mail->send();
220 break;
221
223
225 $mail->setRefId($this->ref_id);
226 $mail->setRecipients(array($a_usr_id));
227 $mail->send();
228 break;
229
230
231 }
232 }
233}
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)
Static function to check if a user is a participant of the container object.
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
__construct(int $a_obj_id)
Constructor.
sendNotification(int $a_type, int $a_usr_id, bool $a_force_sending_mail=false)
static getMemberRoles(int $a_ref_id)
Get member roles (not auto generated)
add(int $a_usr_id, int $a_role)
Waiting list for groups.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
Base class for course and group participants.
addRecommendation(int $a_usr_id)
Add desktop item @access public.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc