ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
46 private $force_sending_mail = false;
47
48
52 public function __construct()
53 {
54 parent::__construct();
55 }
56
61 public function forceSendingMail($a_status)
62 {
63 $this->force_sending_mail = $a_status;
64 }
65
70 public function send()
71 {
72 if (
73 (int) $this->getRefId() &&
74 in_array($this->getType(), array(self::TYPE_ADMISSION_MEMBER))) {
75 $obj = ilObjectFactory::getInstanceByRefId((int) $this->getRefId());
76
77 if ($obj->getAutoNotification() == false) {
78 if (!$this->force_sending_mail) {
79 return false;
80 }
81 }
82 }
83
84 if (!$this->isNotificationTypeEnabled($this->getType())) {
85 return false;
86 }
87
88 // #11359
89 // parent::send();
90
91 switch ($this->getType()) {
93
94 foreach ($this->getRecipients() as $rcp) {
95 $this->initLanguage($rcp);
96 $this->initMail();
97 $this->setSubject(
98 sprintf($this->getLanguageText('crs_added_member'), $this->getObjectTitle(true))
99 );
100 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
101 $this->appendBody("\n\n");
102 $this->appendBody(
103 sprintf($this->getLanguageText('crs_added_member_body'), $this->getObjectTitle())
104 );
105 $this->appendBody("\n\n");
106 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
107 $this->appendBody("\n\n");
108 $this->appendBody($this->createPermanentLink());
109 $this->getMail()->appendInstallationSignature(true);
110
111 $this->sendMail(array($rcp), array('system'));
112 }
113 break;
114
115
117
118 foreach ($this->getRecipients() as $rcp) {
119 $this->initLanguage($rcp);
120 $this->initMail();
121 $this->setSubject(
122 sprintf($this->getLanguageText('crs_accept_subscriber'), $this->getObjectTitle(true))
123 );
124 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
125 $this->appendBody("\n\n");
126 $this->appendBody(
127 sprintf($this->getLanguageText('crs_accept_subscriber_body'), $this->getObjectTitle())
128 );
129 $this->appendBody("\n\n");
130 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
131 $this->appendBody("\n\n");
132 $this->appendBody($this->createPermanentLink());
133 $this->getMail()->appendInstallationSignature(true);
134
135 $this->sendMail(array($rcp), array('system'));
136 }
137 break;
138
140
141 foreach ($this->getRecipients() as $rcp) {
142 $this->initLanguage($rcp);
143 $this->initMail();
144 $this->setSubject(
145 sprintf($this->getLanguageText('crs_reject_subscriber'), $this->getObjectTitle(true))
146 );
147 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
148 $this->appendBody("\n\n");
149 $this->appendBody(
150 sprintf($this->getLanguageText('crs_reject_subscriber_body'), $this->getObjectTitle())
151 );
152
153 $this->getMail()->appendInstallationSignature(true);
154
155 $this->sendMail(array($rcp), array('system'));
156 }
157 break;
158
160 foreach ($this->getRecipients() as $rcp) {
161 $this->initLanguage($rcp);
162 $this->initMail();
163 $this->setSubject(
164 sprintf($this->getLanguageText('crs_status_changed'), $this->getObjectTitle(true))
165 );
166 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
167 $this->appendBody("\n\n");
168 $this->appendBody(
169 sprintf($this->getLanguageText('crs_status_changed_body'), $this->getObjectTitle())
170 );
171
172 $this->appendBody("\n\n");
173 $this->appendBody($this->createCourseStatus($rcp));
174
175 $this->appendBody("\n\n");
176 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
177 $this->appendBody("\n\n");
178 $this->appendBody($this->createPermanentLink());
179
180 $this->getMail()->appendInstallationSignature(true);
181
182 $this->sendMail(array($rcp), array('system'));
183 }
184 break;
185
186
188
189 foreach ($this->getRecipients() as $rcp) {
190 $this->initLanguage($rcp);
191 $this->initMail();
192 $this->setSubject(
193 sprintf($this->getLanguageText('crs_dismiss_member'), $this->getObjectTitle(true))
194 );
195 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
196 $this->appendBody("\n\n");
197 $this->appendBody(
198 sprintf($this->getLanguageText('crs_dismiss_member_body'), $this->getObjectTitle())
199 );
200 $this->getMail()->appendInstallationSignature(true);
201 $this->sendMail(array($rcp), array('system'));
202 }
203 break;
204
205
207
208 foreach ($this->getRecipients() as $rcp) {
209 $this->initLanguage($rcp);
210 $this->initMail();
211 $this->setSubject(
212 sprintf($this->getLanguageText('crs_blocked_member'), $this->getObjectTitle(true))
213 );
214 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
215 $this->appendBody("\n\n");
216 $this->appendBody(
217 sprintf($this->getLanguageText('crs_blocked_member_body'), $this->getObjectTitle())
218 );
219 $this->getMail()->appendInstallationSignature(true);
220 $this->sendMail(array($rcp), array('system'));
221 }
222 break;
223
225
226 foreach ($this->getRecipients() as $rcp) {
227 $this->initLanguage($rcp);
228 $this->initMail();
229 $this->setSubject(
230 sprintf($this->getLanguageText('crs_unblocked_member'), $this->getObjectTitle(true))
231 );
232 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
233 $this->appendBody("\n\n");
234 $this->appendBody(
235 sprintf($this->getLanguageText('crs_unblocked_member_body'), $this->getObjectTitle())
236 );
237
238 $this->appendBody("\n\n");
239 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
240 $this->appendBody("\n\n");
241 $this->appendBody($this->createPermanentLink());
242 $this->getMail()->appendInstallationSignature(true);
243
244 $this->sendMail(array($rcp), array('system'));
245 }
246 break;
247
249
250 foreach ($this->getRecipients() as $rcp) {
251 $this->initLanguage($rcp);
252 $this->initMail();
253 $this->setSubject(
254 sprintf($this->getLanguageText('crs_new_subscription'), $this->getObjectTitle(true))
255 );
256 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
257 $this->appendBody("\n\n");
258
260 $this->appendBody(
261 sprintf(
262 $this->getLanguageText('crs_new_subscription_body'),
263 $this->userToString($info['usr_id']),
264 $this->getObjectTitle()
265 )
266 );
267 $this->appendBody("\n\n");
268 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
269 $this->appendBody("\n\n");
270 $this->appendBody($this->createPermanentLink(array(), '_mem'));
271
272 $this->appendBody("\n\n");
273 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
274
275 $this->getMail()->appendInstallationSignature(true);
276 $this->sendMail(array($rcp), array('system'));
277 }
278 break;
279
281
282 foreach ($this->getRecipients() as $rcp) {
283 $this->initLanguage($rcp);
284 $this->initMail();
285 $this->setSubject(
286 sprintf($this->getLanguageText('crs_new_subscription_request'), $this->getObjectTitle(true))
287 );
288 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
289 $this->appendBody("\n\n");
290
292 $this->appendBody(
293 sprintf(
294 $this->getLanguageText('crs_new_subscription_request_body'),
295 $this->userToString($info['usr_id']),
296 $this->getObjectTitle()
297 )
298 );
299 $this->appendBody("\n\n");
300 $this->appendBody($this->getLanguageText('crs_new_subscription_request_body2'));
301 $this->appendBody("\n");
302 $this->appendBody($this->createPermanentLink(array(), '_mem'));
303
304 $this->appendBody("\n\n");
305 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
306
307 $this->getMail()->appendInstallationSignature(true);
308 $this->sendMail(array($rcp), array('system'));
309 }
310 break;
311
313
314 foreach ($this->getRecipients() as $rcp) {
315 $this->initLanguage($rcp);
316 $this->initMail();
317 $this->setSubject(
318 sprintf($this->getLanguageText('crs_cancel_subscription'), $this->getObjectTitle(true))
319 );
320 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
321 $this->appendBody("\n\n");
322
324 $this->appendBody(
325 sprintf(
326 $this->getLanguageText('crs_cancel_subscription_body'),
327 $this->userToString($info['usr_id']),
328 $this->getObjectTitle()
329 )
330 );
331 $this->appendBody("\n\n");
332 $this->appendBody($this->getLanguageText('crs_cancel_subscription_body2'));
333 $this->appendBody("\n\n");
334 $this->appendBody($this->createPermanentLink(array(), '_mem'));
335
336 $this->appendBody("\n\n");
337 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
338
339 $this->getMail()->appendInstallationSignature(true);
340 $this->sendMail(array($rcp), array('system'));
341 }
342 break;
343
345 foreach ($this->getRecipients() as $rcp) {
346 $this->initLanguage($rcp);
347 $this->initMail();
348 $this->setSubject(
349 sprintf($this->getLanguageText('crs_unsubscribe_member'), $this->getObjectTitle(true))
350 );
351 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
352 $this->appendBody("\n\n");
353 $this->appendBody(
354 sprintf($this->getLanguageText('crs_unsubscribe_member_body'), $this->getObjectTitle())
355 );
356 $this->appendBody("\n\n");
357 $this->appendBody($this->getLanguageText('crs_unsubscribe_member_explanation'));
358 $this->getMail()->appendInstallationSignature(true);
359 $this->sendMail(array($rcp), array('system'));
360 }
361 break;
362
364
365 foreach ($this->getRecipients() as $rcp) {
366 $this->initLanguage($rcp);
367 $this->initMail();
368 $this->setSubject(
369 sprintf($this->getLanguageText('crs_subscribe_member'), $this->getObjectTitle(true))
370 );
371 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
372 $this->appendBody("\n\n");
373 $this->appendBody(
374 sprintf($this->getLanguageText('crs_subscribe_member_body'), $this->getObjectTitle())
375 );
376
377 $this->appendBody("\n\n");
378 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
379 $this->appendBody("\n\n");
380 $this->appendBody($this->createPermanentLink());
381 $this->getMail()->appendInstallationSignature(true);
382
383 $this->sendMail(array($rcp), array('system'));
384 }
385 break;
386
388 foreach ($this->getRecipients() as $rcp) {
389 $this->initLanguage($rcp);
390 $this->initMail();
391 $this->setSubject(
392 sprintf($this->getLanguageText('crs_subscribe_wl'), $this->getObjectTitle(true))
393 );
394
395 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
396
398 $this->appendBody("\n\n");
399 $this->appendBody(
400 sprintf(
401 $this->getLanguageText('crs_subscribe_wl_body'),
402 $this->getObjectTitle(),
403 $info['position']
404 )
405 );
406 $this->getMail()->appendInstallationSignature(true);
407 $this->sendMail(array($rcp), array('system'));
408 }
409 break;
410 }
411 return true;
412 }
413
419 protected function initLanguage($a_usr_id)
420 {
421 parent::initLanguage($a_usr_id);
422 $this->getLanguage()->loadLanguageModule('crs');
423 }
424
430 protected function createCourseStatus($a_usr_id)
431 {
433
434 $body = $this->getLanguageText('crs_new_status') . "\n";
435 $body .= $this->getLanguageText('role') . ': ';
436
437
438 if ($part->isAdmin($a_usr_id)) {
439 $body .= $this->getLanguageText('crs_admin') . "\n";
440 } elseif ($part->isTutor($a_usr_id)) {
441 $body .= $this->getLanguageText('crs_tutor') . "\n";
442 } else {
443 $body .= $this->getLanguageText('crs_member') . "\n";
444 }
445
446 if ($part->isAdmin($a_usr_id) or $part->isTutor($a_usr_id)) {
447 $body .= $this->getLanguageText('crs_status') . ': ';
448
449 if ($part->isNotificationEnabled($a_usr_id)) {
450 $body .= $this->getLanguageText('crs_notify') . "\n";
451 } else {
452 $body .= $this->getLanguageText('crs_no_notify') . "\n";
453 }
454 } else {
455 $body .= $this->getLanguageText('crs_access') . ': ';
456
457 if ($part->isBlocked($a_usr_id)) {
458 $body .= $this->getLanguageText('crs_blocked') . "\n";
459 } else {
460 $body .= $this->getLanguageText('crs_unblocked') . "\n";
461 }
462 }
463
464 $body .= $this->getLanguageText('crs_passed') . ': ';
465
466 if ($part->hasPassed($a_usr_id)) {
467 $body .= $this->getLanguageText('yes');
468 } else {
469 $body .= $this->getLanguageText('no');
470 }
471 return $body;
472 }
473
482 {
483 global $ilSetting;
484
485 return
486 $this->force_sending_mail ||
487 $ilSetting->get('mail_crs_member_notification', true) ||
488 in_array($a_type, $this->permanent_enabled_notifications);
489 }
490}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
isNotificationTypeEnabled($a_type)
get setting "mail_crs_member_notification" and excludes types which are not affected by this setting ...
forceSendingMail($a_status)
Force sending mail independent from global 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, ilLanguage $a_language=null)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$info
Definition: index.php:5
global $ilSetting
Definition: privfeed.php:17
$a_type
Definition: workflow.php:92