ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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)
 Constructor. More...
 
 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 ($a_rcp)
 set mail recipients More...
 
 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)
 Set ref id. More...
 
 getRefId ()
 get reference id More...
 
 getObjId ()
 get object id More...
 
 setObjId ($a_obj_id)
 set obj id More...
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation ($a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 Get additional information for generating notification mails. More...
 
 sendMail ($a_rcp, $a_type, $a_parse_recipients=true)
 Send Mail. More...
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

Data Fields

const SUBJECT_TITLE_LENGTH = 60
 

Protected Member Functions

 setSubject ($a_subject)
 Set mail subject. More...
 
 getSubject ()
 Get mail subject. More...
 
 setBody ($a_body)
 Set mail body. More...
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 Get body. More...
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 A language. More...
 
 getLanguage ()
 get language object More...
 
 getLanguageText ($a_keyword)
 Replace new lines. More...
 
 getObjectTitle ($a_shorten=false)
 Get object title. More...
 
 initMail ()
 Init mail. More...
 
 getMail ()
 Get mail object. More...
 
 createPermanentLink ($a_params=array(), $a_append='')
 Create a permanent link for an object. More...
 
 userToString ($a_usr_id)
 Utility function. More...
 
 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)

Constructor.

Parameters
bool$a_is_personal_workspace
Returns

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

50 {
51 global $lng, $ilUser;
52
53 $this->is_in_wsp = (bool)$a_is_personal_workspace;
54
55 $this->setSender(ANONYMOUS_USER_ID);
56 $this->language = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
57
58 if($this->is_in_wsp)
59 {
60 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
61 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
62 $this->wsp_tree = new ilWorkspaceTree($ilUser->getId()); // owner of tree is irrelevant
63 $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
64 }
65 }
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.
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15

References $ilUser, $lng, ilLanguageFactory\_getLanguage(), and setSender().

+ Here is the call graph for this function:

Member Function Documentation

◆ appendBody()

◆ createPermanentLink()

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

Create a permanent link for an object.

Returns

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

432 {
433 include_once './Services/Link/classes/class.ilLink.php';
434
435 if($this->getRefId())
436 {
437 if(!$this->is_in_wsp)
438 {
439 return ilLink::_getLink($this->ref_id,$this->getObjType(),$a_params,$a_append);
440 }
441 else
442 {
443 return ilWorkspaceAccessHandler::getGotoLink($this->getRefId(), $this->getObjId(), $a_append);
444 }
445 }
446 else
447 {
448 // Return root
449 return ilLink::_getLink(ROOT_FOLDER_ID,'root');
450 }
451 }
static getGotoLink($a_node_id, $a_obj_id, $a_additional=null)

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

Referenced by ilSystemNotification\compose(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilLMMailNotification\send(), ilSessionMembershipMailNotification\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 185 of file class.ilMailNotification.php.

186 {
187 return (array) $this->attachments;
188 }

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 503 of file class.ilMailNotification.php.

504 {
505 return "----------------------------------------\n";
506 }

Referenced by ilSystemNotification\compose().

+ Here is the caller graph for this function:

◆ getBody()

ilMailNotification::getBody ( )
protected

Get body.

Returns
string

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

149 {
150 return $this->body;
151 }

References $body.

Referenced by ilMailSummaryNotification\send(), ilPaymentNotification\send(), sendMail(), and ilMimeMailNotification\sendMimeMail().

+ Here is the caller graph for this function:

◆ getLanguage()

◆ getLanguageText()

◆ getMail()

◆ getObjectTitle()

ilMailNotification::getObjectTitle (   $a_shorten = false)
protected

Get object title.

Parameters
boolshorten title
Returns

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

359 {
360 if(!$this->getObjId())
361 {
362 return '';
363 }
365 if((bool)$a_shorten)
366 {
367 $txt = ilUtil::shortenText($txt, self::SUBJECT_TITLE_LENGTH,true);
368 }
369 return $txt;
370 }
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:10

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

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

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

◆ getObjId()

ilMailNotification::getObjId ( )

◆ getObjType()

ilMailNotification::getObjType ( )

Get object type.

Returns

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

References $obj_type.

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

+ Here is the caller graph for this function:

◆ getRecipients()

◆ getRefId()

ilMailNotification::getRefId ( )

get reference id

Returns

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

References $ref_id.

Referenced by ilSystemNotification\compose(), createPermanentLink(), ilCourseMembershipMailNotification\send(), ilCalendarMailNotification\send(), ilSystemNotification\sendMail(), and setRefId().

+ Here is the caller graph for this function:

◆ getSender()

ilMailNotification::getSender ( )

get sender of mail

Returns

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

Get mail subject.

Returns
string

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

References $subject.

Referenced by ilMailSummaryNotification\send(), ilPaymentNotification\send(), 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 214 of file class.ilMailNotification.php.

215 {
217 $language->loadLanguageModule('mail');
218
219 if(sizeof($this->lang_modules))
220 {
221 foreach($this->lang_modules as $lmod)
222 {
223 $language->loadLanguageModule($lmod);
224 }
225 }
226
227 return $language;
228 }
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 ilMimeMailNotification, and ilCronDeleteInactiveUserReminderMailNotification.

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

235 {
236 $this->language = ilLanguageFactory::_getLanguage($a_code);
237 $this->language->loadLanguageModule('mail');
238
239 if(sizeof($this->lang_modules))
240 {
241 foreach($this->lang_modules as $lmod)
242 {
243 $this->language->loadLanguageModule($lmod);
244 }
245 }
246 }

References ilLanguageFactory\_getLanguage().

+ 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 474 of file class.ilMailNotification.php.

475 {
476 global $ilAccess;
477
478 // no given permission == accessible
479
480 if(!$this->is_in_wsp)
481 {
482 if(trim($a_permission) &&
483 !$ilAccess->checkAccessOfUser($a_user_id, $a_permission, "", $a_ref_id, $this->getObjType()))
484 {
485 return false;
486 }
487 }
488 else
489 {
490 if(trim($a_permission) &&
491 !$this->wsp_access_handler->checkAccessOfUser($this->wsp_tree, $a_user_id, $a_permission, "", $a_ref_id, $this->getObjType()))
492 {
493 return false;
494 }
495 }
496 return true;
497 }

Referenced by ilSystemNotification\compose().

+ Here is the caller graph for this function:

◆ sendMail()

ilMailNotification::sendMail (   $a_rcp,
  $a_type,
  $a_parse_recipients = true 
)

Send Mail.

Parameters
arrayrecipients
arraymail type (one 'normal', 'system', 'email')
Returns

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

379 {
380 $recipients = array();
381 foreach($a_rcp as $rcp)
382 {
383 if($a_parse_recipients)
384 {
386 }
387 else
388 {
389 $recipients[] = $rcp;
390 }
391 }
392 $recipients = implode(',',$recipients);
393 $error = $this->getMail()->sendMail(
395 '',
396 '',
397 $this->getSubject(),
398 $this->getBody(),
399 $this->getAttachments(),
400 $a_type
401 );
402
403 if(strlen($error))
404 {
405 $GLOBALS['ilLog']->write(__METHOD__.': '.$error);
406 }
407 }
getSubject()
Get mail subject.
_lookupLogin($a_user_id)
lookup login
$GLOBALS['ct_recipient']

References $GLOBALS, $recipients, ilObjUser\_lookupLogin(), getAttachments(), getBody(), getMail(), and getSubject().

Referenced by ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilLMMailNotification\send(), ilSessionMembershipMailNotification\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 (   $a_info)

Additional information for creating notification mails.

Parameters
array$a_info
Returns

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

340 {
341 $this->additional_info = $a_info;
342 }

◆ setAttachments()

ilMailNotification::setAttachments (   $a_att)

Set attachments

Parameters
array$a_att

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

177 {
178 $this->attachments = $a_att;
179 }

Referenced by ilCalendarMailNotification\addAttachment(), 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 194 of file class.ilMailNotification.php.

195 {
196 $this->lang_modules = $a_modules;
197 }

◆ setLanguage()

ilMailNotification::setLanguage (   $a_language)
protected

A language.

Parameters
ilLanguage$a_language

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

253 {
254 $this->language = $a_language;
255 }

Referenced by ilCalendarMailNotification\send().

+ Here is the caller graph for this function:

◆ setObjId()

ilMailNotification::setObjId (   $a_obj_id)

set obj id

Returns

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

320 {
321 $this->obj_id = $a_obj_id;
322 $this->obj_type = ilObject::_lookupType($this->obj_id);
323 }
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 (   $a_rcp)

set mail recipients

Parameters
array$a_rcpuser ids
Returns

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

159 {
160 $this->recipients = $a_rcp;
161 }

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

+ Here is the caller graph for this function:

◆ setRefId()

ilMailNotification::setRefId (   $a_id)

Set ref id.

Parameters
int$a_id
Returns

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

282 {
283 if(!$this->is_in_wsp)
284 {
285 $this->ref_id = $a_id;
286 $obj_id = ilObject::_lookupObjId($this->ref_id);
287 }
288 else
289 {
290 $this->ref_id = (int)$a_id;
291 $obj_id = $this->wsp_tree->lookupObjectId($this->getRefId());
292 }
293
294 $this->setObjId($obj_id);
295 }
setObjId($a_obj_id)
set obj id
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
Returns

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

92 {
93 $this->sender = $a_usr_id;
94 }

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
Returns

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

73 {
74 $this->type = $a_type;
75 }

◆ userToString()

ilMailNotification::userToString (   $a_usr_id)
protected

Utility function.

Parameters
int$a_usr_id
Returns

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

459 {
460 $name = ilObjUser::_lookupName($a_usr_id);
461 return ($name['title'] ? $name['title'].' ' : '').
462 ($name['firstname'] ? $name['firstname'].' ' : '').
463 ($name['lastname'] ? $name['lastname'].' ' : '');
464 }
static _lookupName($a_user_id)
lookup user name

References ilObjUser\_lookupName().

Referenced by ilCourseMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), and ilSessionMembershipMailNotification\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

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

Referenced by ilMailSummaryNotification\send().

◆ $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(), and ilMailSummaryNotification\send().

◆ $subject

ilMailNotification::$subject = ''
protected

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

Referenced by getSubject().

◆ $type

ilMailNotification::$type = null
protected

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

Referenced by getType().

◆ $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: