ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseMembershipMailNotification.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  parent::send();
49 
50  switch($this->getType())
51  {
52  case self::TYPE_ADMISSION_MEMBER:
53 
54  foreach($this->getRecipients() as $rcp)
55  {
56  $this->initLanguage($rcp);
57  $this->initMail();
58  $this->setSubject(
59  sprintf($this->getLanguageText('crs_added_member'),$this->getObjectTitle(true))
60  );
61  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
62  $this->appendBody("\n\n");
63  $this->appendBody(
64  sprintf($this->getLanguageText('crs_added_member_body'),$this->getObjectTitle())
65  );
66  $this->appendBody("\n\n");
67  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
68  $this->appendBody("\n\n");
69  $this->appendBody($this->createPermanentLink());
70  $this->getMail()->appendInstallationSignature(true);
71 
72  $this->sendMail(array($rcp),array('system'));
73  }
74  break;
75 
76 
77  case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
78 
79  foreach($this->getRecipients() as $rcp)
80  {
81  $this->initLanguage($rcp);
82  $this->initMail();
83  $this->setSubject(
84  sprintf($this->getLanguageText('crs_accept_subscriber'),$this->getObjectTitle(true))
85  );
86  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
87  $this->appendBody("\n\n");
88  $this->appendBody(
89  sprintf($this->getLanguageText('crs_accept_subscriber_body'),$this->getObjectTitle())
90  );
91  $this->appendBody("\n\n");
92  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
93  $this->appendBody("\n\n");
94  $this->appendBody($this->createPermanentLink());
95  $this->getMail()->appendInstallationSignature(true);
96 
97  $this->sendMail(array($rcp),array('system'));
98  }
99  break;
100 
101  case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
102 
103  foreach($this->getRecipients() as $rcp)
104  {
105  $this->initLanguage($rcp);
106  $this->initMail();
107  $this->setSubject(
108  sprintf($this->getLanguageText('crs_reject_subscriber'),$this->getObjectTitle(true))
109  );
110  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
111  $this->appendBody("\n\n");
112  $this->appendBody(
113  sprintf($this->getLanguageText('crs_reject_subscriber_body'),$this->getObjectTitle())
114  );
115 
116  $this->getMail()->appendInstallationSignature(true);
117 
118  $this->sendMail(array($rcp),array('system'));
119  }
120  break;
121 
122  case self::TYPE_STATUS_CHANGED:
123  foreach($this->getRecipients() as $rcp)
124  {
125  $this->initLanguage($rcp);
126  $this->initMail();
127  $this->setSubject(
128  sprintf($this->getLanguageText('crs_status_changed'),$this->getObjectTitle(true))
129  );
130  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
131  $this->appendBody("\n\n");
132  $this->appendBody(
133  sprintf($this->getLanguageText('crs_status_changed_body'),$this->getObjectTitle())
134  );
135 
136  $this->appendBody("\n\n");
137  $this->appendBody($this->createCourseStatus($rcp));
138 
139  $this->appendBody("\n\n");
140  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
141  $this->appendBody("\n\n");
142  $this->appendBody($this->createPermanentLink());
143 
144  $this->getMail()->appendInstallationSignature(true);
145 
146  $this->sendMail(array($rcp),array('system'));
147  }
148  break;
149 
150 
151  case self::TYPE_DISMISS_MEMBER:
152 
153  foreach($this->getRecipients() as $rcp)
154  {
155  $this->initLanguage($rcp);
156  $this->initMail();
157  $this->setSubject(
158  sprintf($this->getLanguageText('crs_dismiss_member'),$this->getObjectTitle(true))
159  );
160  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
161  $this->appendBody("\n\n");
162  $this->appendBody(
163  sprintf($this->getLanguageText('crs_dismiss_member_body'),$this->getObjectTitle())
164  );
165  $this->getMail()->appendInstallationSignature(true);
166  $this->sendMail(array($rcp),array('system'));
167  }
168  break;
169 
170 
171  case self::TYPE_BLOCKED_MEMBER:
172 
173  foreach($this->getRecipients() as $rcp)
174  {
175  $this->initLanguage($rcp);
176  $this->initMail();
177  $this->setSubject(
178  sprintf($this->getLanguageText('crs_blocked_member'),$this->getObjectTitle(true))
179  );
180  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
181  $this->appendBody("\n\n");
182  $this->appendBody(
183  sprintf($this->getLanguageText('crs_blocked_member_body'),$this->getObjectTitle())
184  );
185  $this->getMail()->appendInstallationSignature(true);
186  $this->sendMail(array($rcp),array('system'));
187  }
188  break;
189 
190  case self::TYPE_UNBLOCKED_MEMBER:
191 
192  foreach($this->getRecipients() as $rcp)
193  {
194  $this->initLanguage($rcp);
195  $this->initMail();
196  $this->setSubject(
197  sprintf($this->getLanguageText('crs_unblocked_member'),$this->getObjectTitle(true))
198  );
199  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
200  $this->appendBody("\n\n");
201  $this->appendBody(
202  sprintf($this->getLanguageText('crs_unblocked_member_body'),$this->getObjectTitle())
203  );
204 
205  $this->appendBody("\n\n");
206  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
207  $this->appendBody("\n\n");
208  $this->appendBody($this->createPermanentLink());
209  $this->getMail()->appendInstallationSignature(true);
210 
211  $this->sendMail(array($rcp),array('system'));
212  }
213  break;
214 
215  case self::TYPE_NOTIFICATION_REGISTRATION:
216 
217  foreach($this->getRecipients() as $rcp)
218  {
219  $this->initLanguage($rcp);
220  $this->initMail();
221  $this->setSubject(
222  sprintf($this->getLanguageText('crs_new_subscription'),$this->getObjectTitle(true))
223  );
224  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
225  $this->appendBody("\n\n");
226 
227  $info = $this->getAdditionalInformation();
228  $this->appendBody(
229  sprintf($this->getLanguageText('crs_new_subscription_body'),
230  $this->userToString($info['usr_id']),
231  $this->getObjectTitle()
232  )
233  );
234  $this->appendBody("\n\n");
235  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
236  $this->appendBody("\n\n");
237  $this->appendBody($this->createPermanentLink(array(),'_mem'));
238 
239  $this->appendBody("\n\n");
240  $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
241 
242  $this->getMail()->appendInstallationSignature(true);
243  $this->sendMail(array($rcp),array('system'));
244  }
245  break;
246 
247  case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
248 
249  foreach($this->getRecipients() as $rcp)
250  {
251  $this->initLanguage($rcp);
252  $this->initMail();
253  $this->setSubject(
254  sprintf($this->getLanguageText('crs_new_subscription_request'),$this->getObjectTitle(true))
255  );
256  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
257  $this->appendBody("\n\n");
258 
259  $info = $this->getAdditionalInformation();
260  $this->appendBody(
261  sprintf($this->getLanguageText('crs_new_subscription_request_body'),
262  $this->userToString($info['usr_id']),
263  $this->getObjectTitle()
264  )
265  );
266  $this->appendBody("\n\n");
267  $this->appendBody($this->getLanguageText('crs_new_subscription_request_body2'));
268  $this->appendBody("\n");
269  $this->appendBody($this->createPermanentLink(array(),'_mem'));
270 
271  $this->appendBody("\n\n");
272  $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
273 
274  $this->getMail()->appendInstallationSignature(true);
275  $this->sendMail(array($rcp),array('system'));
276  }
277  break;
278 
279  case self::TYPE_NOTIFICATION_UNSUBSCRIBE:
280 
281  foreach($this->getRecipients() as $rcp)
282  {
283  $this->initLanguage($rcp);
284  $this->initMail();
285  $this->setSubject(
286  sprintf($this->getLanguageText('crs_cancel_subscription'),$this->getObjectTitle(true))
287  );
288  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
289  $this->appendBody("\n\n");
290 
291  $info = $this->getAdditionalInformation();
292  $this->appendBody(
293  sprintf($this->getLanguageText('crs_cancel_subscription_body'),
294  $this->userToString($info['usr_id']),
295  $this->getObjectTitle()
296  )
297  );
298  $this->appendBody("\n\n");
299  $this->appendBody($this->getLanguageText('crs_cancel_subscription_body2'));
300  $this->appendBody("\n\n");
301  $this->appendBody($this->createPermanentLink(array(),'_mem'));
302 
303  $this->appendBody("\n\n");
304  $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
305 
306  $this->getMail()->appendInstallationSignature(true);
307  $this->sendMail(array($rcp),array('system'));
308  }
309  break;
310 
311  case self::TYPE_UNSUBSCRIBE_MEMBER:
312  foreach($this->getRecipients() as $rcp)
313  {
314  $this->initLanguage($rcp);
315  $this->initMail();
316  $this->setSubject(
317  sprintf($this->getLanguageText('crs_unsubscribe_member'),$this->getObjectTitle(true))
318  );
319  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
320  $this->appendBody("\n\n");
321  $this->appendBody(
322  sprintf($this->getLanguageText('crs_unsubscribe_member_body'),$this->getObjectTitle())
323  );
324  $this->getMail()->appendInstallationSignature(true);
325  $this->sendMail(array($rcp),array('system'));
326  }
327  break;
328 
329  case self::TYPE_SUBSCRIBE_MEMBER:
330 
331  foreach($this->getRecipients() as $rcp)
332  {
333  $this->initLanguage($rcp);
334  $this->initMail();
335  $this->setSubject(
336  sprintf($this->getLanguageText('crs_subscribe_member'),$this->getObjectTitle(true))
337  );
338  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
339  $this->appendBody("\n\n");
340  $this->appendBody(
341  sprintf($this->getLanguageText('crs_subscribe_member_body'),$this->getObjectTitle())
342  );
343 
344  $this->appendBody("\n\n");
345  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
346  $this->appendBody("\n\n");
347  $this->appendBody($this->createPermanentLink());
348  $this->getMail()->appendInstallationSignature(true);
349 
350  $this->sendMail(array($rcp),array('system'));
351  }
352  break;
353 
354  case self::TYPE_WAITING_LIST_MEMBER:
355  foreach($this->getRecipients() as $rcp)
356  {
357  $this->initLanguage($rcp);
358  $this->initMail();
359  $this->setSubject(
360  sprintf($this->getLanguageText('crs_subscribe_wl'),$this->getObjectTitle(true))
361  );
362 
363  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
364 
365  $info = $this->getAdditionalInformation();
366  $this->appendBody("\n\n");
367  $this->appendBody(
368  sprintf($this->getLanguageText('crs_subscribe_wl_body'),
369  $this->getObjectTitle(),
370  $info['position']
371  )
372  );
373  $this->getMail()->appendInstallationSignature(true);
374  $this->sendMail(array($rcp),array('system'));
375  }
376  break;
377  }
378  return true;
379  }
380 
386  protected function initLanguage($a_usr_id)
387  {
388  parent::initLanguage($a_usr_id);
389  $this->getLanguage()->loadLanguageModule('crs');
390  }
391 
397  protected function createCourseStatus($a_usr_id)
398  {
400 
401  $body = $this->getLanguageText('crs_new_status')."\n";
402  $body .= $this->getLanguageText('role').': ';
403 
404 
405  if($part->isAdmin($a_usr_id))
406  {
407  $body .= $this->getLanguageText('crs_admin')."\n";
408 
409  }
410  elseif($part->isTutor($a_usr_id))
411  {
412  $body .= $this->getLanguageText('crs_tutor')."\n";
413  }
414  else
415  {
416  $body .= $this->getLanguageText('crs_member')."\n";
417  }
418 
419  if($part->isAdmin($a_usr_id) or $part->isTutor($a_usr_id))
420  {
421  $body .= $this->getLanguageText('crs_status').': ';
422 
423  if($part->isNotificationEnabled($a_usr_id))
424  {
425  $body .= $this->getLanguageText('crs_notify')."\n";
426  }
427  else
428  {
429  $body .= $this->getLanguageText('crs_no_notify')."\n";
430  }
431  }
432  else
433  {
434  $body .= $this->getLanguageText('crs_access').': ';
435 
436  if($part->isBlocked($a_usr_id))
437  {
438  $body .= $this->getLanguageText('crs_blocked')."\n";
439  }
440  else
441  {
442  $body .= $this->getLanguageText('crs_unblocked')."\n";
443  }
444  }
445 
446  $body .= $this->getLanguageText('crs_passed').': ';
447 
448  if($part->hasPassed($a_usr_id))
449  {
450  $body .= $this->getLanguageText('yes');
451  }
452  else
453  {
454  $body .= $this->getLanguageText('no');
455  }
456  return $body;
457  }
458 }
459 ?>