ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
14 // v Notifications affect members & co. v
17
20
22
25
29
30 // v Notifications affect admins v
34
41 self::TYPE_NOTIFICATION_REGISTRATION,
42 self::TYPE_NOTIFICATION_REGISTRATION_REQUEST,
43 self::TYPE_NOTIFICATION_UNSUBSCRIBE
44 );
45
49 public function __construct()
50 {
51 parent::__construct();
52 }
53
58 public function send()
59 {
60 if( (int) $this->getRefId() &&
61 in_array($this->getType(), array(self::TYPE_ADMISSION_MEMBER)) )
62 {
63 $obj = ilObjectFactory::getInstanceByRefId( (int) $this->getRefId() );
64
65 if( $obj->getAutoNotification() == false )
66 {
67 return false;
68 }
69 }
70
71 if(!$this->isNotificationTypeEnabled($this->getType()))
72 {
73 return false;
74 }
75
76 // #11359
77 // parent::send();
78
79 switch($this->getType())
80 {
82
83 foreach($this->getRecipients() as $rcp)
84 {
85 $this->initLanguage($rcp);
86 $this->initMail();
87 $this->setSubject(
88 sprintf($this->getLanguageText('crs_added_member'),$this->getObjectTitle(true))
89 );
90 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
91 $this->appendBody("\n\n");
92 $this->appendBody(
93 sprintf($this->getLanguageText('crs_added_member_body'),$this->getObjectTitle())
94 );
95 $this->appendBody("\n\n");
96 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
97 $this->appendBody("\n\n");
98 $this->appendBody($this->createPermanentLink());
99 $this->getMail()->appendInstallationSignature(true);
100
101 $this->sendMail(array($rcp),array('system'));
102 }
103 break;
104
105
107
108 foreach($this->getRecipients() as $rcp)
109 {
110 $this->initLanguage($rcp);
111 $this->initMail();
112 $this->setSubject(
113 sprintf($this->getLanguageText('crs_accept_subscriber'),$this->getObjectTitle(true))
114 );
115 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
116 $this->appendBody("\n\n");
117 $this->appendBody(
118 sprintf($this->getLanguageText('crs_accept_subscriber_body'),$this->getObjectTitle())
119 );
120 $this->appendBody("\n\n");
121 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
122 $this->appendBody("\n\n");
123 $this->appendBody($this->createPermanentLink());
124 $this->getMail()->appendInstallationSignature(true);
125
126 $this->sendMail(array($rcp),array('system'));
127 }
128 break;
129
131
132 foreach($this->getRecipients() as $rcp)
133 {
134 $this->initLanguage($rcp);
135 $this->initMail();
136 $this->setSubject(
137 sprintf($this->getLanguageText('crs_reject_subscriber'),$this->getObjectTitle(true))
138 );
139 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
140 $this->appendBody("\n\n");
141 $this->appendBody(
142 sprintf($this->getLanguageText('crs_reject_subscriber_body'),$this->getObjectTitle())
143 );
144
145 $this->getMail()->appendInstallationSignature(true);
146
147 $this->sendMail(array($rcp),array('system'));
148 }
149 break;
150
152 foreach($this->getRecipients() as $rcp)
153 {
154 $this->initLanguage($rcp);
155 $this->initMail();
156 $this->setSubject(
157 sprintf($this->getLanguageText('crs_status_changed'),$this->getObjectTitle(true))
158 );
159 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
160 $this->appendBody("\n\n");
161 $this->appendBody(
162 sprintf($this->getLanguageText('crs_status_changed_body'),$this->getObjectTitle())
163 );
164
165 $this->appendBody("\n\n");
166 $this->appendBody($this->createCourseStatus($rcp));
167
168 $this->appendBody("\n\n");
169 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
170 $this->appendBody("\n\n");
171 $this->appendBody($this->createPermanentLink());
172
173 $this->getMail()->appendInstallationSignature(true);
174
175 $this->sendMail(array($rcp),array('system'));
176 }
177 break;
178
179
181
182 foreach($this->getRecipients() as $rcp)
183 {
184 $this->initLanguage($rcp);
185 $this->initMail();
186 $this->setSubject(
187 sprintf($this->getLanguageText('crs_dismiss_member'),$this->getObjectTitle(true))
188 );
189 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
190 $this->appendBody("\n\n");
191 $this->appendBody(
192 sprintf($this->getLanguageText('crs_dismiss_member_body'),$this->getObjectTitle())
193 );
194 $this->getMail()->appendInstallationSignature(true);
195 $this->sendMail(array($rcp),array('system'));
196 }
197 break;
198
199
201
202 foreach($this->getRecipients() as $rcp)
203 {
204 $this->initLanguage($rcp);
205 $this->initMail();
206 $this->setSubject(
207 sprintf($this->getLanguageText('crs_blocked_member'),$this->getObjectTitle(true))
208 );
209 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
210 $this->appendBody("\n\n");
211 $this->appendBody(
212 sprintf($this->getLanguageText('crs_blocked_member_body'),$this->getObjectTitle())
213 );
214 $this->getMail()->appendInstallationSignature(true);
215 $this->sendMail(array($rcp),array('system'));
216 }
217 break;
218
220
221 foreach($this->getRecipients() as $rcp)
222 {
223 $this->initLanguage($rcp);
224 $this->initMail();
225 $this->setSubject(
226 sprintf($this->getLanguageText('crs_unblocked_member'),$this->getObjectTitle(true))
227 );
228 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
229 $this->appendBody("\n\n");
230 $this->appendBody(
231 sprintf($this->getLanguageText('crs_unblocked_member_body'),$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());
238 $this->getMail()->appendInstallationSignature(true);
239
240 $this->sendMail(array($rcp),array('system'));
241 }
242 break;
243
245
246 foreach($this->getRecipients() as $rcp)
247 {
248 $this->initLanguage($rcp);
249 $this->initMail();
250 $this->setSubject(
251 sprintf($this->getLanguageText('crs_new_subscription'),$this->getObjectTitle(true))
252 );
253 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
254 $this->appendBody("\n\n");
255
257 $this->appendBody(
258 sprintf($this->getLanguageText('crs_new_subscription_body'),
259 $this->userToString($info['usr_id']),
260 $this->getObjectTitle()
261 )
262 );
263 $this->appendBody("\n\n");
264 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
265 $this->appendBody("\n\n");
266 $this->appendBody($this->createPermanentLink(array(),'_mem'));
267
268 $this->appendBody("\n\n");
269 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
270
271 $this->getMail()->appendInstallationSignature(true);
272 $this->sendMail(array($rcp),array('system'));
273 }
274 break;
275
277
278 foreach($this->getRecipients() as $rcp)
279 {
280 $this->initLanguage($rcp);
281 $this->initMail();
282 $this->setSubject(
283 sprintf($this->getLanguageText('crs_new_subscription_request'),$this->getObjectTitle(true))
284 );
285 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
286 $this->appendBody("\n\n");
287
289 $this->appendBody(
290 sprintf($this->getLanguageText('crs_new_subscription_request_body'),
291 $this->userToString($info['usr_id']),
292 $this->getObjectTitle()
293 )
294 );
295 $this->appendBody("\n\n");
296 $this->appendBody($this->getLanguageText('crs_new_subscription_request_body2'));
297 $this->appendBody("\n");
298 $this->appendBody($this->createPermanentLink(array(),'_mem'));
299
300 $this->appendBody("\n\n");
301 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
302
303 $this->getMail()->appendInstallationSignature(true);
304 $this->sendMail(array($rcp),array('system'));
305 }
306 break;
307
309
310 foreach($this->getRecipients() as $rcp)
311 {
312 $this->initLanguage($rcp);
313 $this->initMail();
314 $this->setSubject(
315 sprintf($this->getLanguageText('crs_cancel_subscription'),$this->getObjectTitle(true))
316 );
317 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
318 $this->appendBody("\n\n");
319
321 $this->appendBody(
322 sprintf($this->getLanguageText('crs_cancel_subscription_body'),
323 $this->userToString($info['usr_id']),
324 $this->getObjectTitle()
325 )
326 );
327 $this->appendBody("\n\n");
328 $this->appendBody($this->getLanguageText('crs_cancel_subscription_body2'));
329 $this->appendBody("\n\n");
330 $this->appendBody($this->createPermanentLink(array(),'_mem'));
331
332 $this->appendBody("\n\n");
333 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
334
335 $this->getMail()->appendInstallationSignature(true);
336 $this->sendMail(array($rcp),array('system'));
337 }
338 break;
339
341 foreach($this->getRecipients() as $rcp)
342 {
343 $this->initLanguage($rcp);
344 $this->initMail();
345 $this->setSubject(
346 sprintf($this->getLanguageText('crs_unsubscribe_member'),$this->getObjectTitle(true))
347 );
348 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
349 $this->appendBody("\n\n");
350 $this->appendBody(
351 sprintf($this->getLanguageText('crs_unsubscribe_member_body'),$this->getObjectTitle())
352 );
353 $this->appendBody("\n\n");
354 $this->appendBody($this->getLanguageText('crs_unsubscribe_member_explanation'));
355 $this->getMail()->appendInstallationSignature(true);
356 $this->sendMail(array($rcp),array('system'));
357 }
358 break;
359
361
362 foreach($this->getRecipients() as $rcp)
363 {
364 $this->initLanguage($rcp);
365 $this->initMail();
366 $this->setSubject(
367 sprintf($this->getLanguageText('crs_subscribe_member'),$this->getObjectTitle(true))
368 );
369 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
370 $this->appendBody("\n\n");
371 $this->appendBody(
372 sprintf($this->getLanguageText('crs_subscribe_member_body'),$this->getObjectTitle())
373 );
374
375 $this->appendBody("\n\n");
376 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
377 $this->appendBody("\n\n");
378 $this->appendBody($this->createPermanentLink());
379 $this->getMail()->appendInstallationSignature(true);
380
381 $this->sendMail(array($rcp),array('system'));
382 }
383 break;
384
386 foreach($this->getRecipients() as $rcp)
387 {
388 $this->initLanguage($rcp);
389 $this->initMail();
390 $this->setSubject(
391 sprintf($this->getLanguageText('crs_subscribe_wl'),$this->getObjectTitle(true))
392 );
393
394 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
395
397 $this->appendBody("\n\n");
398 $this->appendBody(
399 sprintf($this->getLanguageText('crs_subscribe_wl_body'),
400 $this->getObjectTitle(),
401 $info['position']
402 )
403 );
404 $this->getMail()->appendInstallationSignature(true);
405 $this->sendMail(array($rcp),array('system'));
406 }
407 break;
408 }
409 return true;
410 }
411
417 protected function initLanguage($a_usr_id)
418 {
419 parent::initLanguage($a_usr_id);
420 $this->getLanguage()->loadLanguageModule('crs');
421 }
422
428 protected function createCourseStatus($a_usr_id)
429 {
431
432 $body = $this->getLanguageText('crs_new_status')."\n";
433 $body .= $this->getLanguageText('role').': ';
434
435
436 if($part->isAdmin($a_usr_id))
437 {
438 $body .= $this->getLanguageText('crs_admin')."\n";
439
440 }
441 elseif($part->isTutor($a_usr_id))
442 {
443 $body .= $this->getLanguageText('crs_tutor')."\n";
444 }
445 else
446 {
447 $body .= $this->getLanguageText('crs_member')."\n";
448 }
449
450 if($part->isAdmin($a_usr_id) or $part->isTutor($a_usr_id))
451 {
452 $body .= $this->getLanguageText('crs_status').': ';
453
454 if($part->isNotificationEnabled($a_usr_id))
455 {
456 $body .= $this->getLanguageText('crs_notify')."\n";
457 }
458 else
459 {
460 $body .= $this->getLanguageText('crs_no_notify')."\n";
461 }
462 }
463 else
464 {
465 $body .= $this->getLanguageText('crs_access').': ';
466
467 if($part->isBlocked($a_usr_id))
468 {
469 $body .= $this->getLanguageText('crs_blocked')."\n";
470 }
471 else
472 {
473 $body .= $this->getLanguageText('crs_unblocked')."\n";
474 }
475 }
476
477 $body .= $this->getLanguageText('crs_passed').': ';
478
479 if($part->hasPassed($a_usr_id))
480 {
481 $body .= $this->getLanguageText('yes');
482 }
483 else
484 {
485 $body .= $this->getLanguageText('no');
486 }
487 return $body;
488 }
489
497 protected function isNotificationTypeEnabled($a_type)
498 {
499 global $ilSetting;
500
501 return $ilSetting->get('mail_crs_member_notification',true) || in_array($a_type, $this->permanent_enabled_notifications);
502 }
503}
504?>
isNotificationTypeEnabled($a_type)
get setting "mail_crs_member_notification" and excludes types which are not affected by this setting ...
$permanent_enabled_notifications
Notifications which are not affected by "mail_crs_member_notification" setting because they addresses...
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
getType()
Get notification type.
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
createPermanentLink($a_params=array(), $a_append='')
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
$info
Definition: example_052.php:80
global $ilSetting
Definition: privfeed.php:40