ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
24 include_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  $this->type = 'grp';
51  parent::__construct(self::COMPONENT_NAME,$a_obj_id);
52  }
53 
63  public static function _getInstanceByObjId($a_obj_id)
64  {
65  if(isset(self::$instances[$a_obj_id]) and self::$instances[$a_obj_id])
66  {
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)
84  {
86  switch(substr($title,0,8))
87  {
88  case 'il_grp_a':
89  case 'il_grp_m':
90  continue;
91 
92  default:
93  $roles[$role] = $role;
94  }
95  }
96  return $roles;
97  }
98 
99  public function addSubscriber($a_usr_id)
100  {
101  global $ilAppEventHandler, $ilLog;
102 
103  parent::addSubscriber($a_usr_id);
104 
105  $ilLog->write(__METHOD__.': Raise new event: Modules/Group addSubscriber');
106  $ilAppEventHandler->raise(
107  "Modules/Group",
108  'addSubscriber',
109  array(
110  'obj_id' => $this->getObjId(),
111  'usr_id' => $a_usr_id
112  )
113  );
114  }
115 
116 
117 
126  public static function _isParticipant($a_ref_id,$a_usr_id)
127  {
128  global $rbacreview,$ilObjDataCache,$ilDB,$ilLog;
129 
130  $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,false);
131  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
132  }
133 
140  public function sendNotification($a_type,$a_usr_id, $a_force_sending_mail = false)
141  {
142  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
143  $mail = new ilGroupMembershipMailNotification();
144  $mail->forceSendingMail($a_force_sending_mail);
145 
146  switch($a_type)
147  {
149 
151  $mail->setRefId($this->ref_id);
152  $mail->setRecipients(array($a_usr_id));
153  $mail->send();
154  break;
155 
157 
159  $mail->setRefId($this->ref_id);
160  $mail->setRecipients(array($a_usr_id));
161  $mail->send();
162  break;
163 
165 
167  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
168  $mail->setRefId($this->ref_id);
169  $mail->setRecipients($this->getNotificationRecipients());
170  $mail->send();
171  break;
172 
174 
176  $mail->setRefId($this->ref_id);
177  $mail->setRecipients(array($a_usr_id));
178  $mail->send();
179  break;
180 
182 
184  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
185  $mail->setRefId($this->ref_id);
186  $mail->setRecipients($this->getNotificationRecipients());
187  $mail->send();
188  break;
189 
191 
193  $mail->setRefId($this->ref_id);
194  $mail->setRecipients(array($a_usr_id));
195  $mail->send();
196  break;
197 
199 
201  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
202  $mail->setRefId($this->ref_id);
203  $mail->setRecipients($this->getNotificationRecipients());
204  $mail->send();
205  break;
206 
208 
210  $mail->setRefId($this->ref_id);
211  $mail->setRecipients(array($a_usr_id));
212  $mail->send();
213  break;
214 
216 
218  $mail->setRefId($this->ref_id);
219  $mail->setRecipients(array($a_usr_id));
220  $mail->send();
221  break;
222 
224 
225  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
226  $wl = new ilGroupWaitingList($this->obj_id);
227  $pos = $wl->getPosition($a_usr_id);
228 
230  $mail->setRefId($this->ref_id);
231  $mail->setRecipients(array($a_usr_id));
232  $mail->setAdditionalInformation(array('position' => $pos));
233  $mail->send();
234  break;
235 
237 
239  $mail->setRefId($this->ref_id);
240  $mail->setRecipients(array($a_usr_id));
241  $mail->send();
242  break;
243 
244 
245  }
246  return true;
247  }
248 
249 
250 }
251 ?>
getObjId()
get current obj_id
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static _lookupTitle($a_id)
lookup object title
static getMemberRoles($a_ref_id)
Get member roles (not auto generated)
__construct($a_obj_id)
Constructor.
sendNotification($a_type, $a_usr_id, $a_force_sending_mail=false)
Send notification mail.
$a_type
Definition: workflow.php:93
Waiting list for groups.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
getNotificationRecipients()
Get admin, tutor which have notification enabled.