4 include_once
'./Services/Mail/classes/class.ilMailNotification.php';
48 parent::__construct(
false);
58 $mail = parent::initMail();
59 $this->logger->debug(
'Initialized mail service');
68 $this->logger->debug(
'Delegating notification transport to mail service ...');
69 parent::sendMail($a_rcp,
$a_type, $a_parse_recipients);
70 $this->logger->debug(
'Notification transport delegated');
78 $value = parent::setSubject($a_subject);
79 $this->logger->debug(sprintf(
'Setting subject to: %s', $a_subject));
88 if (count($this->provider->getAttachments()) > 0) {
89 $this->logger->debug(
'Adding attachments ...');
90 foreach ($this->provider->getAttachments() as $attachment) {
93 $this->
appendBody(
"\n------------------------------------------------------------\n");
105 $lng = $DIC->language();
107 if (!
$ilSetting->get(
'forum_notification', 0)) {
108 $this->logger->debug(
'Forum notifications are globally disabled');
113 $this->logger->debug(
'No notification recipients, nothing to do');
117 $lng->loadLanguageModule(
'forum');
123 case self::TYPE_THREAD_DELETED:
132 $this->provider->getForumTitle(),
133 $this->provider->getThreadTitle()
138 $this->
appendBody(sprintf($this->
getLanguageText(
'thread_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle()));
144 $this->
appendBody($this->
getLanguageText(
'content_deleted_thread') .
"\n------------------------------------------------------------\n");
157 if ($this->provider->getPostCensored() == 1) {
158 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
161 $this->
appendBody(strip_tags($pos_message) .
"\n");
163 $this->
appendBody(
"------------------------------------------------------------\n");
172 case self::TYPE_POST_NEW:
181 $this->provider->getForumTitle(),
182 $this->provider->getThreadTitle()
193 $this->
appendBody($this->
getLanguageText(
'new_post') .
": \n------------------------------------------------------------\n");
204 if ($this->provider->getPostCensored() == 1) {
205 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
208 $this->
appendBody(strip_tags($pos_message) .
"\n");
210 $this->
appendBody(
"------------------------------------------------------------\n");
221 case self::TYPE_POST_ACTIVATION:
230 $this->provider->getForumTitle(),
231 $this->provider->getThreadTitle()
243 $this->
appendBody($this->
getLanguageText(
'new_post') .
": \n------------------------------------------------------------\n");
254 if ($this->provider->getPostCensored() == 1) {
255 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
258 $this->
appendBody(strip_tags($pos_message) .
"\n");
260 $this->
appendBody(
"------------------------------------------------------------\n");
271 case self::TYPE_POST_ANSWERED:
280 $this->provider->getForumTitle(),
281 $this->provider->getThreadTitle()
294 $this->
appendBody($this->
getLanguageText(
'new_post') .
": \n------------------------------------------------------------\n");
305 if ($this->provider->getPostCensored() == 1) {
306 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
309 $this->
appendBody(strip_tags($pos_message) .
"\n");
311 $this->
appendBody(
"------------------------------------------------------------\n");
322 case self::TYPE_POST_UPDATED:
331 $this->provider->getForumTitle(),
332 $this->provider->getThreadTitle()
337 $this->
appendBody(sprintf($this->
getLanguageText(
'post_updated_by'), $this->provider->getPostUpdateUserName($this->getLanguage()), $this->provider->getForumTitle()));
343 $this->
appendBody($this->
getLanguageText(
'content_post_updated') .
"\n------------------------------------------------------------\n");
354 if ($this->provider->getPostCensored() == 1) {
355 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
358 $this->
appendBody(strip_tags($pos_message) .
"\n");
360 $this->
appendBody(
"------------------------------------------------------------\n");
371 case self::TYPE_POST_CENSORED:
380 $this->provider->getForumTitle(),
381 $this->provider->getThreadTitle()
386 $this->
appendBody(sprintf($this->
getLanguageText(
'post_censored_by'), $this->provider->getPostUpdateUserName($this->getLanguage()), $this->provider->getForumTitle()));
392 $this->
appendBody($this->
getLanguageText(
'content_censored_post') .
"\n------------------------------------------------------------\n");
403 if ($this->provider->getPostCensored() == 1) {
404 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
407 $this->
appendBody(strip_tags($pos_message) .
"\n");
409 $this->
appendBody(
"------------------------------------------------------------\n");
419 case self::TYPE_POST_UNCENSORED:
428 $this->provider->getForumTitle(),
429 $this->provider->getThreadTitle()
434 $this->
appendBody(sprintf($this->
getLanguageText(
'post_uncensored_by'), $this->provider->getPostUpdateUserName($this->getLanguage())));
440 $this->
appendBody($this->
getLanguageText(
'forums_the_post') .
"\n------------------------------------------------------------\n");
452 $this->
appendBody(strip_tags($pos_message) .
"\n");
454 $this->
appendBody(
"------------------------------------------------------------\n");
465 case self::TYPE_POST_DELETED:
474 $this->provider->getForumTitle(),
475 $this->provider->getThreadTitle()
480 $this->
appendBody(sprintf($this->
getLanguageText(
'post_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle()));
486 $this->
appendBody($this->
getLanguageText(
'content_deleted_post') .
"\n------------------------------------------------------------\n");
499 if ($this->provider->getPostCensored() == 1) {
500 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
503 $this->
appendBody(strip_tags($pos_message) .
"\n");
505 $this->
appendBody(
"------------------------------------------------------------\n");
526 parent::initLanguage($a_usr_id);
527 $this->language->loadLanguageModule(
'forum');
553 $ilClientIniFile = $DIC[
'ilClientIniFile'];
555 if (
$type == self::PERMANENT_LINK_FORUM) {
556 $language_text = $this->
getLanguageText(
"forums_notification_show_frm");
557 $forum_parameters = $this->provider->getRefId();
559 $language_text = $this->
getLanguageText(
"forums_notification_show_post");
560 $forum_parameters = $this->provider->getRefId() .
"_" . $this->provider->getThreadId() .
"_" . $this->provider->getPostId();
563 $this->logger->debug(sprintf(
564 'Building permanent with parameters %s',
569 $posting_link = sprintf(
571 ilUtil::_getHttpPath() .
"/goto.php?target=frm_" . $forum_parameters .
'&client_id=' . CLIENT_ID
574 $posting_link .= sprintf(
576 $ilClientIniFile->readVariable(
"client",
"name"),
580 $posting_link = sprintf(
582 ilUtil::_getHttpPath() .
"/goto.php?target=frm_" . $forum_parameters .
'&client_id=' . CLIENT_ID
585 $posting_link .= sprintf(
587 $ilClientIniFile->readVariable(
"client",
"name"),
592 $this->logger->debug(sprintf(
597 return $posting_link;
605 $pos_message = $this->provider->getPostMessage();
606 if (strip_tags($pos_message) != $pos_message) {
607 $pos_message = preg_replace(
"/\n/i",
"", $pos_message);
608 $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i",
"\n", $pos_message);
609 $pos_message = preg_replace(
"/<p([^>]*)>/i",
"\n\n", $pos_message);
610 $pos_message = preg_replace(
"/<\/p([^>]*)>/i",
'', $pos_message);
613 return strip_tags($pos_message);
const PERMANENT_LINK_FORUM
getType()
Get notification type.
const TYPE_POST_ACTIVATION
getLanguageText($a_keyword)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
setAttachments($a_att)
Set attachments.
const PERMANENT_LINK_POST
static setUseRelativeDates($a_status)
set use relative dates
__construct(ilForumNotificationMailData $provider, \ilLogger $logger)
ilForumMailNotification constructor.
const TYPE_THREAD_DELETED
setIsCronjob($is_cronjob)
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
static useRelativeDates()
check if relative dates are used
static setLanguage($a_lng)
set language
Base class for course/group mail notifications.
Create styles array
The data for the language used.
Interface ilForumNotificationMailData.
getRecipients()
get array of recipients
getPermanentLink($type=self::PERMANENT_LINK_POST)
appendBody($a_body)
Append body text.
Component logger with individual log levels by component id.
const TYPE_POST_UNCENSORED
static _getInstallationSignature()
static getSalutation($a_usr_id, ilLanguage $a_language=null)