19 declare(strict_types=1);
48 $mail = parent::initMail();
49 $this->
logger->debug(
'Initialized mail service');
53 public function sendMail(array $a_rcp,
bool $a_parse_recipients =
true): void
57 'Delegating notification transport to mail service for recipients: %s',
61 parent::sendMail($a_rcp, $a_parse_recipients);
62 $this->
logger->debug(
'Notification transport delegated');
67 $value = parent::setSubject($a_subject);
68 $this->
logger->debug(sprintf(
'Setting subject to: %s', $a_subject));
74 if ($this->provider->getAttachments() !== []) {
75 $this->
logger->debug(
'Adding attachments ...');
76 foreach ($this->provider->getAttachments() as $attachment) {
79 $this->
appendBody(
"\n------------------------------------------------------------\n");
84 public function send(): bool
88 $lng = $DIC->language();
90 if (!
$ilSetting->get(
'forum_notification',
'0')) {
91 $this->
logger->debug(
'Forum notifications are globally disabled');
96 $this->
logger->debug(
'No notification recipients, nothing to do');
100 $lng->loadLanguageModule(
'forum');
106 case self::TYPE_THREAD_DELETED:
109 $customText = sprintf(
111 $this->provider->getDeletedBy(),
112 $this->provider->getForumTitle()
115 'frm_noti_subject_del_thread',
118 'content_deleted_thread' 123 case self::TYPE_POST_NEW:
126 $customText = sprintf(
128 $this->provider->getForumTitle()
134 case self::TYPE_POST_ACTIVATION:
142 case self::TYPE_POST_ANSWERED:
150 case self::TYPE_POST_UPDATED:
153 $customText = sprintf(
155 $this->provider->getPostUpdateUserName($this->getLanguage()),
156 $this->provider->getForumTitle()
159 'frm_noti_subject_upt_post',
162 'content_post_updated',
163 $this->provider->getPostUpdate()
168 case self::TYPE_POST_CENSORED:
171 $customText = sprintf(
173 $this->provider->getPostUpdateUserName($this->getLanguage()),
174 $this->provider->getForumTitle()
177 'frm_noti_subject_cens_post',
180 'content_censored_post',
181 $this->provider->getPostCensoredDate()
186 case self::TYPE_POST_UNCENSORED:
189 $customText = sprintf(
191 $this->provider->getPostUpdateUserName($this->getLanguage())
194 'frm_noti_subject_uncens_post',
198 $this->provider->getPostCensoredDate()
203 case self::TYPE_POST_DELETED:
206 $customText = sprintf(
208 $this->provider->getDeletedBy(),
209 $this->provider->getForumTitle()
212 'frm_noti_subject_del_post',
215 'content_deleted_post' 229 parent::initLanguage($a_usr_id);
230 $this->
language->loadLanguageModule(
'forum');
247 $ilClientIniFile = $DIC[
'ilClientIniFile'];
249 if (
$type === self::PERMANENT_LINK_FORUM) {
250 $language_text = $this->
getLanguageText(
'forums_notification_show_frm');
251 $forum_parameters = $this->provider->getRefId();
253 $language_text = $this->
getLanguageText(
'forums_notification_show_post');
254 $forum_parameters = implode(
'_', [
255 $this->provider->getRefId(),
256 $this->provider->getThreadId(),
257 $this->provider->getPostId()
263 'Building permanent with parameters %s',
268 $posting_link = sprintf(
273 $posting_link .= sprintf(
275 $ilClientIniFile->readVariable(
'client',
'name'),
286 return $posting_link;
291 $pos_message = $this->provider->getPostMessage() ??
'';
292 if (strip_tags($pos_message) !== $pos_message) {
293 $pos_message = preg_replace(
"/\n/i",
'', $pos_message);
294 $pos_message = preg_replace(
'/<li([^>]*)>/i',
"\n<li$1>", $pos_message);
295 $pos_message = preg_replace(
"/<\/ul([^>]*)>(?!\s*?(<p|<ul))/i",
"</ul$1>\n", $pos_message);
296 $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i",
"\n", $pos_message);
297 $pos_message = preg_replace(
'/<p([^>]*)>/i',
"\n\n", $pos_message);
298 $pos_message = preg_replace(
"/<\/p([^>]*)>/i",
'', $pos_message);
307 string $subjectLanguageId,
313 $this->
createMail($subjectLanguageId, $userId, $customText, $action, $date);
320 string $subjectLanguageId,
326 $this->
createMail($subjectLanguageId, $userId, $customText, $action, $date);
338 if (is_string($date)) {
350 if ($this->provider->providesClosestContainer()) {
352 $this->
getLanguageText(
'frm_noti_obj_' . $this->provider->closestContainer()->getType()) .
': ' .
353 $this->provider->closestContainer()->getTitle()
360 $this->
getLanguageText($action) .
": \n------------------------------------------------------------\n" 364 $this->
getLanguageText(
'author') .
': ' . $this->provider->getPostUserName($this->getLanguage())
367 if (is_string($date) && $date !==
'') {
378 if ($this->provider->isPostCensored()) {
379 $message = $this->provider->getCensorshipComment();
383 $this->
appendBody(
"------------------------------------------------------------\n");
390 $container_text =
'';
391 if ($this->provider->providesClosestContainer()) {
392 $container_text =
' (' .
393 $this->
getLanguageText(
'obj_' . $this->provider->closestContainer()->getType()) .
394 ' "' . $this->provider->closestContainer()->getTitle() .
'")';
400 $this->provider->getForumTitle(),
402 $this->provider->getThreadTitle()
412 $date = $this->provider->getPostDate();
const PERMANENT_LINK_FORUM
static array static setUseRelativeDates(bool $a_status)
set use relative dates
appendBody(string $a_body)
const TYPE_POST_ACTIVATION
getPermanentLink(string $type=self::PERMANENT_LINK_POST)
const PERMANENT_LINK_POST
createMail(string $subject, int $userId, string $customText, string $action, ?string $date)
initLanguage(int $a_usr_id)
__construct(private readonly ilForumNotificationMailData $provider, private readonly ilLogger $logger)
setIsCronjob(bool $is_cronjob)
const TYPE_THREAD_DELETED
static setLanguage(ilLanguage $a_lng)
addMailSubject(string $subject)
static useRelativeDates()
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
createMailDate(string $date)
getLanguageText(string $a_keyword)
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, ?string $date=null)
Interface ilForumNotificationMailData.
__construct(Container $dic, ilPlugin $plugin)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
language()
description: > Example for rendring a language glyph.
setSubject(string $a_subject)
sendMail(array $a_rcp, bool $a_parse_recipients=true)
const TYPE_POST_UNCENSORED
static _getInstallationSignature()
setAttachments(array $a_att)