ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilForumMailNotification Class Reference
+ Inheritance diagram for ilForumMailNotification:
+ Collaboration diagram for ilForumMailNotification:

Public Member Functions

 __construct (ilForumNotificationMailData $provider, \ilLogger $logger)
 ilForumMailNotification constructor. More...
 
 sendMail (array $a_rcp, $a_parse_recipients=true)
 
Parameters
array$a_rcp
bool | true$a_parse_recipients
More...
 
 send ()
 
 isCronjob ()
 
 setIsCronjob ($is_cronjob)
 
- Public Member Functions inherited from ilMailNotification
 __construct ($a_is_personal_workspace=false)
 
 setType ($a_type)
 Set notification type. More...
 
 getType ()
 Get notification type. More...
 
 setSender ($a_usr_id)
 Set sender of mail. More...
 
 getSender ()
 get sender of mail More...
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 get array of recipients More...
 
 setAttachments ($a_att)
 Set attachments. More...
 
 getAttachments ()
 Get attachments. More...
 
 setLangModules (array $a_modules)
 Set lang modules. More...
 
 getUserLanguage ($a_usr_id)
 Get user language. More...
 
 setRefId ($a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId ($a_obj_id)
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation (array $a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, $a_parse_recipients=true)
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

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
 
const PERMANENT_LINK_POST = 'PL_Post'
 
const PERMANENT_LINK_FORUM = 'PL_Forum'
 
- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 

Protected Member Functions

 initMail ()
 
Returns
ilMail
More...
 
 setSubject ($a_subject)
 
Parameters
string$a_subject
Returns
string body
More...
 
 appendAttachments ()
 
 initLanguage ($a_usr_id)
 
- Protected Member Functions inherited from ilMailNotification
 setSubject ($a_subject)
 
 getSubject ()
 
 setBody ($a_body)
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 
 getLanguage ()
 
 getLanguageText ($a_keyword)
 
 getObjectTitle ($a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink ($a_params=array(), $a_append='')
 
 userToString ($a_usr_id)
 
 isRefIdAccessible ($a_user_id, $a_ref_id, $a_permission="read")
 Check if ref id is accessible for user. More...
 

Protected Attributes

 $is_cronjob = false
 
 $provider
 
 $logger
 
- Protected Attributes inherited from ilMailNotification
 $type = null
 
 $sender = null
 
 $mail = null
 
 $subject = ''
 
 $body = ''
 
 $attachments = array()
 
 $language = null
 
 $lang_modules = array()
 
 $recipients = array()
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $additional_info = array()
 
 $is_in_wsp
 
 $wsp_tree
 
 $wsp_access_handler
 

Private Member Functions

 getPermanentLink ($type=self::PERMANENT_LINK_POST)
 
 getSecurePostMessage ()
 
 sendMailWithAttachments (string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
 Add body and send mail with attachments. More...
 
 sendMailWithoutAttachments (string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
 Add body and send mail without attachments. More...
 
 createMail (string $subject, int $userId, string $customText, string $action, string $date)
 
 addMailSubject (string $subject)
 
 createMailDate (string $date)
 
 addLinkToMail ()
 

Detailed Description

Author
Nadia Matuschek nmatu.nosp@m.sche.nosp@m.k@dat.nosp@m.abay.nosp@m..de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

ilForumMailNotification constructor.

Parameters
ilForumNotificationMailData$provider
ilLogger$logger

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

45 {
47 $this->provider = $provider;
48 $this->logger = $logger;
49 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLinkToMail()

ilForumMailNotification::addLinkToMail ( )
private

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

425 {
426 $this->appendBody($this->getPermanentLink());
428 }
getPermanentLink($type=self::PERMANENT_LINK_POST)
appendBody($a_body)
Append body text.
static _getInstallationSignature()

References ilMail\_getInstallationSignature(), ilMailNotification\appendBody(), and getPermanentLink().

Referenced by sendMailWithAttachments(), and sendMailWithoutAttachments().

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

◆ addMailSubject()

ilForumMailNotification::addMailSubject ( string  $subject)
private

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

392 {
393 $this->initMail();
394
395 $this->setSubject(sprintf(
397 $this->provider->getForumTitle(),
398 $this->provider->getThreadTitle()
399 ));
400 }

References ilMailNotification\getLanguageText(), initMail(), and setSubject().

Referenced by createMail().

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

◆ appendAttachments()

ilForumMailNotification::appendAttachments ( )
protected

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

88 {
89 if (count($this->provider->getAttachments()) > 0) {
90 $this->logger->debug('Adding attachments ...');
91 foreach ($this->provider->getAttachments() as $attachment) {
92 $this->appendBody($this->getLanguageText('attachment') . ": " . $attachment . "\n");
93 }
94 $this->appendBody("\n------------------------------------------------------------\n");
95 $this->setAttachments($this->provider->getAttachments());
96 }
97 }
setAttachments($a_att)
Set attachments.

References ilMailNotification\appendBody(), ilMailNotification\getLanguageText(), and ilMailNotification\setAttachments().

Referenced by sendMailWithAttachments().

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

◆ createMail()

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

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

353 {
354 $date = $this->createMailDate($date);
355
356 $this->addMailSubject($subject);
357
358 $this->setBody(ilMail::getSalutation($userId, $this->getLanguage()));
359 $this->appendBody("\n\n");
360 $this->appendBody($customText);
361 $this->appendBody("\n\n");
362 $this->appendBody($this->getLanguageText('forum') . ": " . $this->provider->getForumTitle());
363 $this->appendBody("\n\n");
364 $this->appendBody($this->getLanguageText('thread') . ": " . $this->provider->getThreadTitle());
365 $this->appendBody("\n\n");
366 $this->appendBody($this->getLanguageText($action) . ": \n------------------------------------------------------------\n");
367
368 $this->appendBody($this->getLanguageText('author') . ": " . $this->provider->getPostUserName($this->getLanguage()));
369 $this->appendBody("\n");
370 $this->appendBody($this->getLanguageText('date') . ": " . $date);
371 $this->appendBody("\n");
372 $this->appendBody($this->getLanguageText('subject') . ": " . $this->provider->getPostTitle());
373 $this->appendBody("\n");
374 $this->appendBody($this->getLanguageText('frm_noti_message'));
375 $this->appendBody("\n");
376
377 $message = strip_tags($this->getSecurePostMessage());
378
379 if ($this->provider->getPostCensored() == 1) {
380 $message = $this->provider->getCensorshipComment();
381 }
382
383 $this->appendBody($message . "\n");
384 $this->appendBody("------------------------------------------------------------\n");
385 }
static getSalutation($a_usr_id, ilLanguage $a_language=null)
$message
Definition: xapiexit.php:14

References $message, addMailSubject(), ilMailNotification\appendBody(), createMailDate(), ilMailNotification\getLanguage(), ilMailNotification\getLanguageText(), ilMail\getSalutation(), getSecurePostMessage(), and ilMailNotification\setBody().

Referenced by sendMailWithAttachments(), and sendMailWithoutAttachments().

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

◆ createMailDate()

ilForumMailNotification::createMailDate ( string  $date)
private

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

408 : string
409 {
411
412 if ($date === '') {
413 $date = $this->provider->getPostDate();
414 }
415
417
418 return $date;
419 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setLanguage($a_lng)
set language
@classDescription Date and time handling
language()
Definition: language.php:2

References ilDatePresentation\formatDate(), IL_CAL_DATETIME, language(), and ilDatePresentation\setLanguage().

Referenced by createMail().

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

◆ getPermanentLink()

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

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

228 {
229 global $DIC;
230 $ilClientIniFile = $DIC['ilClientIniFile'];
231
232 if ($type == self::PERMANENT_LINK_FORUM) {
233 $language_text = $this->getLanguageText("forums_notification_show_frm");
234 $forum_parameters = $this->provider->getRefId();
235 } else {
236 $language_text = $this->getLanguageText("forums_notification_show_post");
237 $forum_parameters = $this->provider->getRefId() . "_" . $this->provider->getThreadId() . "_" . $this->provider->getPostId();
238 }
239
240 $this->logger->debug(sprintf(
241 'Building permanent with parameters %s',
242 $forum_parameters
243 ));
244
245 if ($this->isCronjob()) {
246 $posting_link = sprintf(
247 $language_text,
248 ilUtil::_getHttpPath() . "/goto.php?target=frm_" . $forum_parameters . '&client_id=' . CLIENT_ID
249 ) . "\n\n";
250
251 $posting_link .= sprintf(
252 $this->getLanguageText("forums_notification_intro"),
253 $ilClientIniFile->readVariable("client", "name"),
254 ilUtil::_getHttpPath() . '/?client_id=' . CLIENT_ID
255 ) . "\n\n";
256 } else {
257 $posting_link = sprintf(
258 $language_text,
259 ilUtil::_getHttpPath() . "/goto.php?target=frm_" . $forum_parameters . '&client_id=' . CLIENT_ID
260 ) . "\n\n";
261
262 $posting_link .= sprintf(
263 $this->getLanguageText("forums_notification_intro"),
264 $ilClientIniFile->readVariable("client", "name"),
265 ilUtil::_getHttpPath() . '/?client_id=' . CLIENT_ID
266 ) . "\n\n";
267 }
268
269 $this->logger->debug(sprintf(
270 'Link built: %s',
271 $posting_link
272 ));
273
274 return $posting_link;
275 }
static _getHttpPath()
$DIC
Definition: xapitoken.php:46

References $DIC, ilMailNotification\$type, ilUtil\_getHttpPath(), ilMailNotification\getLanguageText(), and isCronjob().

Referenced by addLinkToMail().

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

◆ getSecurePostMessage()

ilForumMailNotification::getSecurePostMessage ( )
private
Returns
string

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

281 {
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);
290 return $pos_message;
291 }
292 return strip_tags($pos_message);
293 }

Referenced by createMail().

+ Here is the caller graph for this function:

◆ initLanguage()

ilForumMailNotification::initLanguage (   $a_usr_id)
protected
Parameters
int$a_usr_id

Reimplemented from ilMailNotification.

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

202 {
203 parent::initLanguage($a_usr_id);
204 $this->language->loadLanguageModule('forum');
205 }

References language().

Referenced by send().

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

◆ initMail()

ilForumMailNotification::initMail ( )
protected

Returns
ilMail

Reimplemented from ilMailNotification.

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

55 {
56 $mail = parent::initMail();
57 $this->logger->debug('Initialized mail service');
58 return $mail;
59 }

References ilMailNotification\$mail.

Referenced by addMailSubject().

+ Here is the caller graph for this function:

◆ isCronjob()

ilForumMailNotification::isCronjob ( )
Returns
boolean

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

References $is_cronjob.

Referenced by getPermanentLink().

+ Here is the caller graph for this function:

◆ send()

ilForumMailNotification::send ( )
Returns
bool

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

103 {
104 global $DIC;
105 $ilSetting = $DIC->settings();
106 $lng = $DIC->language();
107
108 if (!$ilSetting->get('forum_notification', 0)) {
109 $this->logger->debug('Forum notifications are globally disabled');
110 return false;
111 }
112
113 if (!$this->getRecipients()) {
114 $this->logger->debug('No notification recipients, nothing to do');
115 return false;
116 }
117
118 $lng->loadLanguageModule('forum');
119
122
123 switch ($this->getType()) {
125 foreach ($this->getRecipients() as $rcp) {
126 $this->initLanguage($rcp);
127 $customText = sprintf($this->getLanguageText('thread_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle());
128 $this->sendMailWithoutAttachments('frm_noti_subject_del_thread', (int) $rcp, (string) $customText, 'content_deleted_thread');
129 }
130 break;
131
133 foreach ($this->getRecipients() as $rcp) {
134 $this->initLanguage($rcp);
135 $customText = sprintf($this->getLanguageText('frm_noti_new_post'), $this->provider->getForumTitle());
136 $this->sendMailWithAttachments('frm_noti_subject_new_post', (int) $rcp, (string) $customText, 'new_post');
137 }
138 break;
139
141 foreach ($this->getRecipients() as $rcp) {
142 $this->initLanguage($rcp);
143 $customText = $this->getLanguageText('forums_post_activation_mail');
144 $this->sendMailWithAttachments('frm_noti_subject_act_post', (int) $rcp, (string) $customText, 'new_post');
145 }
146 break;
147
149 foreach ($this->getRecipients() as $rcp) {
150 $this->initLanguage($rcp);
151 $customText = $this->getLanguageText('forum_post_replied');
152 $this->sendMailWithAttachments('frm_noti_subject_answ_post', (int) $rcp, (string) $customText, 'new_post');
153 }
154 break;
155
157 foreach ($this->getRecipients() as $rcp) {
158 $this->initLanguage($rcp);
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);
162 }
163 break;
164
166 foreach ($this->getRecipients() as $rcp) {
167 $this->initLanguage($rcp);
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);
171 }
172 break;
173
175 foreach ($this->getRecipients() as $rcp) {
176 $this->initLanguage($rcp);
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);
180 }
181 break;
182
184 foreach ($this->getRecipients() as $rcp) {
185 $this->initLanguage($rcp);
186 $customText = sprintf($this->getLanguageText('post_deleted_by'), $this->provider->getDeletedBy(), $this->provider->getForumTitle());
187 $this->sendMailWithoutAttachments('frm_noti_subject_del_post', (int) $rcp, (string) $customText, 'content_deleted_post');
188 }
189 break;
190 }
191
194
195 return true;
196 }
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
sendMailWithoutAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail without attachments.
sendMailWithAttachments(string $subjectLanguageId, int $userId, string $customText, string $action, string $date='')
Add body and send mail with attachments.
getType()
Get notification type.
getRecipients()
get array of recipients
global $ilSetting
Definition: privfeed.php:17
$lng

References $DIC, $ilSetting, $lng, ilMailNotification\getLanguageText(), ilMailNotification\getRecipients(), ilMailNotification\getType(), initLanguage(), 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,
  $a_parse_recipients = true 
)

Parameters
array$a_rcp
bool | true$a_parse_recipients

Reimplemented from ilMailNotification.

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

65 {
66 $this->logger->debug(sprintf(
67 'Delegating notification transport to mail service for recipients: %s',
68 print_r($a_rcp, true)
69 ));
70 parent::sendMail($a_rcp, $a_parse_recipients);
71 $this->logger->debug('Notification transport delegated');
72 }

Referenced by sendMailWithAttachments(), and sendMailWithoutAttachments().

+ Here is the caller graph for this function:

◆ sendMailWithAttachments()

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

Add body and send mail with attachments.

Parameters
string$subjectLanguageId- Language id of subject
int$userId- id of the user recipient of the mail
string$customText- mail text after salutation
string$action- Language id of action
string | null$date- date to be added in mail

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

310 {
311 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
312 $this->appendAttachments();
313 $this->addLinkToMail();
314 $this->sendMail(array($userId));
315 }
createMail(string $subject, int $userId, string $customText, string $action, string $date)
sendMail(array $a_rcp, $a_parse_recipients=true)

References addLinkToMail(), appendAttachments(), createMail(), and sendMail().

Referenced by send().

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

◆ sendMailWithoutAttachments()

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

Add body and send mail without attachments.

Parameters
string$subjectLanguageId- Language id of subject
int$userId- id of the user recipient of the mail
string$customText- mail text after salutation
string$action- Language id of action
string | null$date- date to be added in mail

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

332 {
333 $this->createMail($subjectLanguageId, $userId, $customText, $action, $date);
334 $this->addLinkToMail();
335 $this->sendMail(array($userId));
336 }

References addLinkToMail(), createMail(), and sendMail().

Referenced by send().

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

◆ setIsCronjob()

ilForumMailNotification::setIsCronjob (   $is_cronjob)
Parameters
boolean$is_cronjob

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

219 {
220 $this->is_cronjob = (bool) $is_cronjob;
221 }

References $is_cronjob.

◆ setSubject()

ilForumMailNotification::setSubject (   $a_subject)
protected

Parameters
string$a_subject
Returns
string body

Reimplemented from ilMailNotification.

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

78 {
79 $value = parent::setSubject($a_subject);
80 $this->logger->debug(sprintf('Setting subject to: %s', $a_subject));
81 return $value;
82 }

Referenced by addMailSubject().

+ Here is the caller graph for this function:

Field Documentation

◆ $is_cronjob

ilForumMailNotification::$is_cronjob = false
protected

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

Referenced by isCronjob(), and setIsCronjob().

◆ $logger

ilForumMailNotification::$logger
protected

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

Referenced by __construct().

◆ $provider

ilForumMailNotification::$provider
protected

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

Referenced by __construct().

◆ PERMANENT_LINK_FORUM

const ilForumMailNotification::PERMANENT_LINK_FORUM = 'PL_Forum'

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

◆ PERMANENT_LINK_POST

const ilForumMailNotification::PERMANENT_LINK_POST = 'PL_Post'

Definition at line 21 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

const ilForumMailNotification::TYPE_POST_DELETED = 64

◆ 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

const ilForumMailNotification::TYPE_THREAD_DELETED = 54

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