ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4include_once './Services/Mail/classes/class.ilMailNotification.php';
5
13{
16
19
21
24
28
32
33
37 public function __construct()
38 {
39 parent::__construct();
40 }
41
46 public function send()
47 {
48 global $ilSetting;
49
50 if( (int) $this->getRefId() &&
51 in_array($this->getType(), array(self::TYPE_ADMISSION_MEMBER)) )
52 {
53 $obj = ilObjectFactory::getInstanceByRefId( (int) $this->getRefId() );
54
55 if( $obj->getAutoNotification() == false )
56 {
57 return false;
58 }
59 }
60
61 // #11359
62 // parent::send();
63
64 switch($this->getType())
65 {
67
68 // automatic mails about status change disabled
69 if(!$ilSetting->get('mail_crs_member_notification',true))
70 {
71 return;
72 }
73
74 foreach($this->getRecipients() as $rcp)
75 {
76 $this->initLanguage($rcp);
77 $this->initMail();
78 $this->setSubject(
79 sprintf($this->getLanguageText('crs_added_member'),$this->getObjectTitle(true))
80 );
81 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
82 $this->appendBody("\n\n");
83 $this->appendBody(
84 sprintf($this->getLanguageText('crs_added_member_body'),$this->getObjectTitle())
85 );
86 $this->appendBody("\n\n");
87 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
88 $this->appendBody("\n\n");
89 $this->appendBody($this->createPermanentLink());
90 $this->getMail()->appendInstallationSignature(true);
91
92 $this->sendMail(array($rcp),array('system'));
93 }
94 break;
95
96
98
99 foreach($this->getRecipients() as $rcp)
100 {
101 $this->initLanguage($rcp);
102 $this->initMail();
103 $this->setSubject(
104 sprintf($this->getLanguageText('crs_accept_subscriber'),$this->getObjectTitle(true))
105 );
106 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
107 $this->appendBody("\n\n");
108 $this->appendBody(
109 sprintf($this->getLanguageText('crs_accept_subscriber_body'),$this->getObjectTitle())
110 );
111 $this->appendBody("\n\n");
112 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
113 $this->appendBody("\n\n");
114 $this->appendBody($this->createPermanentLink());
115 $this->getMail()->appendInstallationSignature(true);
116
117 $this->sendMail(array($rcp),array('system'));
118 }
119 break;
120
122
123 foreach($this->getRecipients() as $rcp)
124 {
125 $this->initLanguage($rcp);
126 $this->initMail();
127 $this->setSubject(
128 sprintf($this->getLanguageText('crs_reject_subscriber'),$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_reject_subscriber_body'),$this->getObjectTitle())
134 );
135
136 $this->getMail()->appendInstallationSignature(true);
137
138 $this->sendMail(array($rcp),array('system'));
139 }
140 break;
141
143 foreach($this->getRecipients() as $rcp)
144 {
145 $this->initLanguage($rcp);
146 $this->initMail();
147 $this->setSubject(
148 sprintf($this->getLanguageText('crs_status_changed'),$this->getObjectTitle(true))
149 );
150 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
151 $this->appendBody("\n\n");
152 $this->appendBody(
153 sprintf($this->getLanguageText('crs_status_changed_body'),$this->getObjectTitle())
154 );
155
156 $this->appendBody("\n\n");
157 $this->appendBody($this->createCourseStatus($rcp));
158
159 $this->appendBody("\n\n");
160 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
161 $this->appendBody("\n\n");
162 $this->appendBody($this->createPermanentLink());
163
164 $this->getMail()->appendInstallationSignature(true);
165
166 $this->sendMail(array($rcp),array('system'));
167 }
168 break;
169
170
172
173 // automatic mails about status change disabled
174 if(!$ilSetting->get('mail_crs_member_notification',true))
175 {
176 return;
177 }
178
179 foreach($this->getRecipients() as $rcp)
180 {
181 $this->initLanguage($rcp);
182 $this->initMail();
183 $this->setSubject(
184 sprintf($this->getLanguageText('crs_dismiss_member'),$this->getObjectTitle(true))
185 );
186 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
187 $this->appendBody("\n\n");
188 $this->appendBody(
189 sprintf($this->getLanguageText('crs_dismiss_member_body'),$this->getObjectTitle())
190 );
191 $this->getMail()->appendInstallationSignature(true);
192 $this->sendMail(array($rcp),array('system'));
193 }
194 break;
195
196
198
199 foreach($this->getRecipients() as $rcp)
200 {
201 $this->initLanguage($rcp);
202 $this->initMail();
203 $this->setSubject(
204 sprintf($this->getLanguageText('crs_blocked_member'),$this->getObjectTitle(true))
205 );
206 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
207 $this->appendBody("\n\n");
208 $this->appendBody(
209 sprintf($this->getLanguageText('crs_blocked_member_body'),$this->getObjectTitle())
210 );
211 $this->getMail()->appendInstallationSignature(true);
212 $this->sendMail(array($rcp),array('system'));
213 }
214 break;
215
217
218 foreach($this->getRecipients() as $rcp)
219 {
220 $this->initLanguage($rcp);
221 $this->initMail();
222 $this->setSubject(
223 sprintf($this->getLanguageText('crs_unblocked_member'),$this->getObjectTitle(true))
224 );
225 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
226 $this->appendBody("\n\n");
227 $this->appendBody(
228 sprintf($this->getLanguageText('crs_unblocked_member_body'),$this->getObjectTitle())
229 );
230
231 $this->appendBody("\n\n");
232 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
233 $this->appendBody("\n\n");
234 $this->appendBody($this->createPermanentLink());
235 $this->getMail()->appendInstallationSignature(true);
236
237 $this->sendMail(array($rcp),array('system'));
238 }
239 break;
240
242
243 foreach($this->getRecipients() as $rcp)
244 {
245 $this->initLanguage($rcp);
246 $this->initMail();
247 $this->setSubject(
248 sprintf($this->getLanguageText('crs_new_subscription'),$this->getObjectTitle(true))
249 );
250 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
251 $this->appendBody("\n\n");
252
253 $info = $this->getAdditionalInformation();
254 $this->appendBody(
255 sprintf($this->getLanguageText('crs_new_subscription_body'),
256 $this->userToString($info['usr_id']),
257 $this->getObjectTitle()
258 )
259 );
260 $this->appendBody("\n\n");
261 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
262 $this->appendBody("\n\n");
263 $this->appendBody($this->createPermanentLink(array(),'_mem'));
264
265 $this->appendBody("\n\n");
266 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
267
268 $this->getMail()->appendInstallationSignature(true);
269 $this->sendMail(array($rcp),array('system'));
270 }
271 break;
272
274
275 foreach($this->getRecipients() as $rcp)
276 {
277 $this->initLanguage($rcp);
278 $this->initMail();
279 $this->setSubject(
280 sprintf($this->getLanguageText('crs_new_subscription_request'),$this->getObjectTitle(true))
281 );
282 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
283 $this->appendBody("\n\n");
284
285 $info = $this->getAdditionalInformation();
286 $this->appendBody(
287 sprintf($this->getLanguageText('crs_new_subscription_request_body'),
288 $this->userToString($info['usr_id']),
289 $this->getObjectTitle()
290 )
291 );
292 $this->appendBody("\n\n");
293 $this->appendBody($this->getLanguageText('crs_new_subscription_request_body2'));
294 $this->appendBody("\n");
295 $this->appendBody($this->createPermanentLink(array(),'_mem'));
296
297 $this->appendBody("\n\n");
298 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
299
300 $this->getMail()->appendInstallationSignature(true);
301 $this->sendMail(array($rcp),array('system'));
302 }
303 break;
304
306
307 foreach($this->getRecipients() as $rcp)
308 {
309 $this->initLanguage($rcp);
310 $this->initMail();
311 $this->setSubject(
312 sprintf($this->getLanguageText('crs_cancel_subscription'),$this->getObjectTitle(true))
313 );
314 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
315 $this->appendBody("\n\n");
316
317 $info = $this->getAdditionalInformation();
318 $this->appendBody(
319 sprintf($this->getLanguageText('crs_cancel_subscription_body'),
320 $this->userToString($info['usr_id']),
321 $this->getObjectTitle()
322 )
323 );
324 $this->appendBody("\n\n");
325 $this->appendBody($this->getLanguageText('crs_cancel_subscription_body2'));
326 $this->appendBody("\n\n");
327 $this->appendBody($this->createPermanentLink(array(),'_mem'));
328
329 $this->appendBody("\n\n");
330 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
331
332 $this->getMail()->appendInstallationSignature(true);
333 $this->sendMail(array($rcp),array('system'));
334 }
335 break;
336
338 foreach($this->getRecipients() as $rcp)
339 {
340 $this->initLanguage($rcp);
341 $this->initMail();
342 $this->setSubject(
343 sprintf($this->getLanguageText('crs_unsubscribe_member'),$this->getObjectTitle(true))
344 );
345 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
346 $this->appendBody("\n\n");
347 $this->appendBody(
348 sprintf($this->getLanguageText('crs_unsubscribe_member_body'),$this->getObjectTitle())
349 );
350 $this->appendBody("\n\n");
351 $this->appendBody($this->getLanguageText('crs_unsubscribe_member_explanation'));
352 $this->getMail()->appendInstallationSignature(true);
353 $this->sendMail(array($rcp),array('system'));
354 }
355 break;
356
358
359 foreach($this->getRecipients() as $rcp)
360 {
361 $this->initLanguage($rcp);
362 $this->initMail();
363 $this->setSubject(
364 sprintf($this->getLanguageText('crs_subscribe_member'),$this->getObjectTitle(true))
365 );
366 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
367 $this->appendBody("\n\n");
368 $this->appendBody(
369 sprintf($this->getLanguageText('crs_subscribe_member_body'),$this->getObjectTitle())
370 );
371
372 $this->appendBody("\n\n");
373 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
374 $this->appendBody("\n\n");
375 $this->appendBody($this->createPermanentLink());
376 $this->getMail()->appendInstallationSignature(true);
377
378 $this->sendMail(array($rcp),array('system'));
379 }
380 break;
381
383 foreach($this->getRecipients() as $rcp)
384 {
385 $this->initLanguage($rcp);
386 $this->initMail();
387 $this->setSubject(
388 sprintf($this->getLanguageText('crs_subscribe_wl'),$this->getObjectTitle(true))
389 );
390
391 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
392
393 $info = $this->getAdditionalInformation();
394 $this->appendBody("\n\n");
395 $this->appendBody(
396 sprintf($this->getLanguageText('crs_subscribe_wl_body'),
397 $this->getObjectTitle(),
398 $info['position']
399 )
400 );
401 $this->getMail()->appendInstallationSignature(true);
402 $this->sendMail(array($rcp),array('system'));
403 }
404 break;
405 }
406 return true;
407 }
408
414 protected function initLanguage($a_usr_id)
415 {
416 parent::initLanguage($a_usr_id);
417 $this->getLanguage()->loadLanguageModule('crs');
418 }
419
425 protected function createCourseStatus($a_usr_id)
426 {
428
429 $body = $this->getLanguageText('crs_new_status')."\n";
430 $body .= $this->getLanguageText('role').': ';
431
432
433 if($part->isAdmin($a_usr_id))
434 {
435 $body .= $this->getLanguageText('crs_admin')."\n";
436
437 }
438 elseif($part->isTutor($a_usr_id))
439 {
440 $body .= $this->getLanguageText('crs_tutor')."\n";
441 }
442 else
443 {
444 $body .= $this->getLanguageText('crs_member')."\n";
445 }
446
447 if($part->isAdmin($a_usr_id) or $part->isTutor($a_usr_id))
448 {
449 $body .= $this->getLanguageText('crs_status').': ';
450
451 if($part->isNotificationEnabled($a_usr_id))
452 {
453 $body .= $this->getLanguageText('crs_notify')."\n";
454 }
455 else
456 {
457 $body .= $this->getLanguageText('crs_no_notify')."\n";
458 }
459 }
460 else
461 {
462 $body .= $this->getLanguageText('crs_access').': ';
463
464 if($part->isBlocked($a_usr_id))
465 {
466 $body .= $this->getLanguageText('crs_blocked')."\n";
467 }
468 else
469 {
470 $body .= $this->getLanguageText('crs_unblocked')."\n";
471 }
472 }
473
474 $body .= $this->getLanguageText('crs_passed').': ';
475
476 if($part->hasPassed($a_usr_id))
477 {
478 $body .= $this->getLanguageText('yes');
479 }
480 else
481 {
482 $body .= $this->getLanguageText('no');
483 }
484 return $body;
485 }
486}
487?>
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
userToString($a_usr_id)
Utility function.
getType()
Get notification type.
getLanguage()
get language object
sendMail($a_rcp, $a_type, $a_parse_recipients=true)
Send Mail.
getAdditionalInformation()
Get additional information for generating notification mails.
setBody($a_body)
Set mail body.
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
Get object title.
getLanguageText($a_keyword)
Replace new lines.
setSubject($a_subject)
Set mail subject.
createPermanentLink($a_params=array(), $a_append='')
Create a permanent link for an object.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
global $ilSetting
Definition: privfeed.php:40