ILIAS  release_8 Revision v8.24
ilForumMailNotification Class Reference
+ Inheritance diagram for ilForumMailNotification:
+ Collaboration diagram for ilForumMailNotification:

Public Member Functions

 __construct (ilForumNotificationMailData $provider, ilLogger $logger)
 
 sendMail (array $a_rcp, bool $a_parse_recipients=true)
 
 send ()
 
 isCronjob ()
 
 setIsCronjob (bool $is_cronjob)
 
- Public Member Functions inherited from ilMailNotification
 __construct (bool $a_is_personal_workspace=false)
 
 setType (int $a_type)
 
 getType ()
 
 setSender (int $a_usr_id)
 
 getSender ()
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 
 setAttachments (array $a_att)
 
 getAttachments ()
 
 setLangModules (array $a_modules)
 
 getUserLanguage (int $a_usr_id)
 
 setRefId (int $a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId (int $a_obj_id)
 
 getObjType ()
 
 setAdditionalInformation (array $a_info)
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, bool $a_parse_recipients=true)
 
 getBlockBorder ()
 

Data Fields

const TYPE_THREAD_DELETED = 54
 
const TYPE_POST_NEW = 60
 
const TYPE_POST_ACTIVATION = 61
 
const TYPE_POST_UPDATED = 62
 
const TYPE_POST_CENSORED = 63
 
const TYPE_POST_DELETED = 64
 
const TYPE_POST_ANSWERED = 65
 
const TYPE_POST_UNCENSORED = 66
 
- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 

Protected Member Functions

 initMail ()
 
 setSubject (string $a_subject)
 
 appendAttachments ()
 
 initLanguage (int $a_usr_id)
 
- Protected Member Functions inherited from ilMailNotification
 setSubject (string $a_subject)
 
 getSubject ()
 
 setBody (string $a_body)
 
 appendBody (string $a_body)
 
 getBody ()
 
 initLanguage (int $a_usr_id)
 
 initLanguageByIso2Code (string $a_code='')
 
 setLanguage (ilLanguage $a_language)
 
 getLanguage ()
 
 getLanguageText (string $a_keyword)
 
 getObjectTitle (bool $a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink (array $a_params=[], string $a_append='')
 
 userToString (int $a_usr_id)
 
 isRefIdAccessible (int $a_user_id, int $a_ref_id, string $a_permission="read")
 

Private Member Functions

 getPermanentLink (string $type=self::PERMANENT_LINK_POST)
 
 getPostMessage ()
 
 sendMailWithAttachments (string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
 
 sendMailWithoutAttachments (string $subjectLanguageId, int $userId, string $customText, string $action, ?string $date=null)
 
 createMail (string $subject, int $userId, string $customText, string $action, ?string $date)
 
 addMailSubject (string $subject)
 
 createMailDate (string $date)
 
 addLinkToMail ()
 

Private Attributes

const PERMANENT_LINK_POST = 'PL_Post'
 
const PERMANENT_LINK_FORUM = 'PL_Forum'
 
bool $is_cronjob = false
 
ilForumNotificationMailData $provider
 
ilLogger $logger
 

Additional Inherited Members

- Protected Attributes inherited from ilMailNotification
int $type
 
int $sender
 
ilMail $mail = null
 
string $subject = ''
 
string $body = ''
 
array $attachments = []
 
ilLanguage $language
 
array $lang_modules = []
 
array $recipients = []
 
int $ref_id
 
int $obj_id = 0
 
string $obj_type = ''
 
array $additional_info = []
 
bool $is_in_wsp
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumMailNotification::__construct ( ilForumNotificationMailData  $provider,
ilLogger  $logger 
)

Definition at line 41 of file class.ilForumMailNotification.php.

42 {
44 $this->provider = $provider;
45 $this->logger = $logger;
46 }
ilForumNotificationMailData $provider
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $logger, $provider, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLinkToMail()

ilForumMailNotification::addLinkToMail ( )
private

Definition at line 404 of file class.ilForumMailNotification.php.

404 : void
405 {
406 $this->appendBody($this->getPermanentLink());
408 }
getPermanentLink(string $type=self::PERMANENT_LINK_POST)
static _getInstallationSignature()

References ilMail\_getInstallationSignature().

+ Here is the call graph for this function:

◆ addMailSubject()

ilForumMailNotification::addMailSubject ( string  $subject)
private

Definition at line 374 of file class.ilForumMailNotification.php.

374 : void
375 {
376 $this->initMail();
377
378 $container_text = '';
379 if ($this->provider->providesClosestContainer()) {
380 $container_text = " (" .
381 $this->getLanguageText('obj_' . $this->provider->closestContainer()->getType()) .
382 " \"" . $this->provider->closestContainer()->getTitle() . "\")";
383 }
384
385 $this->setSubject(sprintf(
387 $this->provider->getForumTitle(),
388 $container_text,
389 $this->provider->getThreadTitle()
390 ));
391 }
getLanguageText(string $a_keyword)

◆ appendAttachments()

ilForumMailNotification::appendAttachments ( )
protected

Definition at line 72 of file class.ilForumMailNotification.php.

72 : void
73 {
74 if (count($this->provider->getAttachments()) > 0) {
75 $this->logger->debug('Adding attachments ...');
76 foreach ($this->provider->getAttachments() as $attachment) {
77 $this->appendBody($this->getLanguageText('attachment') . ": " . $attachment . "\n");
78 }
79 $this->appendBody("\n------------------------------------------------------------\n");
80 $this->setAttachments($this->provider->getAttachments());
81 }
82 }

References ilMailNotification\appendBody(), ilMailNotification\getLanguageText(), ILIAS\Repository\logger(), and ilMailNotification\setAttachments().

+ Here is the call graph for this function:

◆ createMail()

ilForumMailNotification::createMail ( string  $subject,
int  $userId,
string  $customText,
string  $action,
?string  $date 
)
private

Definition at line 323 of file class.ilForumMailNotification.php.

329 : void {
330 if (is_string($date)) {
331 $date = $this->createMailDate($date);
332 }
333
334 $this->addMailSubject($subject);
335
336 $this->setBody(ilMail::getSalutation($userId, $this->getLanguage()));
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()) {
343 $this->appendBody(
344 $this->getLanguageText('frm_noti_obj_' . $this->provider->closestContainer()->getType()) . ": " .
345 $this->provider->closestContainer()->getTitle()
346 );
347 $this->appendBody("\n\n");
348 }
349 $this->appendBody($this->getLanguageText('thread') . ": " . $this->provider->getThreadTitle());
350 $this->appendBody("\n\n");
351 $this->appendBody($this->getLanguageText($action) . ": \n------------------------------------------------------------\n");
352
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");
358 }
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");
363
364 $message = strip_tags($this->getPostMessage());
365
366 if ($this->provider->isPostCensored()) {
367 $message = $this->provider->getCensorshipComment();
368 }
369
370 $this->appendBody($message . "\n");
371 $this->appendBody("------------------------------------------------------------\n");
372 }
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
$message
Definition: xapiexit.php:32

◆ createMailDate()

ilForumMailNotification::createMailDate ( string  $date)
private

Definition at line 393 of file class.ilForumMailNotification.php.

393 : string
394 {
396
397 if ($date === '') {
398 $date = $this->provider->getPostDate();
399 }
400
402 }
const IL_CAL_DATETIME
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

References ilDatePresentation\formatDate(), IL_CAL_DATETIME, ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ilDatePresentation\setLanguage().

+ Here is the call graph for this function:

◆ getPermanentLink()

ilForumMailNotification::getPermanentLink ( string  $type = self::PERMANENT_LINK_POST)
private

Definition at line 243 of file class.ilForumMailNotification.php.

243 : string
244 {
245 global $DIC;
246
247 $ilClientIniFile = $DIC['ilClientIniFile'];
248
249 if ($type === self::PERMANENT_LINK_FORUM) {
250 $language_text = $this->getLanguageText("forums_notification_show_frm");
251 $forum_parameters = $this->provider->getRefId();
252 } else {
253 $language_text = $this->getLanguageText("forums_notification_show_post");
254 $forum_parameters = $this->provider->getRefId() . "_" . $this->provider->getThreadId() . "_" . $this->provider->getPostId();
255 }
256
257 $this->logger->debug(sprintf(
258 'Building permanent with parameters %s',
259 $forum_parameters
260 ));
261
262 $posting_link = sprintf(
263 $language_text,
264 ilUtil::_getHttpPath() . "/goto.php?target=frm_" . $forum_parameters . '&client_id=' . CLIENT_ID
265 ) . "\n\n";
266
267 $posting_link .= sprintf(
268 $this->getLanguageText("forums_notification_intro"),
269 $ilClientIniFile->readVariable("client", "name"),
270 ilUtil::_getHttpPath() . '/?client_id=' . CLIENT_ID
271 ) . "\n\n";
272
273 $this->logger->debug(sprintf(
274 'Link built: %s',
275 $posting_link
276 ));
277
278 return $posting_link;
279 }
static _getHttpPath()
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: feed.php:28

References $DIC, ilMailNotification\$type, ilUtil\_getHttpPath(), CLIENT_ID, ilMailNotification\getLanguageText(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getPostMessage()

ilForumMailNotification::getPostMessage ( )
private

Definition at line 281 of file class.ilForumMailNotification.php.

281 : string
282 {
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);
291
292 return $pos_message;
293 }
294
295 return $pos_message;
296 }

◆ initLanguage()

ilForumMailNotification::initLanguage ( int  $a_usr_id)
protected

Reimplemented from ilMailNotification.

Definition at line 227 of file class.ilForumMailNotification.php.

227 : void
228 {
229 parent::initLanguage($a_usr_id);
230 $this->language->loadLanguageModule('forum');
231 }

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initMail()

ilForumMailNotification::initMail ( )
protected

Reimplemented from ilMailNotification.

Definition at line 48 of file class.ilForumMailNotification.php.

48 : ilMail
49 {
50 $mail = parent::initMail();
51 $this->logger->debug('Initialized mail service');
52 return $mail;
53 }

References ilMailNotification\$mail, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ isCronjob()

ilForumMailNotification::isCronjob ( )

Definition at line 233 of file class.ilForumMailNotification.php.

233 : bool
234 {
235 return $this->is_cronjob;
236 }

References $is_cronjob.

◆ send()

ilForumMailNotification::send ( )

Definition at line 84 of file class.ilForumMailNotification.php.

84 : bool
85 {
86 global $DIC;
87 $ilSetting = $DIC->settings();
88 $lng = $DIC->language();
89
90 if (!$ilSetting->get('forum_notification', '0')) {
91 $this->logger->debug('Forum notifications are globally disabled');
92 return false;
93 }
94
95 if (!$this->getRecipients()) {
96 $this->logger->debug('No notification recipients, nothing to do');
97 return false;
98 }
99
100 $lng->loadLanguageModule('forum');
101
104
105 switch ($this->getType()) {
107 foreach ($this->getRecipients() as $rcp) {
108 $this->initLanguage($rcp);
109 $customText = sprintf(
110 $this->getLanguageText('thread_deleted_by'),
111 $this->provider->getDeletedBy(),
112 $this->provider->getForumTitle()
113 );
115 'frm_noti_subject_del_thread',
116 (int) $rcp,
117 $customText,
118 'content_deleted_thread'
119 );
120 }
121 break;
122
124 foreach ($this->getRecipients() as $rcp) {
125 $this->initLanguage($rcp);
126 $customText = sprintf(
127 $this->getLanguageText('frm_noti_new_post'),
128 $this->provider->getForumTitle()
129 );
130 $this->sendMailWithAttachments('frm_noti_subject_new_post', (int) $rcp, $customText, 'new_post');
131 }
132 break;
133
135 foreach ($this->getRecipients() as $rcp) {
136 $this->initLanguage($rcp);
137 $customText = $this->getLanguageText('forums_post_activation_mail');
138 $this->sendMailWithAttachments('frm_noti_subject_act_post', (int) $rcp, $customText, 'new_post');
139 }
140 break;
141
143 foreach ($this->getRecipients() as $rcp) {
144 $this->initLanguage($rcp);
145 $customText = $this->getLanguageText('forum_post_replied');
146 $this->sendMailWithAttachments('frm_noti_subject_answ_post', (int) $rcp, $customText, 'new_post');
147 }
148 break;
149
151 foreach ($this->getRecipients() as $rcp) {
152 $this->initLanguage($rcp);
153 $customText = sprintf(
154 $this->getLanguageText('post_updated_by'),
155 $this->provider->getPostUpdateUserName($this->getLanguage()),
156 $this->provider->getForumTitle()
157 );
159 'frm_noti_subject_upt_post',
160 (int) $rcp,
161 $customText,
162 'content_post_updated',
163 $this->provider->getPostUpdate()
164 );
165 }
166 break;
167
169 foreach ($this->getRecipients() as $rcp) {
170 $this->initLanguage($rcp);
171 $customText = sprintf(
172 $this->getLanguageText('post_censored_by'),
173 $this->provider->getPostUpdateUserName($this->getLanguage()),
174 $this->provider->getForumTitle()
175 );
177 'frm_noti_subject_cens_post',
178 (int) $rcp,
179 $customText,
180 'content_censored_post',
181 $this->provider->getPostCensoredDate()
182 );
183 }
184 break;
185
187 foreach ($this->getRecipients() as $rcp) {
188 $this->initLanguage($rcp);
189 $customText = sprintf(
190 $this->getLanguageText('post_uncensored_by'),
191 $this->provider->getPostUpdateUserName($this->getLanguage())
192 );
194 'frm_noti_subject_uncens_post',
195 (int) $rcp,
196 $customText,
197 'forums_the_post',
198 $this->provider->getPostCensoredDate()
199 );
200 }
201 break;
202
204 foreach ($this->getRecipients() as $rcp) {
205 $this->initLanguage($rcp);
206 $customText = sprintf(
207 $this->getLanguageText('post_deleted_by'),
208 $this->provider->getDeletedBy(),
209 $this->provider->getForumTitle()
210 );
212 'frm_noti_subject_del_post',
213 (int) $rcp,
214 $customText,
215 'content_deleted_post'
216 );
217 }
218 break;
219 }
220
223
224 return true;
225 }
static setUseRelativeDates(bool $a_status)
set use relative dates
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, ?string $date=null)
global $ilSetting
Definition: privfeed.php:17
$lng

References $DIC, $ilSetting, $lng, ilMailNotification\getLanguageText(), ilMailNotification\getRecipients(), ilMailNotification\getType(), initLanguage(), ILIAS\Repository\logger(), sendMailWithAttachments(), sendMailWithoutAttachments(), ilDatePresentation\setLanguage(), ilDatePresentation\setUseRelativeDates(), TYPE_POST_ACTIVATION, TYPE_POST_ANSWERED, TYPE_POST_CENSORED, TYPE_POST_DELETED, TYPE_POST_NEW, TYPE_POST_UNCENSORED, TYPE_POST_UPDATED, TYPE_THREAD_DELETED, and ilDatePresentation\useRelativeDates().

+ Here is the call graph for this function:

◆ sendMail()

ilForumMailNotification::sendMail ( array  $a_rcp,
bool  $a_parse_recipients = true 
)

Reimplemented from ilMailNotification.

Definition at line 55 of file class.ilForumMailNotification.php.

55 : void
56 {
57 $this->logger->debug(sprintf(
58 'Delegating notification transport to mail service for recipients: %s',
59 print_r($a_rcp, true)
60 ));
61 parent::sendMail($a_rcp, $a_parse_recipients);
62 $this->logger->debug('Notification transport delegated');
63 }

References ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ sendMailWithAttachments()

ilForumMailNotification::sendMailWithAttachments ( string  $subjectLanguageId,
int  $userId,
string  $customText,
string  $action,
string  $date = '' 
)
private

Definition at line 298 of file class.ilForumMailNotification.php.

304 : void {
305 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
306 $this->appendAttachments();
307 $this->addLinkToMail();
308 $this->sendMail([$userId]);
309 }
sendMail(array $a_rcp, bool $a_parse_recipients=true)
createMail(string $subject, int $userId, string $customText, string $action, ?string $date)

Referenced by send().

+ Here is the caller graph for this function:

◆ sendMailWithoutAttachments()

ilForumMailNotification::sendMailWithoutAttachments ( string  $subjectLanguageId,
int  $userId,
string  $customText,
string  $action,
?string  $date = null 
)
private

Definition at line 311 of file class.ilForumMailNotification.php.

317 : void {
318 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
319 $this->addLinkToMail();
320 $this->sendMail([$userId]);
321 }

Referenced by send().

+ Here is the caller graph for this function:

◆ setIsCronjob()

ilForumMailNotification::setIsCronjob ( bool  $is_cronjob)

Definition at line 238 of file class.ilForumMailNotification.php.

238 : void
239 {
240 $this->is_cronjob = $is_cronjob;
241 }

References $is_cronjob.

◆ setSubject()

ilForumMailNotification::setSubject ( string  $a_subject)
protected

Reimplemented from ilMailNotification.

Definition at line 65 of file class.ilForumMailNotification.php.

65 : string
66 {
67 $value = parent::setSubject($a_subject);
68 $this->logger->debug(sprintf('Setting subject to: %s', $a_subject));
69 return $value;
70 }

References ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $is_cronjob

bool ilForumMailNotification::$is_cronjob = false
private

Definition at line 37 of file class.ilForumMailNotification.php.

Referenced by isCronjob(), and setIsCronjob().

◆ $logger

ilLogger ilForumMailNotification::$logger
private

Definition at line 39 of file class.ilForumMailNotification.php.

Referenced by __construct().

◆ $provider

ilForumNotificationMailData ilForumMailNotification::$provider
private

Definition at line 38 of file class.ilForumMailNotification.php.

Referenced by __construct().

◆ PERMANENT_LINK_FORUM

const ilForumMailNotification::PERMANENT_LINK_FORUM = 'PL_Forum'
private

Definition at line 27 of file class.ilForumMailNotification.php.

◆ PERMANENT_LINK_POST

const ilForumMailNotification::PERMANENT_LINK_POST = 'PL_Post'
private

Definition at line 26 of file class.ilForumMailNotification.php.

◆ TYPE_POST_ACTIVATION

const ilForumMailNotification::TYPE_POST_ACTIVATION = 61

◆ TYPE_POST_ANSWERED

const ilForumMailNotification::TYPE_POST_ANSWERED = 65

◆ TYPE_POST_CENSORED

const ilForumMailNotification::TYPE_POST_CENSORED = 63

◆ TYPE_POST_DELETED

◆ TYPE_POST_NEW

const ilForumMailNotification::TYPE_POST_NEW = 60

◆ TYPE_POST_UNCENSORED

const ilForumMailNotification::TYPE_POST_UNCENSORED = 66

◆ TYPE_POST_UPDATED

const ilForumMailNotification::TYPE_POST_UPDATED = 62

◆ TYPE_THREAD_DELETED


The documentation for this class was generated from the following file: