ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
79
80 $rbacreview = $DIC['rbacreview'];
81
82 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
83
84 $roles = array();
85 foreach ($lrol as $role) {
86 $title = ilObject::_lookupTitle($role);
87 switch (substr($title, 0, 8)) {
88 case 'il_grp_a':
89 case 'il_grp_m':
90 continue 2;
91
92 default:
93 $roles[$role] = $role;
94 }
95 }
96 return $roles;
97 }
98
105 public function add($a_usr_id, $a_role)
106 {
107 if (parent::add($a_usr_id, $a_role)) {
108 $this->addRecommendation($a_usr_id);
109 return true;
110 }
111 return false;
112 }
113
114 public function addSubscriber($a_usr_id)
115 {
116 global $DIC;
117
118 $ilAppEventHandler = $DIC['ilAppEventHandler'];
119 $ilLog = $DIC['ilLog'];
120
121 parent::addSubscriber($a_usr_id);
122
123 $GLOBALS['DIC']->logger()->grp()->info('Raise new event: Modules/Group addSubscriber.');
124 $ilAppEventHandler->raise(
125 "Modules/Group",
126 'addSubscriber',
127 array(
128 'obj_id' => $this->getObjId(),
129 'usr_id' => $a_usr_id
130 )
131 );
132 }
133
134
135
144 public static function _isParticipant($a_ref_id, $a_usr_id)
145 {
146 global $DIC;
147
148 $rbacreview = $DIC['rbacreview'];
149 $ilObjDataCache = $DIC['ilObjDataCache'];
150 $ilDB = $DIC['ilDB'];
151 $ilLog = $DIC['ilLog'];
152
153 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
154 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
155 }
156
163 public function sendNotification($a_type, $a_usr_id, $a_force_sending_mail = false)
164 {
165 include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
167 $mail->forceSendingMail($a_force_sending_mail);
168
169 switch ($a_type) {
171
173 $mail->setRefId($this->ref_id);
174 $mail->setRecipients(array($a_usr_id));
175 $mail->send();
176 break;
177
179
181 $mail->setRefId($this->ref_id);
182 $mail->setRecipients(array($a_usr_id));
183 $mail->send();
184 break;
185
187
189 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
190 $mail->setRefId($this->ref_id);
191 $mail->setRecipients($this->getNotificationRecipients());
192 $mail->send();
193 break;
194
196
198 $mail->setRefId($this->ref_id);
199 $mail->setRecipients(array($a_usr_id));
200 $mail->send();
201 break;
202
204
206 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
207 $mail->setRefId($this->ref_id);
208 $mail->setRecipients($this->getNotificationRecipients());
209 $mail->send();
210 break;
211
213
215 $mail->setRefId($this->ref_id);
216 $mail->setRecipients(array($a_usr_id));
217 $mail->send();
218 break;
219
221
223 $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
224 $mail->setRefId($this->ref_id);
225 $mail->setRecipients($this->getNotificationRecipients());
226 $mail->send();
227 break;
228
230
232 $mail->setRefId($this->ref_id);
233 $mail->setRecipients(array($a_usr_id));
234 $mail->send();
235 break;
236
238
240 $mail->setRefId($this->ref_id);
241 $mail->setRecipients(array($a_usr_id));
242 $mail->send();
243 break;
244
246
247 include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
248 $wl = new ilGroupWaitingList($this->obj_id);
249 $pos = $wl->getPosition($a_usr_id);
250
252 $mail->setRefId($this->ref_id);
253 $mail->setRecipients(array($a_usr_id));
254 $mail->setAdditionalInformation(array('position' => $pos));
255 $mail->send();
256 break;
257
259
261 $mail->setRefId($this->ref_id);
262 $mail->setRecipients(array($a_usr_id));
263 $mail->send();
264 break;
265
266
267 }
268 return true;
269 }
270}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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
addRecommendation($a_usr_id)
Add desktop item.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getObjId()
get current obj_id
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46