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");
101 public function send()
110 if(!$ilSetting->get(
'forum_notification', 0))
112 $this->logger->debug(
'Forum notifications are globally disabled');
118 $this->logger->debug(
'No notification recipients, nothing to do');
122 $lng->loadLanguageModule(
'forum');
129 case self::TYPE_THREAD_DELETED:
139 $this->provider->getForumTitle(),
140 $this->provider->getThreadTitle()
145 $this->
appendBody(sprintf($this->
getLanguageText(
'thread_deleted_by'), $ilUser->getLogin(), $this->provider->getForumTitle()));
151 $this->
appendBody($this->
getLanguageText(
'content_deleted_thread') .
"\n------------------------------------------------------------\n");
164 if($this->provider->getPostCensored() == 1)
166 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
171 $this->
appendBody(strip_tags($pos_message) .
"\n");
173 $this->
appendBody(
"------------------------------------------------------------\n");
175 $this->
appendBody($this->getPermanentLink(self::PERMANENT_LINK_FORUM));
176 $this->
appendBody(ilMail::_getInstallationSignature());
182 case self::TYPE_POST_NEW:
192 $this->provider->getForumTitle(),
193 $this->provider->getThreadTitle()
204 $this->
appendBody($this->
getLanguageText(
'new_post').
": \n------------------------------------------------------------\n");
215 if($this->provider->getPostCensored() == 1)
217 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
222 $this->
appendBody(strip_tags($pos_message) .
"\n");
224 $this->
appendBody(
"------------------------------------------------------------\n");
229 $this->
appendBody(ilMail::_getInstallationSignature());
236 case self::TYPE_POST_ACTIVATION:
246 $this->provider->getForumTitle(),
247 $this->provider->getThreadTitle()
259 $this->
appendBody($this->
getLanguageText(
'new_post').
": \n------------------------------------------------------------\n");
270 if($this->provider->getPostCensored() == 1)
272 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
277 $this->
appendBody(strip_tags($pos_message) .
"\n");
279 $this->
appendBody(
"------------------------------------------------------------\n");
284 $this->
appendBody(ilMail::_getInstallationSignature());
290 case self::TYPE_POST_ANSWERED;
300 $this->provider->getForumTitle(),
301 $this->provider->getThreadTitle()
314 $this->
appendBody($this->
getLanguageText(
'new_post').
": \n------------------------------------------------------------\n");
325 if($this->provider->getPostCensored() == 1)
327 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
332 $this->
appendBody(strip_tags($pos_message) .
"\n");
334 $this->
appendBody(
"------------------------------------------------------------\n");
339 $this->
appendBody(ilMail::_getInstallationSignature());
346 case self::TYPE_POST_UPDATED:
356 $this->provider->getForumTitle(),
357 $this->provider->getThreadTitle()
362 $this->
appendBody(sprintf($this->
getLanguageText(
'post_updated_by'), $this->provider->getPostUpdateUserName($this->getLanguage()), $this->provider->getForumTitle()));
368 $this->
appendBody($this->
getLanguageText(
'content_post_updated') .
"\n------------------------------------------------------------\n");
379 if($this->provider->getPostCensored() == 1)
381 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
386 $this->
appendBody(strip_tags($pos_message) .
"\n");
388 $this->
appendBody(
"------------------------------------------------------------\n");
393 $this->
appendBody(ilMail::_getInstallationSignature());
399 case self::TYPE_POST_CENSORED:
409 $this->provider->getForumTitle(),
410 $this->provider->getThreadTitle()
415 $this->
appendBody(sprintf($this->
getLanguageText(
'post_censored_by'), $this->provider->getPostUpdateUserName($this->getLanguage()) ,$this->provider->getForumTitle()));
421 $this->
appendBody($this->
getLanguageText(
'content_censored_post') .
"\n------------------------------------------------------------\n");
432 if($this->provider->getPostCensored() == 1)
434 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
439 $this->
appendBody(strip_tags($pos_message) .
"\n");
441 $this->
appendBody(
"------------------------------------------------------------\n");
446 $this->
appendBody(ilMail::_getInstallationSignature());
451 case self::TYPE_POST_UNCENSORED:
461 $this->provider->getForumTitle(),
462 $this->provider->getThreadTitle()
467 $this->
appendBody(sprintf($this->
getLanguageText(
'post_uncensored_by'), $this->provider->getPostUpdateUserName($this->getLanguage())));
473 $this->
appendBody($this->
getLanguageText(
'forums_the_post') .
"\n------------------------------------------------------------\n");
485 $this->
appendBody(strip_tags($pos_message) .
"\n");
487 $this->
appendBody(
"------------------------------------------------------------\n");
492 $this->
appendBody(ilMail::_getInstallationSignature());
498 case self::TYPE_POST_DELETED:
508 $this->provider->getForumTitle(),
509 $this->provider->getThreadTitle()
514 $this->
appendBody(sprintf($this->
getLanguageText(
'post_deleted_by'), $ilUser->getLogin(), $this->provider->getForumTitle()));
520 $this->
appendBody($this->
getLanguageText(
'content_deleted_post') .
"\n------------------------------------------------------------\n");
533 if($this->provider->getPostCensored() == 1)
535 $this->
appendBody($this->provider->getCensorshipComment() .
"\n");
540 $this->
appendBody(strip_tags($pos_message) .
"\n");
542 $this->
appendBody(
"------------------------------------------------------------\n");
544 $this->
appendBody($this->getPermanentLink(self::PERMANENT_LINK_FORUM));
545 $this->
appendBody(ilMail::_getInstallationSignature());
563 parent::initLanguage($a_usr_id);
564 $this->
language->loadLanguageModule(
'forum');
587 private function getPermanentLink(
$type = self::PERMANENT_LINK_POST)
592 global $ilClientIniFile;
594 if(
$type == self::PERMANENT_LINK_FORUM)
596 $language_text = $this->
getLanguageText(
"forums_notification_show_frm");
597 $forum_parameters = $this->provider->getRefId();
601 $language_text = $this->
getLanguageText(
"forums_notification_show_post");
602 $forum_parameters = $this->provider->getRefId() .
"_" . $this->provider->getThreadId() .
"_" . $this->provider->getPostId();
605 $this->logger->debug(sprintf(
606 'Building permanent with parameters %s', $forum_parameters
611 $posting_link = sprintf($language_text,
612 ilUtil::_getHttpPath() .
"/goto.php?target=frm_" .$forum_parameters.
'&client_id=' . CLIENT_ID) .
"\n\n";
614 $posting_link .= sprintf($this->
getLanguageText(
"forums_notification_intro"),
615 $ilClientIniFile->readVariable(
"client",
"name"),
620 $posting_link = sprintf($language_text,
621 ilUtil::_getHttpPath() .
"/goto.php?target=frm_" .$forum_parameters.
'&client_id=' . CLIENT_ID) .
"\n\n";
623 $posting_link .= sprintf($this->
getLanguageText(
"forums_notification_intro"),
624 $ilClientIniFile->readVariable(
"client",
"name"),
628 $this->logger->debug(sprintf(
629 'Link built: %s', $posting_link
632 return $posting_link;
640 $pos_message = $this->provider->getPostMessage();
641 if(strip_tags($pos_message) != $pos_message)
643 $pos_message = preg_replace(
"/\n/i",
"", $pos_message);
644 $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i",
"\n", $pos_message);
645 $pos_message = preg_replace(
"/<p([^>]*)>/i",
"\n\n", $pos_message);
646 $pos_message = preg_replace(
"/<\/p([^>]*)>/i",
'', $pos_message);
649 return strip_tags($pos_message);
const PERMANENT_LINK_FORUM
getType()
Get notification type.
const TYPE_POST_ACTIVATION
getLanguageText($a_keyword)
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.
static formatDate(ilDateTime $date)
Format a date public.
Create styles array
The data for the language used.
Interface ilForumNotificationMailData.
getRecipients()
get array of recipients
appendBody($a_body)
Append body text.
Component logger with individual log levels by component id.
const TYPE_POST_UNCENSORED