ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGroupParticipants.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
30  protected const COMPONENT_NAME = 'components/ILIAS/Group';
31 
32  protected static array $instances = [];
33 
40  public function __construct(int $a_obj_id)
41  {
42  global $DIC;
43 
44  $this->logger = $DIC->logger()->grp();
45 
46  // ref based constructor
47  $refs = ilObject::_getAllReferences($a_obj_id);
48  parent::__construct(self::COMPONENT_NAME, array_pop($refs));
49  }
50 
54  public static function _getInstanceByObjId(int $a_obj_id): ilGroupParticipants
55  {
56  if (isset(self::$instances[$a_obj_id]) && self::$instances[$a_obj_id]) {
57  return self::$instances[$a_obj_id];
58  }
59  return self::$instances[$a_obj_id] = new ilGroupParticipants($a_obj_id);
60  }
61 
65  public static function getMemberRoles(int $a_ref_id): array
66  {
67  global $DIC;
68 
69  $rbacreview = $DIC['rbacreview'];
70 
71  $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
72 
73  $roles = array();
74  foreach ($lrol as $role) {
75  $title = ilObject::_lookupTitle($role);
76  switch (substr($title, 0, 8)) {
77  case 'il_grp_a':
78  case 'il_grp_m':
79  continue 2;
80 
81  default:
82  $roles[$role] = $role;
83  }
84  }
85  return $roles;
86  }
87 
88  public function add(int $a_usr_id, int $a_role): bool
89  {
90  if (parent::add($a_usr_id, $a_role)) {
91  $this->addRecommendation($a_usr_id);
92  return true;
93  }
94  return false;
95  }
96 
97  public function addSubscriber(int $a_usr_id): void
98  {
99  parent::addSubscriber($a_usr_id);
100 
101  $this->logger->info('Raise new event: Modules/Group addSubscriber.');
102  $this->eventHandler->raise(
103  "components/ILIAS/Group",
104  'addSubscriber',
105  array(
106  'obj_id' => $this->getObjId(),
107  'usr_id' => $a_usr_id
108  )
109  );
110  }
111 
112 
113 
117  public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
118  {
119  global $DIC;
120 
121  $rbacreview = $DIC->rbac()->review();
122  $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
123  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
124  }
125 
126  public function sendNotification(int $a_type, int $a_usr_id, bool $a_force_sending_mail = false): void
127  {
128  $mail = new ilGroupMembershipMailNotification();
129  $mail->forceSendingMail($a_force_sending_mail);
130 
131  switch ($a_type) {
133 
135  $mail->setRefId($this->ref_id);
136  $mail->setRecipients(array($a_usr_id));
137  $mail->send();
138  break;
139 
141 
143  $mail->setRefId($this->ref_id);
144  $mail->setRecipients(array($a_usr_id));
145  $mail->send();
146  break;
147 
149 
151  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
152  $mail->setRefId($this->ref_id);
153  $mail->setRecipients($this->getNotificationRecipients());
154  $mail->send();
155  break;
156 
158 
160  $mail->setRefId($this->ref_id);
161  $mail->setRecipients(array($a_usr_id));
162  $mail->send();
163  break;
164 
166 
168  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
169  $mail->setRefId($this->ref_id);
170  $mail->setRecipients($this->getNotificationRecipients());
171  $mail->send();
172  break;
173 
175 
177  $mail->setRefId($this->ref_id);
178  $mail->setRecipients(array($a_usr_id));
179  $mail->send();
180  break;
181 
183 
185  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
186  $mail->setRefId($this->ref_id);
187  $mail->setRecipients($this->getNotificationRecipients());
188  $mail->send();
189  break;
190 
192 
194  $mail->setRefId($this->ref_id);
195  $mail->setRecipients(array($a_usr_id));
196  $mail->send();
197  break;
198 
200 
202  $mail->setRefId($this->ref_id);
203  $mail->setRecipients(array($a_usr_id));
204  $mail->send();
205  break;
206 
208 
209  $wl = new ilGroupWaitingList($this->obj_id);
210  $pos = $wl->getPosition($a_usr_id);
211 
213  $mail->setRefId($this->ref_id);
214  $mail->setRecipients(array($a_usr_id));
215  $mail->setAdditionalInformation(array('position' => $pos));
216  $mail->send();
217  break;
218 
220 
222  $mail->setRefId($this->ref_id);
223  $mail->setRecipients(array($a_usr_id));
224  $mail->send();
225  break;
226  }
227  }
228 }
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
add()
description: > Example for rendring an add glyph.
Definition: add.php:41
static getMemberRoles(int $a_ref_id)
Get member roles (not auto generated)
static _getAllReferences(int $id)
get all reference ids for object ID
addRecommendation(int $a_usr_id)
Add desktop item public.
__construct(int $a_obj_id)
Constructor.
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
Waiting list for groups.
sendNotification(int $a_type, int $a_usr_id, bool $a_force_sending_mail=false)
add(int $a_usr_id, int $a_role)
Base class for course and group participants.
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
__construct(Container $dic, ilPlugin $plugin)
getNotificationRecipients()
Get admin, tutor which have notification enabled.