ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilForumMailNotification Class Reference
+ Inheritance diagram for ilForumMailNotification:
+ Collaboration diagram for ilForumMailNotification:

Public Member Functions

 __construct (private readonly ilForumNotificationMailData $provider, private readonly ilLogger $logger)
 
 sendMail (array $a_rcp, bool $a_parse_recipients=true)
 
 send ()
 
 isCronjob ()
 
 setIsCronjob (bool $is_cronjob)
 
- Public Member Functions inherited from ilMailNotification
 __construct (protected bool $is_in_wsp=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
final const int 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 string PERMANENT_LINK_POST = 'PL_Post'
 
const string PERMANENT_LINK_FORUM = 'PL_Forum'
 
bool $is_cronjob = false
 

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 = []
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

42 {
44 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLinkToMail()

ilForumMailNotification::addLinkToMail ( )
private

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

418 : void
419 {
420 $this->appendBody($this->getPermanentLink());
422 }
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 386 of file class.ilForumMailNotification.php.

386 : void
387 {
388 $this->initMail();
389
390 $container_text = '';
391 if ($this->provider->providesClosestContainer()) {
392 $container_text = ' (' .
393 $this->getLanguageText('obj_' . $this->provider->closestContainer()->getType()) .
394 ' "' . $this->provider->closestContainer()->getTitle() . '")';
395 }
396
397 $this->setSubject(
398 sprintf(
400 $this->provider->getForumTitle(),
401 $container_text,
402 $this->provider->getThreadTitle()
403 )
404 );
405 }
getLanguageText(string $a_keyword)

◆ appendAttachments()

ilForumMailNotification::appendAttachments ( )
protected

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

72 : void
73 {
74 if ($this->provider->getAttachments() !== []) {
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 331 of file class.ilForumMailNotification.php.

337 : void {
338 if (is_string($date)) {
339 $date = $this->createMailDate($date);
340 }
341
342 $this->addMailSubject($subject);
343
344 $this->setBody(ilMail::getSalutation($userId, $this->getLanguage()));
345 $this->appendBody("\n\n");
346 $this->appendBody($customText);
347 $this->appendBody("\n\n");
348 $this->appendBody($this->getLanguageText('forum') . ': ' . $this->provider->getForumTitle());
349 $this->appendBody("\n\n");
350 if ($this->provider->providesClosestContainer()) {
351 $this->appendBody(
352 $this->getLanguageText('frm_noti_obj_' . $this->provider->closestContainer()->getType()) . ': ' .
353 $this->provider->closestContainer()->getTitle()
354 );
355 $this->appendBody("\n\n");
356 }
357 $this->appendBody($this->getLanguageText('thread') . ': ' . $this->provider->getThreadTitle());
358 $this->appendBody("\n\n");
359 $this->appendBody(
360 $this->getLanguageText($action) . ": \n------------------------------------------------------------\n"
361 );
362
363 $this->appendBody(
364 $this->getLanguageText('author') . ': ' . $this->provider->getPostUserName($this->getLanguage())
365 );
366 $this->appendBody("\n");
367 if (is_string($date) && $date !== '') {
368 $this->appendBody($this->getLanguageText('date') . ': ' . $date);
369 $this->appendBody("\n");
370 }
371 $this->appendBody($this->getLanguageText('subject') . ': ' . $this->provider->getPostTitle());
372 $this->appendBody("\n");
373 $this->appendBody($this->getLanguageText('frm_noti_message'));
374 $this->appendBody("\n");
375
376 $message = strip_tags($this->getPostMessage());
377
378 if ($this->provider->isPostCensored()) {
379 $message = $this->provider->getCensorshipComment();
380 }
381
382 $this->appendBody($message . "\n");
383 $this->appendBody("------------------------------------------------------------\n");
384 }
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
$message
Definition: xapiexit.php:31

◆ createMailDate()

ilForumMailNotification::createMailDate ( string  $date)
private

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

407 : string
408 {
410
411 if ($date === '') {
412 $date = $this->provider->getPostDate();
413 }
414
416 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static setLanguage(ilLanguage $a_lng)
@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 = implode('_', [
255 $this->provider->getRefId(),
256 $this->provider->getThreadId(),
257 $this->provider->getPostId()
258 ]);
259 }
260
261 $this->logger->debug(
262 sprintf(
263 'Building permanent with parameters %s',
264 $forum_parameters
265 )
266 );
267
268 $posting_link = sprintf(
269 $language_text,
270 rtrim(ilUtil::_getHttpPath(), '/') . '/goto.php?target=frm_' . $forum_parameters . '&client_id=' . CLIENT_ID
271 ) . "\n\n";
272
273 $posting_link .= sprintf(
274 $this->getLanguageText('forums_notification_intro'),
275 $ilClientIniFile->readVariable('client', 'name'),
276 rtrim(ilUtil::_getHttpPath(), '/') . '/?client_id=' . CLIENT_ID
277 ) . "\n\n";
278
279 $this->logger->debug(
280 sprintf(
281 'Link built: %s',
282 $posting_link
283 )
284 );
285
286 return $posting_link;
287 }
static _getHttpPath()
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:26

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 289 of file class.ilForumMailNotification.php.

289 : string
290 {
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);
299
300 return $pos_message;
301 }
302
303 return $pos_message;
304 }

◆ 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 46 of file class.ilForumMailNotification.php.

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

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 $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31

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 53 of file class.ilForumMailNotification.php.

53 : void
54 {
55 $this->logger->debug(
56 sprintf(
57 'Delegating notification transport to mail service for recipients: %s',
58 print_r($a_rcp, true)
59 )
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 306 of file class.ilForumMailNotification.php.

312 : void {
313 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
314 $this->appendAttachments();
315 $this->addLinkToMail();
316 $this->sendMail([$userId]);
317 }
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 319 of file class.ilForumMailNotification.php.

325 : void {
326 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
327 $this->addLinkToMail();
328 $this->sendMail([$userId]);
329 }

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().

◆ PERMANENT_LINK_FORUM

const string ilForumMailNotification::PERMANENT_LINK_FORUM = 'PL_Forum'
private

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

◆ PERMANENT_LINK_POST

const string 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: