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");
106 $lng = $DIC->language();
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');
124 case self::TYPE_THREAD_DELETED:
127 $customText = sprintf($this->
getLanguageText(
'thread_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle());
132 case self::TYPE_POST_NEW:
135 $customText = sprintf($this->
getLanguageText(
'frm_noti_new_post'), $this->provider->getForumTitle());
140 case self::TYPE_POST_ACTIVATION:
148 case self::TYPE_POST_ANSWERED:
156 case self::TYPE_POST_UPDATED:
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);
165 case self::TYPE_POST_CENSORED:
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);
174 case self::TYPE_POST_UNCENSORED:
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);
183 case self::TYPE_POST_DELETED:
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,
311 $this->
createMail($subjectLanguageId, $userId, $customText, $action, $date);
314 $this->
sendMail(array($userId), array(
'system'));
327 string $subjectLanguageId,
333 $this->
createMail($subjectLanguageId, $userId, $customText, $action, $date);
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();
const PERMANENT_LINK_FORUM
getType()
Get notification type.
const TYPE_POST_ACTIVATION
createMail(string $subject, int $userId, string $customText, string $action, string $date)
getLanguageText($a_keyword)
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail without attachments.
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
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setIsCronjob($is_cronjob)
addMailSubject(string $subject)
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
static useRelativeDates()
check if relative dates are used
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail with attachments.
static setLanguage($a_lng)
set language
Base class for course/group mail notifications.
catch(Exception $e) $message
createMailDate(string $date)
Interface ilForumNotificationMailData.
getRecipients()
get array of recipients
getPermanentLink($type=self::PERMANENT_LINK_POST)
appendBody($a_body)
Append body text.
Component logger with individual log levels by component id.
const TYPE_POST_UNCENSORED
static _getInstallationSignature()
static getSalutation($a_usr_id, ilLanguage $a_language=null)