ILIAS  release_8 Revision v8.24
ilMailNotification Class Reference

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

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

Public Member Functions

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

Protected Member Functions

 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")
 

Protected Attributes

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

Base class for course/group mail notifications.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilMailNotification::__construct ( bool  $a_is_personal_workspace = false)

Reimplemented in ilGroupMembershipMailNotification, ilLMMailNotification, ilCalendarMailNotification, ilMailSummaryNotification, and ilMimeMailNotification.

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

47 {
48 global $DIC;
49 $this->is_in_wsp = $a_is_personal_workspace;
51 $this->language = ilLanguageFactory::_getLanguage($DIC->language()->getDefaultLanguage());
52
53 if ($this->is_in_wsp) {
54 $this->wsp_tree = new ilWorkspaceTree($DIC->user()->getId()); // owner of tree is irrelevant
55 $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
56 }
57 }
static _getLanguage(string $a_lang_key='')
Get language object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28

References $DIC, ilLanguageFactory\_getLanguage(), ANONYMOUS_USER_ID, ILIAS\UI\examples\Symbol\Glyph\Language\language(), and setSender().

+ Here is the call graph for this function:

Member Function Documentation

◆ appendBody()

◆ createPermanentLink()

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

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

269 : ?string
270 {
271 if ($this->getRefId()) {
272 if (!$this->is_in_wsp) {
273 return ilLink::_getLink($this->ref_id, $this->getObjType(), $a_params, $a_append);
274 }
275 return ilWorkspaceAccessHandler::getGotoLink($this->getRefId(), $this->getObjId(), $a_append);
276 }
277 return ilLink::_getLink(ROOT_FOLDER_ID, 'root');
278 }
static getGotoLink(int $a_node_id, int $a_obj_id, string $a_additional="")
const ROOT_FOLDER_ID
Definition: constants.php:32

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

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

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

◆ getAdditionalInformation()

◆ getAttachments()

ilMailNotification::getAttachments ( )

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

123 : array
124 {
125 return $this->attachments;
126 }

References $attachments.

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

+ Here is the caller graph for this function:

◆ getBlockBorder()

ilMailNotification::getBlockBorder ( )

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

322 : string
323 {
324 return "----------------------------------------\n";
325 }

◆ getBody()

ilMailNotification::getBody ( )
protected

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

103 : string
104 {
105 return $this->body;
106 }

References $body.

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

+ Here is the caller graph for this function:

◆ getLanguage()

ilMailNotification::getLanguage ( )
protected

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

169 : ilLanguage
170 {
171 return $this->language;
172 }
language handling

References $language.

Referenced by ilTestManScoringParticipantNotification\__construct(), ilTestManScoringParticipantNotification\buildBody(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\buildFolderTitle(), getLanguageText(), ilCourseMembershipMailNotification\initLanguage(), ilExerciseMailNotification\initLanguage(), ilGroupMembershipMailNotification\initLanguage(), ilLMMailNotification\initLanguage(), ilSessionMembershipMailNotification\initLanguage(), ilMimeMailNotification\initLanguage(), ilRegistrationMailNotification\initLanguage(), ilCronDeleteInactiveUserReminderMailNotification\initLanguage(), ilLearningSequenceMembershipMailNotification\initLanguage(), ilMimeMailNotification\initLanguageByIso2Code(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\initLanguageByIso2Code(), ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilCalendarMailNotification\send(), ilMailSummaryNotification\send(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\send(), ilRegistrationMailNotification\send(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilSessionMembershipMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), and ilTestMailNotification\sendSimpleNotification().

+ Here is the caller graph for this function:

◆ getLanguageText()

◆ getMail()

◆ getObjectTitle()

ilMailNotification::getObjectTitle ( bool  $a_shorten = false)
protected

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

223 : string
224 {
225 if (!$this->getObjId()) {
226 return '';
227 }
229 if ($a_shorten) {
230 $txt = ilStr::shortenTextExtended($txt, self::SUBJECT_TITLE_LENGTH, true);
231 }
232 return $txt;
233 }
static _lookupTitle(int $obj_id)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
$txt
Definition: error.php:13

References $txt, ilObject\_lookupTitle(), getObjId(), and ilStr\shortenTextExtended().

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

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

◆ getObjId()

◆ getObjType()

ilMailNotification::getObjType ( )

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

208 : string
209 {
210 return $this->obj_type;
211 }

References $obj_type.

Referenced by createPermanentLink().

+ Here is the caller graph for this function:

◆ getRecipients()

◆ getRefId()

◆ getSender()

ilMailNotification::getSender ( )

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

74 : int
75 {
76 return $this->sender;
77 }

References $sender.

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

+ Here is the caller graph for this function:

◆ getSubject()

ilMailNotification::getSubject ( )
protected

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

88 : string
89 {
90 return $this->subject;
91 }

References $subject.

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

+ Here is the caller graph for this function:

◆ getType()

◆ getUserLanguage()

ilMailNotification::getUserLanguage ( int  $a_usr_id)

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

138 : ilLanguage
139 {
142
143 if (count($this->lang_modules)) {
144 foreach ($this->lang_modules as $lmod) {
146 }
147 }
148
149 return $language;
150 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
loadLanguageModule(string $a_module)
Load language module.

References $language, ilLanguageFactory\_getLanguageOfUser(), and ilLanguage\loadLanguageModule().

Referenced by initLanguage().

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

◆ initLanguage()

◆ initLanguageByIso2Code()

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

Reimplemented in ilMimeMailNotification, and ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification.

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

152 : void
153 {
155 $this->language->loadLanguageModule('mail');
156
157 if (count($this->lang_modules)) {
158 foreach ($this->lang_modules as $lmod) {
159 $this->language->loadLanguageModule($lmod);
160 }
161 }
162 }

References ilLanguageFactory\_getLanguage(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ initMail()

◆ isRefIdAccessible()

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

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

288 : bool
289 {
290 global $DIC;
291
292 // no given permission == accessible
293
294 if (!$this->is_in_wsp) {
295 if (trim($a_permission) &&
296 !$DIC->access()->checkAccessOfUser(
297 $a_user_id,
298 $a_permission,
299 "",
300 $a_ref_id,
301 $this->getObjType()
302 )) {
303 return false;
304 }
305 } elseif (
306 trim($a_permission) &&
307 !$this->wsp_access_handler->checkAccessOfUser(
308 $this->wsp_tree,
309 $a_user_id,
310 $a_permission,
311 "",
312 $a_ref_id,
313 $this->getObjType()
314 )
315 ) {
316 return false;
317 }
318
319 return true;
320 }

References $DIC.

◆ sendMail()

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

Reimplemented in ilForumMailNotification, and ilForumMailEventNotificationSender.

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

235 : void
236 {
237 $recipients = [];
238 foreach ($a_rcp as $rcp) {
239 if ($a_parse_recipients) {
240 $recipients[] = ilObjUser::_lookupLogin((int) $rcp);
241 } else {
242 $recipients[] = $rcp;
243 }
244 }
245 $recipients = implode(',', $recipients);
246 $errors = $this->getMail()->enqueue(
248 '',
249 '',
250 $this->getSubject(),
251 $this->getBody(),
252 $this->getAttachments()
253 );
254 if (count($errors) > 0) {
256 }
257 }
static getLogger(string $a_component_id)
Get component logger.
static _lookupLogin(int $a_user_id)
$errors
Definition: imgupload.php:65

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

Referenced by ilCourseMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilGroupMembershipMailNotification\send(), ilLMMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilTestManScoringParticipantNotification\send(), ilCalendarMailNotification\send(), ilRegistrationMailNotification\send(), ilSessionMembershipMailNotification\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)

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

213 : void
214 {
215 $this->additional_info = $a_info;
216 }

◆ setAttachments()

ilMailNotification::setAttachments ( array  $a_att)

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

118 : void
119 {
120 $this->attachments = $a_att;
121 }

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

+ Here is the caller graph for this function:

◆ setBody()

◆ setLangModules()

ilMailNotification::setLangModules ( array  $a_modules)

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

128 : void
129 {
130 $this->lang_modules = $a_modules;
131 }

Referenced by ilIndividualAssessmentPrimitiveInternalNotificator\__construct().

+ Here is the caller graph for this function:

◆ setLanguage()

ilMailNotification::setLanguage ( ilLanguage  $a_language)
protected

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

164 : void
165 {
166 $this->language = $a_language;
167 }

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

Referenced by ilCalendarMailNotification\send().

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

◆ setObjId()

ilMailNotification::setObjId ( int  $a_obj_id)

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

202 : void
203 {
204 $this->obj_id = $a_obj_id;
205 $this->obj_type = ilObject::_lookupType($this->obj_id);
206 }
static _lookupType(int $id, bool $reference=false)

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)

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

108 : void
109 {
110 $this->recipients = $a_rcp;
111 }

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

+ Here is the caller graph for this function:

◆ setRefId()

ilMailNotification::setRefId ( int  $a_id)

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

179 : void
180 {
181 if (!$this->is_in_wsp) {
182 $this->ref_id = $a_id;
183 $obj_id = ilObject::_lookupObjId($this->ref_id);
184 } else {
185 $this->ref_id = $a_id;
186 $obj_id = $this->wsp_tree->lookupObjectId($this->getRefId());
187 }
188
189 $this->setObjId($obj_id);
190 }
static _lookupObjId(int $ref_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 ( int  $a_usr_id)

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

69 : void
70 {
71 $this->sender = $a_usr_id;
72 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setSubject()

ilMailNotification::setSubject ( string  $a_subject)
protected

◆ setType()

ilMailNotification::setType ( int  $a_type)

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

59 : void
60 {
61 $this->type = $a_type;
62 }

◆ userToString()

ilMailNotification::userToString ( int  $a_usr_id)
protected

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

280 : string
281 {
282 $name = ilObjUser::_lookupName($a_usr_id);
283 return ($name['title'] ? $name['title'] . ' ' : '') .
284 ($name['firstname'] ? $name['firstname'] . ' ' : '') .
285 ($name['lastname'] ? $name['lastname'] . ' ' : '');
286 }
static _lookupName(int $a_user_id)
lookup user name
if($format !==null) $name
Definition: metadata.php:247

References $name, and ilObjUser\_lookupName().

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

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

Field Documentation

◆ $additional_info

array ilMailNotification::$additional_info = []
protected

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

Referenced by getAdditionalInformation().

◆ $attachments

array ilMailNotification::$attachments = []
protected

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

Referenced by getAttachments().

◆ $body

◆ $is_in_wsp

bool ilMailNotification::$is_in_wsp
protected

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

◆ $lang_modules

array ilMailNotification::$lang_modules = []
protected

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

◆ $language

ilLanguage ilMailNotification::$language
protected

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

Referenced by getLanguage(), and getUserLanguage().

◆ $mail

◆ $obj_id

int ilMailNotification::$obj_id = 0
protected

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

Referenced by getObjId(), and setRefId().

◆ $obj_type

string ilMailNotification::$obj_type = ''
protected

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

Referenced by getObjType().

◆ $recipients

array ilMailNotification::$recipients = []
protected

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

Referenced by getRecipients(), and sendMail().

◆ $ref_id

int ilMailNotification::$ref_id
protected

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

Referenced by getRefId().

◆ $sender

int ilMailNotification::$sender
protected

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

Referenced by getSender(), and ilMailSummaryNotification\send().

◆ $subject

string ilMailNotification::$subject = ''
protected

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

Referenced by getSubject().

◆ $type

◆ $wsp_access_handler

ilWorkspaceAccessHandler ilMailNotification::$wsp_access_handler
protected

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

◆ $wsp_tree

ilWorkspaceTree ilMailNotification::$wsp_tree
protected

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

◆ SUBJECT_TITLE_LENGTH

const ilMailNotification::SUBJECT_TITLE_LENGTH = 60

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


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