19 declare(strict_types=1);
    45         $mail = parent::initMail();
    46         $this->
logger->debug(
'Initialized mail service');
    51     public function sendMail(array $a_rcp, 
bool $a_parse_recipients = 
true): void
    53         $this->
logger->debug(sprintf(
    54             'Delegating notification transport to mail service for recipient "%s" ...',
    55             json_encode($a_rcp, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
    57         parent::sendMail($a_rcp, $a_parse_recipients);
    58         $this->
logger->debug(
'Notification transport delegated');
    63         $value = parent::setSubject($a_subject);
    64         $this->
logger->debug(sprintf(
'Setting subject to: %s', $a_subject));
    69     public function send(): bool
    73         $lng = $DIC->language();
    75         if (!
$ilSetting->get(
'forum_notification', 
'0')) {
    76             $this->
logger->debug(
'Forum notifications are globally disabled');
    82             $this->
logger->debug(
'No notification recipients, nothing to do');
    87         $lng->loadLanguageModule(
'forum');
    95             case self::TYPE_THREAD_DELETED:
    98                     $customText = sprintf(
   100                         $this->provider->getDeletedBy(),
   101                         $this->provider->getForumTitle()
   105                         'frm_noti_subject_del_thread',
   108                         'content_deleted_thread'   113             case self::TYPE_POST_NEW:
   116                     $customText = sprintf(
   118                         $this->provider->getForumTitle()
   122                         'frm_noti_subject_new_post',
   130             case self::TYPE_POST_ACTIVATION:
   136                         'frm_noti_subject_act_post',
   144             case self::TYPE_POST_ANSWERED:
   150                         'frm_noti_subject_answ_post',
   158             case self::TYPE_POST_UPDATED:
   161                     $customText = sprintf(
   163                         $this->provider->getPostUpdateUserName($this->getLanguage()),
   164                         $this->provider->getForumTitle()
   166                     $date = $this->provider->getPostUpdate();
   169                         'frm_noti_subject_upt_post',
   172                         'content_post_updated',
   178             case self::TYPE_POST_CENSORED:
   181                     $customText = sprintf(
   183                         $this->provider->getPostUpdateUserName($this->getLanguage()),
   184                         $this->provider->getForumTitle()
   186                     $date = $this->provider->getPostCensoredDate();
   189                         'frm_noti_subject_cens_post',
   192                         'content_censored_post',
   198             case self::TYPE_POST_UNCENSORED:
   201                     $customText = sprintf(
   203                         $this->provider->getPostUpdateUserName($this->getLanguage())
   205                     $date = $this->provider->getPostCensoredDate();
   208                         'frm_noti_subject_uncens_post',
   217             case self::TYPE_POST_DELETED:
   220                     $customText = sprintf(
   222                         $this->provider->getDeletedBy(),
   223                         $this->provider->getForumTitle()
   227                         'frm_noti_subject_del_post',
   230                         'content_deleted_post'   237         if (null === $contextId) {
   260         parent::initLanguage($a_usr_id);
   261         $this->
language->loadLanguageModule(
'forum');
   277         $ilClientIniFile = $DIC[
'ilClientIniFile'];
   279         if (
$type === self::PERMANENT_LINK_FORUM) {
   280             $language_text = $this->
getLanguageText(
"forums_notification_show_frm");
   281             $forum_parameters = $this->provider->getRefId();
   283             $language_text = $this->
getLanguageText(
"forums_notification_show_post");
   284             $forum_parameters = $this->provider->getRefId() . 
"_" . $this->provider->getThreadId() . 
"_" . $this->provider->getPostId();
   287         $this->
logger->debug(sprintf(
   288             'Building permanent with parameters %s',
   292         $posting_link = sprintf(
   296         $posting_link .= sprintf(
   298             $ilClientIniFile->readVariable(
"client", 
"name"),
   302         $this->
logger->debug(sprintf(
   307         return $posting_link;
   312         $pos_message = $this->provider->getPostMessage();
   313         if (strip_tags($pos_message) !== $pos_message) {
   314             $pos_message = preg_replace(
"/\n/i", 
"", $pos_message);
   315             $pos_message = preg_replace(
"/<li([^>]*)>/i", 
"\n<li$1>", $pos_message);
   316             $pos_message = preg_replace(
"/<\/ul([^>]*)>(?!\s*?(<p|<ul))/i", 
"</ul$1>\n", $pos_message);
   317             $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i", 
"\n", $pos_message);
   318             $pos_message = preg_replace(
"/<p([^>]*)>/i", 
"\n\n", $pos_message);
   319             return preg_replace(
"/<\/p([^>]*)>/i", 
'', $pos_message);
   334         string $subjectLanguageId,
   335         int $recipientUserId,
   351         $bodyText .= $attachmentText;
   354         $bodyText .= $attachmentText;
   361             ilStr::strLen($subjectText) > 255 ? ilStr::substr($subjectText, 0, 255) : $subjectText,
   363             $this->provider->getAttachments(),
   373         string $subjectLanguageId,
   374         int $recipientUserId,
   394             ilStr::strLen($subjectText) > 255 ? ilStr::substr($subjectText, 0, 255) : $subjectText,
   416         $body .= $customText;
   420         if ($this->provider->providesClosestContainer()) {
   421             $body .= $this->
getLanguageText(
'obj_' . $this->provider->closestContainer()->getType()) . 
": " . $this->provider->closestContainer()->getTitle();
   426         $body .= $this->
getLanguageText($action) . 
": \n------------------------------------------------------------\n";
   439         if ($this->provider->isPostCensored()) {
   440             $message = $this->provider->getCensorshipComment();
   445         return $body . 
"------------------------------------------------------------\n";
   450         $attachmentText = 
'';
   451         if ($this->provider->getAttachments() !== []) {
   452             $this->
logger->debug(
'Adding attachments ...');
   453             foreach ($this->provider->getAttachments() as $attachment) {
   454                 $attachmentText .= $this->
getLanguageText(
'attachment') . 
": " . $attachment . 
"\n";
   456             $attachmentText .= 
"\n------------------------------------------------------------\n";
   459         return $attachmentText;
   481             $date = $this->provider->getPostDate();
   489         $container_text = 
'';
   490         if ($this->provider->providesClosestContainer()) {
   491             $container_text = 
" (" . $this->
getLanguageText(
'frm_noti_obj_' . $this->provider->closestContainer()->getType()) .
   492                 " \"" . $this->provider->closestContainer()->getTitle() . 
"\")";
   497             $this->provider->getForumTitle(),
   499             $this->provider->getThreadTitle()
 
const TYPE_POST_ACTIVATION
 
setSubject(string $a_subject)
 
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
 
const PERMANENT_LINK_POST
 
static setLanguage(ilLanguage $a_lng)
 
const PERMANENT_LINK_FORUM
 
const TYPE_POST_UNCENSORED
 
static useRelativeDates()
 
__construct(protected ilForumNotificationMailData $provider, protected ilLogger $logger)
 
static strLen(string $a_string)
 
createMailBodyText(string $subject, int $userId, string $customText, string $action, string $date)
 
initLanguage(int $a_usr_id)
 
createAttachmentLinkText()
 
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
 
createSubjectText(string $subject)
 
createMailValueObjectsWithAttachments(string $subjectLanguageId, int $recipientUserId, string $customText, string $action, string $date='')
Add body and send mail with attachments. 
 
setIsCronjob(bool $is_cronjob)
 
getLanguageText(string $a_keyword)
 
addMailSubject(string $subject)
 
Interface ilForumNotificationMailData. 
 
createMailDate(string $date)
 
createMailValueObjectWithoutAttachments(string $subjectLanguageId, int $recipientUserId, string $customText, string $action, string $date='')
Add body and send mail without attachments. 
 
getPermanentLink(string $type=self::PERMANENT_LINK_POST)
 
static setUseRelativeDates(bool $a_status)
set use relative dates 
 
static _getInstallationSignature()
 
const TYPE_THREAD_DELETED
 
sendMail(array $a_rcp, bool $a_parse_recipients=true)
 
static _lookupLogin(int $a_user_id)