19declare(strict_types=1);
50 $mail = parent::initMail();
51 $this->
logger->debug(
'Initialized mail service');
55 public function sendMail(array $a_rcp,
bool $a_parse_recipients =
true): void
57 $this->
logger->debug(sprintf(
58 '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 (count($this->provider->getAttachments()) > 0) {
75 $this->
logger->debug(
'Adding attachments ...');
76 foreach ($this->provider->getAttachments() as $attachment) {
79 $this->
appendBody(
"\n------------------------------------------------------------\n");
84 public function send(): bool
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');
109 $customText = sprintf(
111 $this->provider->getDeletedBy(),
112 $this->provider->getForumTitle()
115 'frm_noti_subject_del_thread',
118 'content_deleted_thread'
126 $customText = sprintf(
128 $this->provider->getForumTitle()
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()
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()
189 $customText = sprintf(
191 $this->provider->getPostUpdateUserName($this->getLanguage())
194 'frm_noti_subject_uncens_post',
198 $this->provider->getPostCensoredDate()
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 = $this->provider->getRefId() .
"_" . $this->provider->getThreadId() .
"_" . $this->provider->getPostId();
257 $this->
logger->debug(sprintf(
258 'Building permanent with parameters %s',
262 $posting_link = sprintf(
267 $posting_link .= sprintf(
269 $ilClientIniFile->readVariable(
"client",
"name"),
273 $this->
logger->debug(sprintf(
278 return $posting_link;
283 $pos_message = $this->provider->getPostMessage();
284 if (strip_tags($pos_message) !== $pos_message) {
285 $pos_message = preg_replace(
"/\n/i",
"", $pos_message);
286 $pos_message = preg_replace(
"/<li([^>]*)>/i",
"\n<li$1>", $pos_message);
287 $pos_message = preg_replace(
"/<\/ul([^>]*)>(?!\s*?(<p|<ul))/i",
"</ul$1>\n", $pos_message);
288 $pos_message = preg_replace(
"/<br(\s*)(\/?)>/i",
"\n", $pos_message);
289 $pos_message = preg_replace(
"/<p([^>]*)>/i",
"\n\n", $pos_message);
290 $pos_message = preg_replace(
"/<\/p([^>]*)>/i",
'', $pos_message);
299 string $subjectLanguageId,
305 $this->
createMail($subjectLanguageId, $userId, $customText, $action, $date);
312 string $subjectLanguageId,
318 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
319 $this->addLinkToMail();
320 $this->sendMail([$userId]);
330 if (is_string($date)) {
331 $date = $this->createMailDate($date);
334 $this->addMailSubject($subject);
337 $this->appendBody(
"\n\n");
338 $this->appendBody($customText);
339 $this->appendBody(
"\n\n");
340 $this->appendBody($this->getLanguageText(
'forum') .
": " . $this->provider->getForumTitle());
341 $this->appendBody(
"\n\n");
342 if ($this->provider->providesClosestContainer()) {
344 $this->getLanguageText(
'frm_noti_obj_' . $this->provider->closestContainer()->getType()) .
": " .
345 $this->provider->closestContainer()->getTitle()
347 $this->appendBody(
"\n\n");
349 $this->appendBody($this->getLanguageText(
'thread') .
": " . $this->provider->getThreadTitle());
350 $this->appendBody(
"\n\n");
351 $this->appendBody($this->getLanguageText($action) .
": \n------------------------------------------------------------\n");
353 $this->appendBody($this->getLanguageText(
'author') .
": " . $this->provider->getPostUserName($this->getLanguage()));
354 $this->appendBody(
"\n");
355 if (is_string($date) && $date !==
'') {
356 $this->appendBody($this->getLanguageText(
'date') .
": " . $date);
357 $this->appendBody(
"\n");
359 $this->appendBody($this->getLanguageText(
'subject') .
": " . $this->provider->getPostTitle());
360 $this->appendBody(
"\n");
361 $this->appendBody($this->getLanguageText(
'frm_noti_message'));
362 $this->appendBody(
"\n");
364 $message = strip_tags($this->getPostMessage());
366 if ($this->provider->isPostCensored()) {
367 $message = $this->provider->getCensorshipComment();
371 $this->appendBody(
"------------------------------------------------------------\n");
378 $container_text =
'';
379 if ($this->provider->providesClosestContainer()) {
380 $container_text =
" (" .
381 $this->getLanguageText(
'obj_' . $this->provider->closestContainer()->getType()) .
382 " \"" . $this->provider->closestContainer()->getTitle() .
"\")";
385 $this->setSubject(sprintf(
386 $this->getLanguageText($subject),
387 $this->provider->getForumTitle(),
389 $this->provider->getThreadTitle()
398 $date = $this->provider->getPostDate();
406 $this->appendBody($this->getPermanentLink());
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
static setLanguage(ilLanguage $a_lng)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
const TYPE_POST_UNCENSORED
const PERMANENT_LINK_FORUM
setIsCronjob(bool $is_cronjob)
initLanguage(int $a_usr_id)
addMailSubject(string $subject)
sendMail(array $a_rcp, bool $a_parse_recipients=true)
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
createMail(string $subject, int $userId, string $customText, string $action, ?string $date)
setSubject(string $a_subject)
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, ?string $date=null)
__construct(ilForumNotificationMailData $provider, ilLogger $logger)
const TYPE_THREAD_DELETED
const TYPE_POST_ACTIVATION
createMailDate(string $date)
const PERMANENT_LINK_POST
ilForumNotificationMailData $provider
getPermanentLink(string $type=self::PERMANENT_LINK_POST)
Component logger with individual log levels by component id.
Base class for course/group mail notifications.
getLanguageText(string $a_keyword)
appendBody(string $a_body)
setAttachments(array $a_att)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilForumNotificationMailData.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc