46        parent::__construct(
false);
 
   56        $mail = parent::initMail();
 
   57        $this->logger->debug(
'Initialized mail service');
 
   66        $this->logger->debug(sprintf(
 
   67            'Delegating notification transport to mail service for recipients: %s',
 
   70        parent::sendMail($a_rcp, 
$a_type, $a_parse_recipients);
 
   71        $this->logger->debug(
'Notification transport delegated');
 
   79        $value = parent::setSubject($a_subject);
 
   80        $this->logger->debug(sprintf(
'Setting subject to: %s', $a_subject));
 
   89        if (count($this->provider->getAttachments()) > 0) {
 
   90            $this->logger->debug(
'Adding attachments ...');
 
   91            foreach ($this->provider->getAttachments() as $attachment) {
 
   94            $this->
appendBody(
"\n------------------------------------------------------------\n");
 
  108        if (!
$ilSetting->get(
'forum_notification', 0)) {
 
  109            $this->logger->debug(
'Forum notifications are globally disabled');
 
  114            $this->logger->debug(
'No notification recipients, nothing to do');
 
  118        $lng->loadLanguageModule(
'forum');
 
  127                    $customText = sprintf($this->
getLanguageText(
'thread_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle());
 
  135                    $customText = sprintf($this->
getLanguageText(
'frm_noti_new_post'), $this->provider->getForumTitle());
 
  159                    $customText = sprintf($this->
getLanguageText(
'post_updated_by'), $this->provider->getPostUpdateUserName($this->getLanguage()), $this->provider->getForumTitle());
 
  160                    $date = $this->provider->getPostUpdate();
 
  161                    $this->
sendMailWithAttachments(
'frm_noti_subject_upt_post', (
int) $rcp, (
string) $customText, 
'content_post_updated', $date);
 
  168                    $customText = sprintf($this->
getLanguageText(
'post_censored_by'), $this->provider->getPostUpdateUserName($this->getLanguage()), $this->provider->getForumTitle());
 
  169                    $date = $this->provider->getPostCensoredDate();
 
  170                    $this->
sendMailWithAttachments(
'frm_noti_subject_cens_post', (
int) $rcp, (
string) $customText, 
'content_censored_post', $date);
 
  177                    $customText = sprintf($this->
getLanguageText(
'post_uncensored_by'), $this->provider->getPostUpdateUserName($this->getLanguage()));
 
  178                    $date = $this->provider->getPostCensoredDate();
 
  179                    $this->
sendMailWithAttachments(
'frm_noti_subject_uncens_post', (
int) $rcp, (
string) $customText, 
'forums_the_post', $date);
 
  186                    $customText = sprintf($this->
getLanguageText(
'post_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle());
 
  203        parent::initLanguage($a_usr_id);
 
  204        $this->language->loadLanguageModule(
'forum');
 
  230        $ilClientIniFile = 
$DIC[
'ilClientIniFile'];
 
  232        if (
$type == self::PERMANENT_LINK_FORUM) {
 
  233            $language_text = $this->
getLanguageText(
"forums_notification_show_frm");
 
  234            $forum_parameters = $this->provider->getRefId();
 
  236            $language_text = $this->
getLanguageText(
"forums_notification_show_post");
 
  237            $forum_parameters = $this->provider->getRefId() . 
"_" . $this->provider->getThreadId() . 
"_" . $this->provider->getPostId();
 
  240        $this->logger->debug(sprintf(
 
  241            'Building permanent with parameters %s',
 
  246            $posting_link = sprintf(
 
  248                ilUtil::_getHttpPath() . 
"/goto.php?target=frm_" . $forum_parameters . 
'&client_id=' . CLIENT_ID
 
  251            $posting_link .= sprintf(
 
  253                $ilClientIniFile->readVariable(
"client", 
"name"),
 
  257            $posting_link = sprintf(
 
  259                ilUtil::_getHttpPath() . 
"/goto.php?target=frm_" . $forum_parameters . 
'&client_id=' . CLIENT_ID
 
  262            $posting_link .= sprintf(
 
  264                $ilClientIniFile->readVariable(
"client", 
"name"),
 
  269        $this->logger->debug(sprintf(
 
  274        return $posting_link;
 
  282        $pos_message = $this->provider->getPostMessage();
 
  283        if (strip_tags($pos_message) != $pos_message) {
 
  284            $pos_message = preg_replace(
"/\n/i", 
"", $pos_message);
 
  285            $pos_message = preg_replace(
"/<li([^>]*)>/i", 
"\n<li$1>", $pos_message);
 
  286            $pos_message = preg_replace(
"/<\/ul([^>]*)>(?!\s*?(<p|<ul))/i", 
"</ul$1>\n", $pos_message);
 
  287            $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i", 
"\n", $pos_message);
 
  288            $pos_message = preg_replace(
"/<p([^>]*)>/i", 
"\n\n", $pos_message);
 
  289            $pos_message = preg_replace(
"/<\/p([^>]*)>/i", 
'', $pos_message);
 
  292        return strip_tags($pos_message);
 
  305        string $subjectLanguageId,
 
  314        $this->
sendMail(array($userId), array(
'system'));
 
  327        string $subjectLanguageId,
 
  335        $this->
sendMail(array($userId), array(
'system'));
 
  366        $this->
appendBody($this->
getLanguageText($action) . 
": \n------------------------------------------------------------\n");
 
  379        if ($this->provider->getPostCensored() == 1) {
 
  380            $message = $this->provider->getCensorshipComment();
 
  384        $this->
appendBody(
"------------------------------------------------------------\n");
 
  397            $this->provider->getForumTitle(),
 
  398            $this->provider->getThreadTitle()
 
  413            $date = $this->provider->getPostDate();
 
An exception for terminatinating execution or to throw for unit testing.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setLanguage($a_lng)
set language
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
createMail(string $subject, int $userId, string $customText, string $action, string $date)
const TYPE_POST_UNCENSORED
getPermanentLink($type=self::PERMANENT_LINK_POST)
const PERMANENT_LINK_FORUM
__construct(ilForumNotificationMailData $provider, \ilLogger $logger)
ilForumMailNotification constructor.
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail without attachments.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
addMailSubject(string $subject)
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail with attachments.
setSubject($a_subject)
string body
setIsCronjob($is_cronjob)
const TYPE_THREAD_DELETED
const TYPE_POST_ACTIVATION
createMailDate(string $date)
const PERMANENT_LINK_POST
Component logger with individual log levels by component id.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
getType()
Get notification type.
getRecipients()
get array of recipients
setAttachments($a_att)
Set attachments.
getLanguageText($a_keyword)
static _getInstallationSignature()
static getSalutation($a_usr_id, ilLanguage $a_language=null)
Interface ilForumNotificationMailData.
catch(Exception $e) $message