ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)

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

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

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  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
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...
global $DIC
Definition: feed.php:28
static _getLanguage(string $a_lang_key='')
Get language object.
+ 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.

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

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

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  }
const ROOT_FOLDER_ID
Definition: constants.php:32
static getGotoLink(int $a_node_id, int $a_obj_id, string $a_additional="")
+ 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.

References $attachments.

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

123  : array
124  {
125  return $this->attachments;
126  }
+ Here is the caller graph for this function:

◆ getBlockBorder()

ilMailNotification::getBlockBorder ( )

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

Referenced by ilSystemNotification\compose().

322  : string
323  {
324  return "----------------------------------------\n";
325  }
+ Here is the caller graph for this function:

◆ getBody()

ilMailNotification::getBody ( )
protected

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

References $body.

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

103  : string
104  {
105  return $this->body;
106  }
+ Here is the caller graph for this function:

◆ getLanguage()

ilMailNotification::getLanguage ( )
protected

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

References $language.

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

169  : ilLanguage
170  {
171  return $this->language;
172  }
+ Here is the caller graph for this function:

◆ getLanguageText()

ilMailNotification::getLanguageText ( string  $a_keyword)
protected

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

References getLanguage().

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

174  : string
175  {
176  return str_replace('\n', "\n", $this->getLanguage()->txt($a_keyword));
177  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMail()

◆ getObjectTitle()

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

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

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

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

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)
$txt
Definition: error.php:13
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
+ 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.

References $obj_type.

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

208  : string
209  {
210  return $this->obj_type;
211  }
+ Here is the caller graph for this function:

◆ getRecipients()

◆ getRefId()

◆ getSender()

ilMailNotification::getSender ( )

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

References $sender.

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

74  : int
75  {
76  return $this->sender;
77  }
+ Here is the caller graph for this function:

◆ getSubject()

ilMailNotification::getSubject ( )
protected

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

References $subject.

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

88  : string
89  {
90  return $this->subject;
91  }
+ 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.

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

Referenced by initLanguage().

138  : ilLanguage
139  {
141  $language->loadLanguageModule('mail');
142 
143  if (count($this->lang_modules)) {
144  foreach ($this->lang_modules as $lmod) {
146  }
147  }
148 
149  return $language;
150  }
loadLanguageModule(string $a_module)
Load language module.
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLanguage()

◆ initLanguageByIso2Code()

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

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

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

152  : void
153  {
154  $this->language = ilLanguageFactory::_getLanguage($a_code);
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  }
static _getLanguage(string $a_lang_key='')
Get language object.
+ 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.

References $DIC, and getObjType().

Referenced by ilSystemNotification\compose().

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  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

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

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

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

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

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(
247  $recipients,
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.
$errors
Definition: imgupload.php:65
static _lookupLogin(int $a_user_id)
+ 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.

Referenced by ilTestScoringGUI\saveManScoringParticipantScreen().

213  : void
214  {
215  $this->additional_info = $a_info;
216  }
+ Here is the caller graph for this function:

◆ setAttachments()

ilMailNotification::setAttachments ( array  $a_att)

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

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

118  : void
119  {
120  $this->attachments = $a_att;
121  }
+ Here is the caller graph for this function:

◆ setBody()

◆ setLangModules()

ilMailNotification::setLangModules ( array  $a_modules)

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

Referenced by ilIndividualAssessmentPrimitiveInternalNotificator\__construct().

128  : void
129  {
130  $this->lang_modules = $a_modules;
131  }
+ Here is the caller graph for this function:

◆ setLanguage()

ilMailNotification::setLanguage ( ilLanguage  $a_language)
protected

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

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

Referenced by ilCalendarMailNotification\send().

164  : void
165  {
166  $this->language = $a_language;
167  }
+ 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.

References ilObject\_lookupType().

Referenced by setRefId().

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

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

108  : void
109  {
110  $this->recipients = $a_rcp;
111  }
+ Here is the caller graph for this function:

◆ setRefId()

ilMailNotification::setRefId ( int  $a_id)

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

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

Referenced by ilTestManScoringParticipantNotification\__construct().

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

Referenced by __construct().

69  : void
70  {
71  $this->sender = $a_usr_id;
72  }
+ 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.

References $name, and ilObjUser\_lookupName().

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

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

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

◆ $ref_id

int ilMailNotification::$ref_id
protected

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

Referenced by ilSystemNotification\compose(), and 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

◆ $type

int ilMailNotification::$type
protected

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