ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGroupMembershipMailNotification.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Mail/classes/class.ilMailNotification.php';
5 
13 {
15  const TYPE_DISMISS_MEMBER = 21;
16 
19 
20  const TYPE_STATUS_CHANGED = 24;
21 
22  const TYPE_BLOCKED_MEMBER = 25;
24 
28 
32 
33 
37  public function __construct()
38  {
40  }
41 
46  public function send()
47  {
48  global $ilSetting;
49 
50  // parent::send();
51 
52  switch($this->getType())
53  {
54  case self::TYPE_ADMISSION_MEMBER:
55 
56  // automatic mails about status change disabled
57  if(!$ilSetting->get('mail_grp_member_notification',false))
58  {
59  return;
60  }
61 
62  foreach($this->getRecipients() as $rcp)
63  {
64  $this->initLanguage($rcp);
65  $this->initMail();
66  $this->setSubject(
67  sprintf($this->getLanguageText('grp_mail_admission_new_sub'),$this->getObjectTitle(true))
68  );
69  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
70  $this->appendBody("\n\n");
71  $this->appendBody(
72  sprintf($this->getLanguageText('grp_mail_admission_new_bod'),$this->getObjectTitle())
73  );
74  $this->appendBody("\n\n");
75  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
76  $this->appendBody("\n\n");
77  $this->appendBody($this->createPermanentLink());
78  $this->getMail()->appendInstallationSignature(true);
79 
80  $this->sendMail(array($rcp),array('system'));
81  }
82  break;
83 
84  case self::TYPE_DISMISS_MEMBER:
85 
86  // automatic mails about status change disabled
87  if(!$ilSetting->get('mail_grp_member_notification',false))
88  {
89  return;
90  }
91 
92  foreach($this->getRecipients() as $rcp)
93  {
94  $this->initLanguage($rcp);
95  $this->initMail();
96  $this->setSubject(
97  sprintf($this->getLanguageText('grp_mail_dismiss_sub'),$this->getObjectTitle(true))
98  );
99  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
100  $this->appendBody("\n\n");
101  $this->appendBody(
102  sprintf($this->getLanguageText('grp_mail_dismiss_bod'),$this->getObjectTitle())
103  );
104  $this->getMail()->appendInstallationSignature(true);
105  $this->sendMail(array($rcp),array('system'));
106  }
107  break;
108 
109 
110  case self::TYPE_NOTIFICATION_REGISTRATION:
111 
112  foreach($this->getRecipients() as $rcp)
113  {
114  $this->initLanguage($rcp);
115  $this->initMail();
116  $this->setSubject(
117  sprintf($this->getLanguageText('grp_mail_notification_reg_sub'),$this->getObjectTitle(true))
118  );
119  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
120  $this->appendBody("\n\n");
121 
122  $info = $this->getAdditionalInformation();
123  $this->appendBody(
124  sprintf($this->getLanguageText('grp_mail_notification_reg_bod'),
125  $this->userToString($info['usr_id']),
126  $this->getObjectTitle()
127  )
128  );
129  $this->appendBody("\n\n");
130  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
131  $this->appendBody("\n\n");
132  $this->appendBody($this->createPermanentLink(array(),'_mem'));
133 
134  $this->appendBody("\n\n");
135  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
136 
137  $this->getMail()->appendInstallationSignature(true);
138  $this->sendMail(array($rcp),array('system'));
139  }
140  break;
141 
142  case self::TYPE_UNSUBSCRIBE_MEMBER:
143 
144  foreach($this->getRecipients() as $rcp)
145  {
146  $this->initLanguage($rcp);
147  $this->initMail();
148  $this->setSubject(
149  sprintf($this->getLanguageText('grp_mail_unsubscribe_member_sub'),$this->getObjectTitle(true))
150  );
151  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
152  $this->appendBody("\n\n");
153  $this->appendBody(
154  sprintf($this->getLanguageText('grp_mail_unsubscribe_member_bod'),$this->getObjectTitle())
155  );
156  $this->getMail()->appendInstallationSignature(true);
157  $this->sendMail(array($rcp),array('system'));
158  }
159  break;
160 
161  case self::TYPE_NOTIFICATION_UNSUBSCRIBE:
162 
163  foreach($this->getRecipients() as $rcp)
164  {
165  $this->initLanguage($rcp);
166  $this->initMail();
167  $this->setSubject(
168  sprintf($this->getLanguageText('grp_mail_notification_unsub_sub'),$this->getObjectTitle(true))
169  );
170  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
171  $this->appendBody("\n\n");
172 
173  $info = $this->getAdditionalInformation();
174  $this->appendBody(
175  sprintf($this->getLanguageText('grp_mail_notification_unsub_bod'),
176  $this->userToString($info['usr_id']),
177  $this->getObjectTitle()
178  )
179  );
180  $this->appendBody("\n\n");
181  $this->appendBody($this->getLanguageText('grp_mail_notification_unsub_bod2'));
182  $this->appendBody("\n\n");
183  $this->appendBody($this->createPermanentLink(array(),'_mem'));
184 
185  $this->appendBody("\n\n");
186  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
187 
188  $this->getMail()->appendInstallationSignature(true);
189  $this->sendMail(array($rcp),array('system'));
190  }
191  break;
192 
193 
194  case self::TYPE_SUBSCRIBE_MEMBER:
195 
196  foreach($this->getRecipients() as $rcp)
197  {
198  $this->initLanguage($rcp);
199  $this->initMail();
200  $this->setSubject(
201  sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'),$this->getObjectTitle(true))
202  );
203  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
204  $this->appendBody("\n\n");
205  $this->appendBody(
206  sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'),$this->getObjectTitle())
207  );
208 
209  $this->appendBody("\n\n");
210  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
211  $this->appendBody("\n\n");
212  $this->appendBody($this->createPermanentLink());
213  $this->getMail()->appendInstallationSignature(true);
214 
215  $this->sendMail(array($rcp),array('system'));
216  }
217  break;
218 
219 
220  case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
221 
222  foreach($this->getRecipients() as $rcp)
223  {
224  $this->initLanguage($rcp);
225  $this->initMail();
226  $this->setSubject(
227  sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'),$this->getObjectTitle(true))
228  );
229  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
230  $this->appendBody("\n\n");
231 
232  $info = $this->getAdditionalInformation();
233  $this->appendBody(
234  sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'),
235  $this->userToString($info['usr_id']),
236  $this->getObjectTitle()
237  )
238  );
239  $this->appendBody("\n\n");
240  $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
241  $this->appendBody("\n");
242  $this->appendBody($this->createPermanentLink(array(),'_mem'));
243 
244  $this->appendBody("\n\n");
245  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
246 
247  $this->getMail()->appendInstallationSignature(true);
248  $this->sendMail(array($rcp),array('system'));
249  }
250  break;
251 
252  case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
253 
254  foreach($this->getRecipients() as $rcp)
255  {
256  $this->initLanguage($rcp);
257  $this->initMail();
258  $this->setSubject(
259  sprintf($this->getLanguageText('grp_mail_sub_dec_sub'),$this->getObjectTitle(true))
260  );
261  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
262  $this->appendBody("\n\n");
263  $this->appendBody(
264  sprintf($this->getLanguageText('grp_mail_sub_dec_bod'),$this->getObjectTitle())
265  );
266 
267  $this->getMail()->appendInstallationSignature(true);
268 
269  $this->sendMail(array($rcp),array('system'));
270  }
271  break;
272 
273  case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
274 
275  foreach($this->getRecipients() as $rcp)
276  {
277  $this->initLanguage($rcp);
278  $this->initMail();
279  $this->setSubject(
280  sprintf($this->getLanguageText('grp_mail_sub_acc_sub'),$this->getObjectTitle(true))
281  );
282  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
283  $this->appendBody("\n\n");
284  $this->appendBody(
285  sprintf($this->getLanguageText('grp_mail_sub_acc_bod'),$this->getObjectTitle())
286  );
287  $this->appendBody("\n\n");
288  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
289  $this->appendBody("\n\n");
290  $this->appendBody($this->createPermanentLink());
291  $this->getMail()->appendInstallationSignature(true);
292 
293  $this->sendMail(array($rcp),array('system'));
294  }
295  break;
296 
297  case self::TYPE_WAITING_LIST_MEMBER:
298  foreach($this->getRecipients() as $rcp)
299  {
300  $this->initLanguage($rcp);
301  $this->initMail();
302  $this->setSubject(
303  sprintf($this->getLanguageText('grp_mail_wl_sub'),$this->getObjectTitle(true))
304  );
305 
306  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
307 
308  $info = $this->getAdditionalInformation();
309  $this->appendBody("\n\n");
310  $this->appendBody(
311  sprintf($this->getLanguageText('grp_mail_wl_bod'),
312  $this->getObjectTitle(),
313  $info['position']
314  )
315  );
316  $this->getMail()->appendInstallationSignature(true);
317  $this->sendMail(array($rcp),array('system'));
318  }
319  break;
320 
321 
322  case self::TYPE_STATUS_CHANGED:
323  foreach($this->getRecipients() as $rcp)
324  {
325  $this->initLanguage($rcp);
326  $this->initMail();
327  $this->setSubject(
328  sprintf($this->getLanguageText('grp_mail_status_sub'),$this->getObjectTitle(true))
329  );
330  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
331  $this->appendBody("\n\n");
332  $this->appendBody(
333  sprintf($this->getLanguageText('grp_mail_status_bod'),$this->getObjectTitle())
334  );
335 
336  $this->appendBody("\n\n");
337  $this->appendBody($this->createGroupStatus($rcp));
338 
339  $this->appendBody("\n\n");
340  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
341  $this->appendBody("\n\n");
342  $this->appendBody($this->createPermanentLink());
343 
344  $this->getMail()->appendInstallationSignature(true);
345 
346  $this->sendMail(array($rcp),array('system'));
347  }
348  break;
349 
350  }
351  return true;
352  }
353 
359  protected function initLanguage($a_usr_id)
360  {
361  parent::initLanguage($a_usr_id);
362  $this->getLanguage()->loadLanguageModule('grp');
363  }
364 
370  protected function createGroupStatus($a_usr_id)
371  {
373 
374  $body = $this->getLanguageText('grp_new_status')."\n";
375  $body .= $this->getLanguageText('role').': ';
376 
377 
378  if($part->isAdmin($a_usr_id))
379  {
380  $body .= $this->getLanguageText('il_grp_admin')."\n";
381 
382  }
383  else
384  {
385  $body .= $this->getLanguageText('il_grp_member')."\n";
386  }
387 
388  if($part->isAdmin($a_usr_id))
389  {
390  $body .= $this->getLanguageText('grp_notification').': ';
391 
392  if($part->isNotificationEnabled($a_usr_id))
393  {
394  $body .= $this->getLanguageText('grp_notify_on')."\n";
395  }
396  else
397  {
398  $body .= $this->getLanguageText('grp_notify_off')."\n";
399  }
400  }
401  return $body;
402  }
403 
404 }
405 ?>