ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  protected static $instances = array();
39 
46  public function __construct($a_obj_id)
47  {
48  $this->type = 'grp';
49  parent::__construct($a_obj_id);
50  }
51 
61  public static function _getInstanceByObjId($a_obj_id)
62  {
63  if(isset(self::$instances[$a_obj_id]) and self::$instances[$a_obj_id])
64  {
65  return self::$instances[$a_obj_id];
66  }
67  return self::$instances[$a_obj_id] = new ilGroupParticipants($a_obj_id);
68  }
69 
74  public static function getMemberRoles($a_ref_id)
75  {
76  global $rbacreview;
77 
78  $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
79  $lrol = $rbacreview->getRolesOfRoleFolder($rolf['ref_id'],false);
80 
81  $roles = array();
82  foreach($lrol as $role)
83  {
85  switch(substr($title,0,8))
86  {
87  case 'il_grp_a':
88  case 'il_grp_m':
89  continue;
90 
91  default:
92  $roles[$role] = $role;
93  }
94  }
95  return $roles;
96  }
97 
98 
107  public static function _isParticipant($a_ref_id,$a_usr_id)
108  {
109  global $rbacreview,$ilObjDataCache,$ilDB,$ilLog;
110 
111  $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
112  if(!isset($rolf['ref_id']) or !$rolf['ref_id'])
113  {
114  $title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($a_ref_id));
115  $ilLog->write(__METHOD__.': Found object without role folder. Ref_id: '.$a_ref_id.', title: '.$title);
116  $ilLog->logStack();
117 
118  return false;
119  }
120  $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
121  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
122  }
123 
130  public function sendNotification($a_type,$a_usr_id)
131  {
132  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
133  switch($a_type)
134  {
136 
137  $mail = new ilGroupMembershipMailNotification();
139  $mail->setRefId($this->ref_id);
140  $mail->setRecipients(array($a_usr_id));
141  $mail->send();
142  break;
143 
145 
146  $mail = new ilGroupMembershipMailNotification();
148  $mail->setRefId($this->ref_id);
149  $mail->setRecipients(array($a_usr_id));
150  $mail->send();
151  break;
152 
154 
155  $mail = new ilGroupMembershipMailNotification();
157  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
158  $mail->setRefId($this->ref_id);
159  $mail->setRecipients($this->getNotificationRecipients());
160  $mail->send();
161  break;
162 
164 
165  $mail = new ilGroupMembershipMailNotification();
167  $mail->setRefId($this->ref_id);
168  $mail->setRecipients(array($a_usr_id));
169  $mail->send();
170  break;
171 
173 
174  $mail = new ilGroupMembershipMailNotification();
176  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
177  $mail->setRefId($this->ref_id);
178  $mail->setRecipients($this->getNotificationRecipients());
179  $mail->send();
180  break;
181 
183 
184  $mail = new ilGroupMembershipMailNotification();
186  $mail->setRefId($this->ref_id);
187  $mail->setRecipients(array($a_usr_id));
188  $mail->send();
189  break;
190 
192 
193  $mail = new ilGroupMembershipMailNotification();
195  $mail->setAdditionalInformation(array('usr_id' => $a_usr_id));
196  $mail->setRefId($this->ref_id);
197  $mail->setRecipients($this->getNotificationRecipients());
198  $mail->send();
199  break;
200 
202 
203  $mail = new ilGroupMembershipMailNotification();
205  $mail->setRefId($this->ref_id);
206  $mail->setRecipients(array($a_usr_id));
207  $mail->send();
208  break;
209 
211 
212  $mail = new ilGroupMembershipMailNotification();
214  $mail->setRefId($this->ref_id);
215  $mail->setRecipients(array($a_usr_id));
216  $mail->send();
217  break;
218 
220 
221  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
222  $wl = new ilGroupWaitingList($this->obj_id);
223  $pos = $wl->getPosition($a_usr_id);
224 
225  $mail = new ilGroupMembershipMailNotification();
227  $mail->setRefId($this->ref_id);
228  $mail->setRecipients(array($a_usr_id));
229  $mail->setAdditionalInformation(array('position' => $pos));
230  $mail->send();
231  break;
232 
234 
235  $mail = new ilGroupMembershipMailNotification();
237  $mail->setRefId($this->ref_id);
238  $mail->setRecipients(array($a_usr_id));
239  $mail->send();
240  break;
241 
242 
243  }
244  return true;
245  }
246 
247 
248 }
249 ?>