ILIAS  Release_4_0_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  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('grp_mail_admission_new_sub'),$this->getObjectTitle(true))
60  );
61  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
62  $this->appendBody("\n\n");
63  $this->appendBody(
64  sprintf($this->getLanguageText('grp_mail_admission_new_bod'),$this->getObjectTitle())
65  );
66  $this->appendBody("\n\n");
67  $this->appendBody($this->getLanguageText('grp_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  case self::TYPE_DISMISS_MEMBER:
77 
78  foreach($this->getRecipients() as $rcp)
79  {
80  $this->initLanguage($rcp);
81  $this->initMail();
82  $this->setSubject(
83  sprintf($this->getLanguageText('grp_mail_dismiss_sub'),$this->getObjectTitle(true))
84  );
85  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
86  $this->appendBody("\n\n");
87  $this->appendBody(
88  sprintf($this->getLanguageText('grp_mail_dismiss_bod'),$this->getObjectTitle())
89  );
90  $this->getMail()->appendInstallationSignature(true);
91  $this->sendMail(array($rcp),array('system'));
92  }
93  break;
94 
95 
96  case self::TYPE_NOTIFICATION_REGISTRATION:
97 
98  foreach($this->getRecipients() as $rcp)
99  {
100  $this->initLanguage($rcp);
101  $this->initMail();
102  $this->setSubject(
103  sprintf($this->getLanguageText('grp_mail_notification_reg_sub'),$this->getObjectTitle(true))
104  );
105  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
106  $this->appendBody("\n\n");
107 
108  $info = $this->getAdditionalInformation();
109  $this->appendBody(
110  sprintf($this->getLanguageText('grp_mail_notification_reg_bod'),
111  $this->userToString($info['usr_id']),
112  $this->getObjectTitle()
113  )
114  );
115  $this->appendBody("\n\n");
116  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
117  $this->appendBody("\n\n");
118  $this->appendBody($this->createPermanentLink());
119 
120  $this->appendBody("\n\n");
121  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
122 
123  $this->getMail()->appendInstallationSignature(true);
124  $this->sendMail(array($rcp),array('system'));
125  }
126  break;
127 
128  case self::TYPE_UNSUBSCRIBE_MEMBER:
129 
130  foreach($this->getRecipients() as $rcp)
131  {
132  $this->initLanguage($rcp);
133  $this->initMail();
134  $this->setSubject(
135  sprintf($this->getLanguageText('grp_mail_unsubscribe_member_sub'),$this->getObjectTitle(true))
136  );
137  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
138  $this->appendBody("\n\n");
139  $this->appendBody(
140  sprintf($this->getLanguageText('grp_mail_unsubscribe_member_bod'),$this->getObjectTitle())
141  );
142  $this->getMail()->appendInstallationSignature(true);
143  $this->sendMail(array($rcp),array('system'));
144  }
145  break;
146 
147  case self::TYPE_NOTIFICATION_UNSUBSCRIBE:
148 
149  foreach($this->getRecipients() as $rcp)
150  {
151  $this->initLanguage($rcp);
152  $this->initMail();
153  $this->setSubject(
154  sprintf($this->getLanguageText('grp_mail_notification_unsub_sub'),$this->getObjectTitle(true))
155  );
156  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
157  $this->appendBody("\n\n");
158 
159  $info = $this->getAdditionalInformation();
160  $this->appendBody(
161  sprintf($this->getLanguageText('grp_mail_notification_unsub_bod'),
162  $this->userToString($info['usr_id']),
163  $this->getObjectTitle()
164  )
165  );
166  $this->appendBody("\n\n");
167  $this->appendBody($this->getLanguageText('grp_mail_notification_unsub_bod2'));
168  $this->appendBody("\n\n");
169  $this->appendBody($this->createPermanentLink());
170 
171  $this->appendBody("\n\n");
172  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
173 
174  $this->getMail()->appendInstallationSignature(true);
175  $this->sendMail(array($rcp),array('system'));
176  }
177  break;
178 
179 
180  case self::TYPE_SUBSCRIBE_MEMBER:
181 
182  foreach($this->getRecipients() as $rcp)
183  {
184  $this->initLanguage($rcp);
185  $this->initMail();
186  $this->setSubject(
187  sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'),$this->getObjectTitle(true))
188  );
189  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
190  $this->appendBody("\n\n");
191  $this->appendBody(
192  sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'),$this->getObjectTitle())
193  );
194 
195  $this->appendBody("\n\n");
196  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
197  $this->appendBody("\n\n");
198  $this->appendBody($this->createPermanentLink());
199  $this->getMail()->appendInstallationSignature(true);
200 
201  $this->sendMail(array($rcp),array('system'));
202  }
203  break;
204 
205 
206  case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
207 
208  foreach($this->getRecipients() as $rcp)
209  {
210  $this->initLanguage($rcp);
211  $this->initMail();
212  $this->setSubject(
213  sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'),$this->getObjectTitle(true))
214  );
215  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
216  $this->appendBody("\n\n");
217 
218  $info = $this->getAdditionalInformation();
219  $this->appendBody(
220  sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'),
221  $this->userToString($info['usr_id']),
222  $this->getObjectTitle()
223  )
224  );
225  $this->appendBody("\n\n");
226  $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
227  $this->appendBody("\n");
228  $this->appendBody($this->createPermanentLink());
229 
230  $this->appendBody("\n\n");
231  $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
232 
233  $this->getMail()->appendInstallationSignature(true);
234  $this->sendMail(array($rcp),array('system'));
235  }
236  break;
237 
238  case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
239 
240  foreach($this->getRecipients() as $rcp)
241  {
242  $this->initLanguage($rcp);
243  $this->initMail();
244  $this->setSubject(
245  sprintf($this->getLanguageText('grp_mail_sub_dec_sub'),$this->getObjectTitle(true))
246  );
247  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
248  $this->appendBody("\n\n");
249  $this->appendBody(
250  sprintf($this->getLanguageText('grp_mail_sub_dec_bod'),$this->getObjectTitle())
251  );
252 
253  $this->getMail()->appendInstallationSignature(true);
254 
255  $this->sendMail(array($rcp),array('system'));
256  }
257  break;
258 
259  case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
260 
261  foreach($this->getRecipients() as $rcp)
262  {
263  $this->initLanguage($rcp);
264  $this->initMail();
265  $this->setSubject(
266  sprintf($this->getLanguageText('grp_mail_sub_acc_sub'),$this->getObjectTitle(true))
267  );
268  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
269  $this->appendBody("\n\n");
270  $this->appendBody(
271  sprintf($this->getLanguageText('grp_mail_sub_acc_bod'),$this->getObjectTitle())
272  );
273  $this->appendBody("\n\n");
274  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
275  $this->appendBody("\n\n");
276  $this->appendBody($this->createPermanentLink());
277  $this->getMail()->appendInstallationSignature(true);
278 
279  $this->sendMail(array($rcp),array('system'));
280  }
281  break;
282 
283  case self::TYPE_WAITING_LIST_MEMBER:
284  foreach($this->getRecipients() as $rcp)
285  {
286  $this->initLanguage($rcp);
287  $this->initMail();
288  $this->setSubject(
289  sprintf($this->getLanguageText('grp_mail_wl_sub'),$this->getObjectTitle(true))
290  );
291 
292  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
293 
294  $info = $this->getAdditionalInformation();
295  $this->appendBody("\n\n");
296  $this->appendBody(
297  sprintf($this->getLanguageText('grp_mail_wl_bod'),
298  $this->getObjectTitle(),
299  $info['position']
300  )
301  );
302  $this->getMail()->appendInstallationSignature(true);
303  $this->sendMail(array($rcp),array('system'));
304  }
305  break;
306 
307 
308  case self::TYPE_STATUS_CHANGED:
309  foreach($this->getRecipients() as $rcp)
310  {
311  $this->initLanguage($rcp);
312  $this->initMail();
313  $this->setSubject(
314  sprintf($this->getLanguageText('grp_mail_status_sub'),$this->getObjectTitle(true))
315  );
316  $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
317  $this->appendBody("\n\n");
318  $this->appendBody(
319  sprintf($this->getLanguageText('grp_mail_status_bod'),$this->getObjectTitle())
320  );
321 
322  $this->appendBody("\n\n");
323  $this->appendBody($this->createGroupStatus($rcp));
324 
325  $this->appendBody("\n\n");
326  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
327  $this->appendBody("\n\n");
328  $this->appendBody($this->createPermanentLink());
329 
330  $this->getMail()->appendInstallationSignature(true);
331 
332  $this->sendMail(array($rcp),array('system'));
333  }
334  break;
335 
336  }
337  return true;
338  }
339 
345  protected function initLanguage($a_usr_id)
346  {
347  parent::initLanguage($a_usr_id);
348  $this->getLanguage()->loadLanguageModule('grp');
349  }
350 
356  protected function createGroupStatus($a_usr_id)
357  {
359 
360  $body = $this->getLanguageText('grp_new_status')."\n";
361  $body .= $this->getLanguageText('role').': ';
362 
363 
364  if($part->isAdmin($a_usr_id))
365  {
366  $body .= $this->getLanguageText('il_grp_admin')."\n";
367 
368  }
369  else
370  {
371  $body .= $this->getLanguageText('il_grp_member')."\n";
372  }
373 
374  if($part->isAdmin($a_usr_id))
375  {
376  $body .= $this->getLanguageText('grp_notification').': ';
377 
378  if($part->isNotificationEnabled($a_usr_id))
379  {
380  $body .= $this->getLanguageText('grp_notify_on')."\n";
381  }
382  else
383  {
384  $body .= $this->getLanguageText('grp_notify_off')."\n";
385  }
386  }
387  return $body;
388  }
389 
390 }
391 ?>