ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupParticipants.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Membership/classes/class.ilParticipants.php');
25
37{
38 const COMPONENT_NAME = 'Modules/Group';
39
40 protected static $instances = array();
41
48 public function __construct($a_obj_id)
49 {
50 // ref based constructor
51 $refs = ilObject::_getAllReferences($a_obj_id);
52 parent::__construct(self::COMPONENT_NAME, array_pop($refs));
53 }
54
64 public static function _getInstanceByObjId($a_obj_id)
65 {
66 if (isset(self::$instances[$a_obj_id]) and self::$instances[$a_obj_id]) {
67 return self::$instances[$a_obj_id];
68 }
69 return self::$instances[$a_obj_id] = new ilGroupParticipants($a_obj_id);
70 }
71
76 public static function getMemberRoles($a_ref_id)
77 {
78 global $rbacreview;
79
80 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
81
82 $roles = array();
83 foreach ($lrol as $role) {
85 switch (substr($title, 0, 8)) {
86 case 'il_grp_a':
87 case 'il_grp_m':
88 continue;
89
90 default:
91 $roles[$role] = $role;
92 }
93 }
94 return $roles;
95 }
96
103 public function add($a_usr_id, $a_role)
104 {
105 if (parent::add($a_usr_id, $a_role)) {
106 $this->addDesktopItem($a_usr_id);
107 return true;
108 }
109 return false;
110 }
111
112 public function addSubscriber($a_usr_id)
113 {
114 global $ilAppEventHandler, $ilLog;
115
116 parent::addSubscriber($a_usr_id);
117
118 $GLOBALS['DIC']->logger()->grp()->info('Raise new event: Modules/Group addSubscriber.');
119 $ilAppEventHandler->raise(
120 "Modules/Group",
121 'addSubscriber',
122 array(
123 'obj_id' => $this->getObjId(),
124 'usr_id' => $a_usr_id
125 )
126 );
127 }
128
129
130
139 public static function _isParticipant($a_ref_id, $a_usr_id)
140 {
141 global $rbacreview,$ilObjDataCache,$ilDB,$ilLog;
142
143 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
144 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
145 }
146
153 public function sendNotification($a_type, $a_usr_id, $a_force_sending_mail = false)
154 {
155 include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
157 $mail->forceSendingMail($a_force_sending_mail);
158
159 switch ($a_type) {
161
163 $mail->setRefId($this->ref_id);
164 $mail->setRecipients(array($a_usr_id));
165 $mail->send();
166 break;
167
169
171 $mail->setRefId($this->ref_id);
172 $mail->setRecipients(array($a_usr_id));
173 $mail->send();
174 break;
175
177
179 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
180 $mail->setRefId($this->ref_id);
181 $mail->setRecipients($this->getNotificationRecipients());
182 $mail->send();
183 break;
184
186
188 $mail->setRefId($this->ref_id);
189 $mail->setRecipients(array($a_usr_id));
190 $mail->send();
191 break;
192
194
196 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
197 $mail->setRefId($this->ref_id);
198 $mail->setRecipients($this->getNotificationRecipients());
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
213 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
214 $mail->setRefId($this->ref_id);
215 $mail->setRecipients($this->getNotificationRecipients());
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
228
230 $mail->setRefId($this->ref_id);
231 $mail->setRecipients(array($a_usr_id));
232 $mail->send();
233 break;
234
236
237 include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
238 $wl = new ilGroupWaitingList($this->obj_id);
239 $pos = $wl->getPosition($a_usr_id);
240
242 $mail->setRefId($this->ref_id);
243 $mail->setRecipients(array($a_usr_id));
244 $mail->setAdditionalInformation(array('position' => $pos));
245 $mail->send();
246 break;
247
249
251 $mail->setRefId($this->ref_id);
252 $mail->setRecipients(array($a_usr_id));
253 $mail->send();
254 break;
255
256
257 }
258 return true;
259 }
260}
add()
Definition: add.php:2
An exception for terminatinating execution or to throw for unit testing.
static getMemberRoles($a_ref_id)
Get member roles (not auto generated)
addSubscriber($a_usr_id)
Add subscriber.
__construct($a_obj_id)
Constructor.
add($a_usr_id, $a_role)
Add user to role.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
sendNotification($a_type, $a_usr_id, $a_force_sending_mail=false)
Send notification mail.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
Waiting list for groups.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
addDesktopItem($a_usr_id)
Add desktop item.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getObjId()
get current obj_id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$a_type
Definition: workflow.php:92