ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilMailNotification Class Reference

Base class for course/group mail notifications. More...

+ Inheritance diagram for ilMailNotification:
+ Collaboration diagram for ilMailNotification:

Public Member Functions

 __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 SUBJECT_TITLE_LENGTH = 60
 

Protected Member Functions

 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

 $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
 

Detailed Description

Base class for course/group mail notifications.

Version
$Id$
Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 16 of file class.ilMailNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailNotification::__construct (   $a_is_personal_workspace = false)
Parameters
bool | false$a_is_personal_workspace

Reimplemented in ilLMMailNotification, ilDiskQuotaSummaryNotification, ilMailCronOrphanedMailsNotification, and ilMailSummaryNotification.

Definition at line 47 of file class.ilMailNotification.php.

48 {
49 global $DIC;
50
51 $this->is_in_wsp = (bool) $a_is_personal_workspace;
52
53 $this->setSender(ANONYMOUS_USER_ID);
54 $this->language = ilLanguageFactory::_getLanguage($DIC->language()->getDefaultLanguage());
55
56 if ($this->is_in_wsp) {
57 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
58 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
59 $this->wsp_tree = new ilWorkspaceTree($DIC->user()->getId()); // owner of tree is irrelevant
60 $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
61 }
62 }
static _getLanguage($a_lang_key='')
Get langauge object.
setSender($a_usr_id)
Set sender of mail.
Access handler for personal workspace.
Tree handler for personal workspace.
language()
Definition: language.php:2
$DIC
Definition: xapitoken.php:46

References $DIC, ilLanguageFactory\_getLanguage(), language(), and setSender().

+ Here is the call graph for this function:

Member Function Documentation

◆ appendBody()

◆ createPermanentLink()

ilMailNotification::createPermanentLink (   $a_params = array(),
  $a_append = '' 
)
protected
Parameters
array$a_params
string$a_append
Returns
string

Definition at line 392 of file class.ilMailNotification.php.

393 {
394 include_once './Services/Link/classes/class.ilLink.php';
395
396 if ($this->getRefId()) {
397 if (!$this->is_in_wsp) {
398 return ilLink::_getLink($this->ref_id, $this->getObjType(), $a_params, $a_append);
399 } else {
400 return ilWorkspaceAccessHandler::getGotoLink($this->getRefId(), $this->getObjId(), $a_append);
401 }
402 } else {
403 // Return root
404 return ilLink::_getLink(ROOT_FOLDER_ID, 'root');
405 }
406 }
static getGotoLink($a_node_id, $a_obj_id, $a_additional=null)

References ilLink\_getLink(), ilWorkspaceAccessHandler\getGotoLink(), getObjId(), getObjType(), and getRefId().

Referenced by ilSystemNotification\compose(), ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), and ilCalendarMailNotification\send().

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

◆ getAdditionalInformation()

◆ getAttachments()

ilMailNotification::getAttachments ( )

Get attachments.

Returns
array

Definition at line 173 of file class.ilMailNotification.php.

174 {
175 return (array) $this->attachments;
176 }

References $attachments.

Referenced by ilCalendarMailNotification\deleteAttachments(), and sendMail().

+ Here is the caller graph for this function:

◆ getBlockBorder()

ilMailNotification::getBlockBorder ( )

Get (ascii) block border.

Returns
string

Definition at line 452 of file class.ilMailNotification.php.

453 {
454 return "----------------------------------------\n";
455 }

Referenced by ilSystemNotification\compose().

+ Here is the caller graph for this function:

◆ getBody()

ilMailNotification::getBody ( )
protected
Returns
string

Definition at line 138 of file class.ilMailNotification.php.

139 {
140 return $this->body;
141 }

References $body.

Referenced by sendMail(), and ilMimeMailNotification\sendMimeMail().

+ Here is the caller graph for this function:

◆ getLanguage()

ilMailNotification::getLanguage ( )
protected
Returns
ilLanguage

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

References $language.

Referenced by ilTestManScoringParticipantNotification\__construct(), ilTestManScoringParticipantNotification\buildBody(), ilMailCronOrphanedMailsNotification\buildFolderTitle(), ilSystemNotification\compose(), ilForumMailNotification\createMail(), ilMailEventNotificationSender\createMailBodyText(), getLanguageText(), ilCourseMembershipMailNotification\initLanguage(), ilExerciseMailNotification\initLanguage(), ilGroupMembershipMailNotification\initLanguage(), ilLMMailNotification\initLanguage(), ilSessionMembershipMailNotification\initLanguage(), ilMimeMailNotification\initLanguage(), ilRegistrationMailNotification\initLanguage(), ilLearningSequenceMembershipMailNotification\initLanguage(), ilMailCronOrphanedMailsNotification\initLanguageByIso2Code(), ilMimeMailNotification\initLanguageByIso2Code(), ilCronDeleteInactiveUserReminderMailNotification\initLanguageByIso2Code(), ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilCalendarMailNotification\send(), ilDiskQuotaSummaryNotification\send(), ilMailCronOrphanedMailsNotification\send(), ilRegistrationMailNotification\send(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), and ilTestMailNotification\sendSimpleNotification().

+ Here is the caller graph for this function:

◆ getLanguageText()

ilMailNotification::getLanguageText (   $a_keyword)
protected
Parameters
string$a_keyword
Returns
string

Definition at line 252 of file class.ilMailNotification.php.

253 {
254 return str_replace('\n', "\n", $this->getLanguage()->txt($a_keyword));
255 }

References getLanguage().

Referenced by ilForumMailNotification\addMailSubject(), ilForumMailNotification\appendAttachments(), ilTestManScoringParticipantNotification\buildBody(), ilTestManScoringParticipantNotification\buildSubject(), ilSystemNotification\compose(), ilMailEventNotificationSender\createAttachmentText(), ilCourseMembershipMailNotification\createCourseStatus(), ilGroupMembershipMailNotification\createGroupStatus(), ilLearningSequenceMembershipMailNotification\createLearningSequenceStatus(), ilForumMailNotification\createMail(), ilMailEventNotificationSender\createMailBodyText(), ilMailEventNotificationSender\createSubjectText(), ilForumMailNotification\getPermanentLink(), ilMailEventNotificationSender\getPermanentLink(), ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilForumMailNotification\send(), ilMailEventNotificationSender\send(), ilGroupMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilCalendarMailNotification\send(), and ilRegistrationMailNotification\send().

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

◆ getMail()

◆ getObjectTitle()

ilMailNotification::getObjectTitle (   $a_shorten = false)
protected
Parameters
bool | false$a_shorten
Returns
string

Definition at line 328 of file class.ilMailNotification.php.

329 {
330 if (!$this->getObjId()) {
331 return '';
332 }
334 if ((bool) $a_shorten) {
335 $txt = ilUtil::shortenText($txt, self::SUBJECT_TITLE_LENGTH, true);
336 }
337 return $txt;
338 }
static _lookupTitle($a_id)
lookup object title
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
$txt
Definition: error.php:13

References $txt, ilObject\_lookupTitle(), getObjId(), and ilUtil\shortenText().

Referenced by ilSystemNotification\compose(), ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), and ilCalendarMailNotification\send().

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

◆ getObjId()

◆ getObjType()

ilMailNotification::getObjType ( )

Get object type.

Returns

Definition at line 302 of file class.ilMailNotification.php.

References $obj_type.

Referenced by ilSystemNotification\compose(), and createPermanentLink().

+ Here is the caller graph for this function:

◆ getRecipients()

◆ getRefId()

◆ getSender()

ilMailNotification::getSender ( )

get sender of mail

Returns

Definition at line 95 of file class.ilMailNotification.php.

References $sender.

Referenced by ilCalendarMailNotification\addAttachment(), ilCalendarMailNotification\deleteAttachments(), and initMail().

+ Here is the caller graph for this function:

◆ getSubject()

ilMailNotification::getSubject ( )
protected
Returns
string

Definition at line 112 of file class.ilMailNotification.php.

References $subject.

Referenced by sendMail(), and ilMimeMailNotification\sendMimeMail().

+ Here is the caller graph for this function:

◆ getType()

◆ getUserLanguage()

ilMailNotification::getUserLanguage (   $a_usr_id)

Get user language.

Parameters
int$a_usr_id
Returns
ilLanguage

Definition at line 202 of file class.ilMailNotification.php.

203 {
205 $language->loadLanguageModule('mail');
206
207 if (sizeof($this->lang_modules)) {
208 foreach ($this->lang_modules as $lmod) {
209 $language->loadLanguageModule($lmod);
210 }
211 }
212
213 return $language;
214 }
static _getLanguageOfUser($a_usr_id)
Get language object of user.

References $language, and ilLanguageFactory\_getLanguageOfUser().

Referenced by initLanguage().

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

◆ initLanguage()

◆ initLanguageByIso2Code()

ilMailNotification::initLanguageByIso2Code (   $a_code = '')
protected

Init language by ISO2 code.

Parameters
string$a_code

Reimplemented in ilMailCronOrphanedMailsNotification, ilMimeMailNotification, and ilCronDeleteInactiveUserReminderMailNotification.

Definition at line 220 of file class.ilMailNotification.php.

221 {
223 $this->language->loadLanguageModule('mail');
224
225 if (sizeof($this->lang_modules)) {
226 foreach ($this->lang_modules as $lmod) {
227 $this->language->loadLanguageModule($lmod);
228 }
229 }
230 }

References ilLanguageFactory\_getLanguage(), and language().

+ Here is the call graph for this function:

◆ initMail()

◆ isRefIdAccessible()

ilMailNotification::isRefIdAccessible (   $a_user_id,
  $a_ref_id,
  $a_permission = "read" 
)
protected

Check if ref id is accessible for user.

Parameters
int$a_user_id
int$a_ref_id
string$a_permission
Returns
bool

Definition at line 428 of file class.ilMailNotification.php.

429 {
430 global $DIC;
431
432 // no given permission == accessible
433
434 if (!$this->is_in_wsp) {
435 if (trim($a_permission) &&
436 !$DIC->access()->checkAccessOfUser($a_user_id, $a_permission, "", $a_ref_id, $this->getObjType())) {
437 return false;
438 }
439 } else {
440 if (trim($a_permission) &&
441 !$this->wsp_access_handler->checkAccessOfUser($this->wsp_tree, $a_user_id, $a_permission, "", $a_ref_id, $this->getObjType())) {
442 return false;
443 }
444 }
445 return true;
446 }

References $DIC.

Referenced by ilSystemNotification\compose().

+ Here is the caller graph for this function:

◆ sendMail()

ilMailNotification::sendMail ( array  $a_rcp,
  $a_parse_recipients = true 
)
Parameters
array$a_rcp
bool | true$a_parse_recipients

Reimplemented in ilForumMailNotification, and ilMailEventNotificationSender.

Definition at line 344 of file class.ilMailNotification.php.

345 {
346 $recipients = array();
347 foreach ($a_rcp as $rcp) {
348 if ($a_parse_recipients) {
350 } else {
351 $recipients[] = $rcp;
352 }
353 }
354 $recipients = implode(',', $recipients);
355 $errors = $this->getMail()->enqueue(
357 '',
358 '',
359 $this->getSubject(),
360 $this->getBody(),
361 $this->getAttachments()
362 );
363 // smeyer: 19.5.16 fixed strlen warning, since $error is of type array
364 if (count($errors) > 0) {
365 require_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
367 //ilLoggerFactory::getLogger('mail')->error($error);
368 }
369 }
static getLogger($a_component_id)
Get component logger.
getAttachments()
Get attachments.
static _lookupLogin($a_user_id)
lookup login
$errors

References $errors, $recipients, ilObjUser\_lookupLogin(), ilLogLevel\ERROR, getAttachments(), getBody(), ilLoggerFactory\getLogger(), getMail(), and getSubject().

Referenced by ilWorkflowEngineMailNotification\send(), ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilTestManScoringParticipantNotification\send(), ilCalendarMailNotification\send(), ilDiskQuotaSummaryNotification\send(), ilRegistrationMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), and ilTestMailNotification\sendSimpleNotification().

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

◆ setAdditionalInformation()

ilMailNotification::setAdditionalInformation ( array  $a_info)

Additional information for creating notification mails.

Parameters
array$a_info

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

312 {
313 $this->additional_info = $a_info;
314 }

◆ setAttachments()

ilMailNotification::setAttachments (   $a_att)

Set attachments.

Parameters
array$a_att

Definition at line 164 of file class.ilMailNotification.php.

165 {
166 $this->attachments = $a_att;
167 }

Referenced by ilCalendarMailNotification\addAttachment(), ilForumMailNotification\appendAttachments(), and ilTestMailNotification\sendAdvancedNotification().

+ Here is the caller graph for this function:

◆ setBody()

◆ setLangModules()

ilMailNotification::setLangModules ( array  $a_modules)

Set lang modules.

Parameters
array$a_modules

Definition at line 182 of file class.ilMailNotification.php.

183 {
184 $this->lang_modules = $a_modules;
185 }

Referenced by ilIndividualAssessmentPrimitiveInternalNotificator\__construct().

+ Here is the caller graph for this function:

◆ setLanguage()

ilMailNotification::setLanguage (   $a_language)
protected
Parameters
ilLanguage$a_language

Definition at line 235 of file class.ilMailNotification.php.

236 {
237 $this->language = $a_language;
238 }

References language().

Referenced by ilCalendarMailNotification\send().

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

◆ setObjId()

ilMailNotification::setObjId (   $a_obj_id)
Parameters
int$a_obj_id

Definition at line 292 of file class.ilMailNotification.php.

293 {
294 $this->obj_id = $a_obj_id;
295 $this->obj_type = ilObject::_lookupType($this->obj_id);
296 }
static _lookupType($a_id, $a_reference=false)
lookup object type

References ilObject\_lookupType().

Referenced by setRefId().

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

◆ setRecipients()

ilMailNotification::setRecipients ( array  $a_rcp)
Parameters
array$a_rcp

Definition at line 146 of file class.ilMailNotification.php.

147 {
148 $this->recipients = $a_rcp;
149 }

Referenced by ilDiskQuotaSummaryNotification\__construct(), and ilTestManScoringParticipantNotification\setRecipient().

+ Here is the caller graph for this function:

◆ setRefId()

ilMailNotification::setRefId (   $a_id)
Parameters
int$a_id

Definition at line 260 of file class.ilMailNotification.php.

261 {
262 if (!$this->is_in_wsp) {
263 $this->ref_id = $a_id;
264 $obj_id = ilObject::_lookupObjId($this->ref_id);
265 } else {
266 $this->ref_id = (int) $a_id;
267 $obj_id = $this->wsp_tree->lookupObjectId($this->getRefId());
268 }
269
270 $this->setObjId($obj_id);
271 }
static _lookupObjId($a_id)

References $obj_id, ilObject\_lookupObjId(), getRefId(), and setObjId().

Referenced by ilTestManScoringParticipantNotification\__construct().

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

◆ setSender()

ilMailNotification::setSender (   $a_usr_id)

Set sender of mail.

Parameters
int$a_usr_id

Definition at line 86 of file class.ilMailNotification.php.

87 {
88 $this->sender = $a_usr_id;
89 }

Referenced by __construct(), and ilCalendarMailNotification\__construct().

+ Here is the caller graph for this function:

◆ setSubject()

◆ setType()

ilMailNotification::setType (   $a_type)

Set notification type.

Parameters
int$a_type

Definition at line 68 of file class.ilMailNotification.php.

69 {
70 $this->type = $a_type;
71 }
$a_type
Definition: workflow.php:92

References $a_type.

◆ userToString()

ilMailNotification::userToString (   $a_usr_id)
protected
Parameters
int$a_usr_id
Returns
string

Definition at line 412 of file class.ilMailNotification.php.

413 {
414 $name = ilObjUser::_lookupName($a_usr_id);
415 return ($name['title'] ? $name['title'] . ' ' : '') .
416 ($name['firstname'] ? $name['firstname'] . ' ' : '') .
417 ($name['lastname'] ? $name['lastname'] . ' ' : '');
418 }
static _lookupName($a_user_id)
lookup user name
if($format !==null) $name
Definition: metadata.php:230

References $name, and ilObjUser\_lookupName().

Referenced by ilSessionMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), and ilLearningSequenceMembershipMailNotification\send().

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

Field Documentation

◆ $additional_info

ilMailNotification::$additional_info = array()
protected

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

Referenced by getAdditionalInformation().

◆ $attachments

ilMailNotification::$attachments = array()
protected

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

Referenced by getAttachments().

◆ $body

◆ $is_in_wsp

ilMailNotification::$is_in_wsp
protected

Definition at line 40 of file class.ilMailNotification.php.

◆ $lang_modules

ilMailNotification::$lang_modules = array()
protected

Definition at line 30 of file class.ilMailNotification.php.

◆ $language

ilMailNotification::$language = null
protected

Definition at line 29 of file class.ilMailNotification.php.

Referenced by getLanguage(), and getUserLanguage().

◆ $mail

ilMailNotification::$mail = null
protected

◆ $obj_id

ilMailNotification::$obj_id = null
protected

Definition at line 35 of file class.ilMailNotification.php.

Referenced by getObjId(), and setRefId().

◆ $obj_type

ilMailNotification::$obj_type = null
protected

Definition at line 36 of file class.ilMailNotification.php.

Referenced by getObjType().

◆ $recipients

ilMailNotification::$recipients = array()
protected

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

Referenced by getRecipients(), and sendMail().

◆ $ref_id

ilMailNotification::$ref_id = null
protected

Definition at line 34 of file class.ilMailNotification.php.

Referenced by ilSystemNotification\compose(), and getRefId().

◆ $sender

ilMailNotification::$sender = null
protected

Definition at line 21 of file class.ilMailNotification.php.

Referenced by getSender().

◆ $subject

ilMailNotification::$subject = ''
protected

◆ $type

◆ $wsp_access_handler

ilMailNotification::$wsp_access_handler
protected

Definition at line 42 of file class.ilMailNotification.php.

◆ $wsp_tree

ilMailNotification::$wsp_tree
protected

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

◆ SUBJECT_TITLE_LENGTH

const ilMailNotification::SUBJECT_TITLE_LENGTH = 60

Definition at line 18 of file class.ilMailNotification.php.


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