ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSystemNotification Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilSystemNotification:
+ Collaboration diagram for ilSystemNotification:

Public Member Functions

 __construct (protected bool $is_in_wsp=false)
 
 setSubjectLangId (string $a_lang_id)
 
 setSubjectDirect (string $a_text)
 
 setIntroductionLangId (string $a_lang_id)
 
 setIntroductionDirect (string $a_text)
 
 setTaskLangId (string $a_lang_id)
 
 setReasonLangId (string $a_lang_id)
 
 setGotoLangId (string $a_lang_id)
 
 setChangedByUserId (int $a_id)
 
 addAdditionalInfo (string $a_lang_id, string $a_value, bool $a_multiline=false, bool $a_lang_direct=false)
 Add additional information. More...
 
 sendMailAndReturnRecipients (array $a_user_ids, ?string $a_goto_additional=null, string $a_permission="read")
 Send notification(s) More...
 
 compose (int $a_user_id, ?string $a_goto_additional=null, string $a_permission="read", bool $a_append_signature_direct=false)
 Compose notification to single recipient. More...
 
 composeAndGetMessage (int $a_user_id, ?string $a_goto_additional=null, string $a_permission="read", bool $a_append_signature_direct=false)
 Compose notification to single recipient. More...
 
- Public Member Functions inherited from ilMailNotification
 __construct (protected bool $is_in_wsp=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 ()
 

Protected Member Functions

 composeAndSendMail (int $a_user_id, ?string $a_goto_additional=null, string $a_permission="read")
 Send notification to single recipient. More...
 
- Protected Member Functions inherited from ilMailNotification
 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

string $subject_lang_id = ""
 
string $subject_direct = ""
 
string $introduction = ""
 
string $introduction_direct = ""
 
string $task = ""
 
string $reason = ""
 
array $additional = []
 
string $goto_caption = ""
 
int $changed_by = 0
 
array $all_ref_ids = []
 
- Protected Attributes inherited from ilMailNotification
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 = []
 
ilWorkspaceTree $wsp_tree
 
ilWorkspaceAccessHandler $wsp_access_handler
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
final const int SUBJECT_TITLE_LENGTH = 60
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Wrapper classes for system notifications

See also
FeatureWiki/Guidelines/System Notification Guideline
Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilSystemNotification::__construct ( protected bool  $is_in_wsp = false)

Reimplemented from ilMailNotification.

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

40 {
41 parent::__construct($is_in_wsp);
42 $this->ref_id = 0;
43 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalInfo()

ilSystemNotification::addAdditionalInfo ( string  $a_lang_id,
string  $a_value,
bool  $a_multiline = false,
bool  $a_lang_direct = false 
)

Add additional information.

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

93 : void {
94 $this->additional[$a_lang_id] = array(trim($a_value), $a_multiline, $a_lang_direct);
95 }

◆ compose()

ilSystemNotification::compose ( int  $a_user_id,
?string  $a_goto_additional = null,
string  $a_permission = "read",
bool  $a_append_signature_direct = false 
)

Compose notification to single recipient.

Definition at line 151 of file class.ilSystemNotification.php.

156 : bool {
157 $find_ref_id = false;
158 $this->initLanguage($a_user_id);
159 $this->initMail();
160 if ($this->subject_direct) {
161 $this->setSubject($this->subject_direct);
162 } else {
163 $this->setSubject(
164 sprintf($this->getLanguageText($this->subject_lang_id), $this->getObjectTitle(true))
165 );
166 }
167
168 $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
169 $this->appendBody("\n\n");
170
171 if ($this->introduction) {
172 $this->appendBody($this->getLanguageText($this->introduction));
173 $this->appendBody("\n\n");
174 }
175
176 if ($this->introduction_direct) {
177 $this->appendBody($this->introduction_direct);
178 $this->appendBody("\n\n");
179 }
180
181 if ($this->task) {
182 $this->appendBody($this->getLanguageText($this->task));
183 $this->appendBody("\n\n");
184 }
185
186 // details table
187 if ($this->getObjId()) {
188 $this->appendBody($this->getLanguageText("obj_" . $this->getObjType()) . ": " .
189 $this->getObjectTitle() . "\n");
190 }
191 if (count($this->additional) > 0) {
192 foreach ($this->additional as $lang_id => $item) {
193 $caption = "";
194 if ($lang_id) {
195 $caption = (!$item[2])
196 ? $this->getLanguageText($lang_id)
197 : $lang_id;
198 }
199 if (!$item[1]) {
200 if ($caption) {
201 $caption .= ": ";
202 }
203 $this->appendBody($caption . $item[0] . "\n");
204 } else {
205 if ($caption) {
206 $caption .= "\n";
207 }
208 $this->appendBody("\n" . $caption .
209 $this->getBlockBorder() .
210 $item[0] . "\n" .
211 $this->getBlockBorder() . "\n");
212 }
213 }
214 }
215 $this->body = trim($this->body);
216 $this->appendBody("\n\n");
217
218 if ($this->changed_by) {
219 $this->appendBody($this->getLanguageText("system_notification_installation_changed_by") . ": " .
220 ilUserUtil::getNamePresentation($this->changed_by));
221 $this->appendBody("\n\n");
222 }
223
224 if ($this->getObjId()) {
225 // try to find accessible ref_id
226 if (!$this->getRefId() && $this->all_ref_ids) {
227 $find_ref_id = true;
228 foreach ($this->all_ref_ids as $ref_id) {
229 if ($this->isRefIdAccessible($a_user_id, $ref_id, $a_permission)) {
230 $this->ref_id = $ref_id;
231 break;
232 }
233 }
234 }
235
236 // check if initially given ref_id is accessible for current recipient
237 if ($this->getRefId() &&
238 !$find_ref_id &&
239 !$this->isRefIdAccessible($a_user_id, $this->getRefId(), $a_permission)) {
240 return false;
241 }
242
243 $goto = $this->createPermanentLink(array(), (string) $a_goto_additional);
244 if ($goto) {
245 $this->appendBody($this->getLanguageText($this->goto_caption) . ": " .
246 $goto);
247 $this->appendBody("\n\n");
248 }
249
250 if ($find_ref_id) {
251 $this->ref_id = 0;
252 }
253 }
254
255 if ($this->reason) {
256 $this->appendBody($this->getLanguageText($this->reason));
257 $this->appendBody("\n\n");
258 }
259
261
262 // signature will append new lines
263 $this->body = trim($this->body);
264
265 if (!$a_append_signature_direct) {
266 $this->getMail()->appendInstallationSignature(true);
267 } else {
269 }
270
271 return true;
272 }
getObjectTitle(bool $a_shorten=false)
createPermanentLink(array $a_params=[], string $a_append='')
getLanguageText(string $a_keyword)
isRefIdAccessible(int $a_user_id, int $a_ref_id, string $a_permission='read')
setSubject(string $a_subject)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:

◆ composeAndGetMessage()

ilSystemNotification::composeAndGetMessage ( int  $a_user_id,
?string  $a_goto_additional = null,
string  $a_permission = "read",
bool  $a_append_signature_direct = false 
)

Compose notification to single recipient.

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

297 : string {
298 if ($this->compose($a_user_id, $a_goto_additional, $a_permission, $a_append_signature_direct)) {
299 return $this->body;
300 }
301 return "";
302 }
compose(int $a_user_id, ?string $a_goto_additional=null, string $a_permission="read", bool $a_append_signature_direct=false)
Compose notification to single recipient.

◆ composeAndSendMail()

ilSystemNotification::composeAndSendMail ( int  $a_user_id,
?string  $a_goto_additional = null,
string  $a_permission = "read" 
)
protected

Send notification to single recipient.

Definition at line 277 of file class.ilSystemNotification.php.

281 : bool {
282 if ($this->compose($a_user_id, $a_goto_additional, $a_permission)) {
283 $this->sendMail(array($a_user_id), is_numeric($a_user_id));
284 return true;
285 }
286 return false;
287 }
sendMail(array $a_rcp, bool $a_parse_recipients=true)

◆ sendMailAndReturnRecipients()

ilSystemNotification::sendMailAndReturnRecipients ( array  $a_user_ids,
?string  $a_goto_additional = null,
string  $a_permission = "read" 
)

Send notification(s)

Parameters
array$a_user_ids
?string$a_goto_additional
string$a_permission
Returns
array recipient ids

Definition at line 105 of file class.ilSystemNotification.php.

109 : array {
110 $this->all_ref_ids = null;
111
112 // prepare object related info
113 if ($this->getObjId()) {
114 if (!$this->getRefId()) {
115 // try to find ref_id(s)
116 if (!$this->is_in_wsp) {
117 $ref_ids = ilObject::_getAllReferences($this->getObjId());
118 if (count($ref_ids) === 1) {
119 $this->ref_id = array_shift($ref_ids);
120 } else {
121 $this->all_ref_ids = $ref_ids;
122 }
123 }
124 } elseif ($this->is_in_wsp) { // #11680
125 $this->ref_id = $this->wsp_tree->lookupNodeId($this->getObjId());
126 }
127
128 // default values
129 if (!$this->goto_caption) {
130 $this->goto_caption = "url";
131 }
132 }
133
134 $recipient_ids = array();
135 foreach (array_unique($a_user_ids) as $user_id) {
136 // author of change should not get notification
137 if ($this->changed_by === $user_id) {
138 continue;
139 }
140 if ($this->composeAndSendMail($user_id, $a_goto_additional, $a_permission)) {
141 $recipient_ids[] = $user_id;
142 }
143 }
144
145 return $recipient_ids;
146 }
static _getAllReferences(int $id)
get all reference ids for object ID
composeAndSendMail(int $a_user_id, ?string $a_goto_additional=null, string $a_permission="read")
Send notification to single recipient.

References ilObject\_getAllReferences().

+ Here is the call graph for this function:

◆ setChangedByUserId()

ilSystemNotification::setChangedByUserId ( int  $a_id)

Definition at line 80 of file class.ilSystemNotification.php.

80 : void
81 {
82 $this->changed_by = $a_id;
83 }

◆ setGotoLangId()

ilSystemNotification::setGotoLangId ( string  $a_lang_id)

Definition at line 75 of file class.ilSystemNotification.php.

75 : void
76 {
77 $this->goto_caption = $a_lang_id;
78 }

◆ setIntroductionDirect()

ilSystemNotification::setIntroductionDirect ( string  $a_text)

Definition at line 60 of file class.ilSystemNotification.php.

60 : void
61 {
62 $this->introduction_direct = trim($a_text);
63 }

◆ setIntroductionLangId()

ilSystemNotification::setIntroductionLangId ( string  $a_lang_id)

Definition at line 55 of file class.ilSystemNotification.php.

55 : void
56 {
57 $this->introduction = $a_lang_id;
58 }

◆ setReasonLangId()

ilSystemNotification::setReasonLangId ( string  $a_lang_id)

Definition at line 70 of file class.ilSystemNotification.php.

70 : void
71 {
72 $this->reason = $a_lang_id;
73 }

◆ setSubjectDirect()

ilSystemNotification::setSubjectDirect ( string  $a_text)

Definition at line 50 of file class.ilSystemNotification.php.

50 : void
51 {
52 $this->subject_direct = trim($a_text);
53 }

◆ setSubjectLangId()

ilSystemNotification::setSubjectLangId ( string  $a_lang_id)

Definition at line 45 of file class.ilSystemNotification.php.

45 : void
46 {
47 $this->subject_lang_id = $a_lang_id;
48 }

◆ setTaskLangId()

ilSystemNotification::setTaskLangId ( string  $a_lang_id)

Definition at line 65 of file class.ilSystemNotification.php.

65 : void
66 {
67 $this->task = $a_lang_id;
68 }

Field Documentation

◆ $additional

array ilSystemNotification::$additional = []
protected

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

◆ $all_ref_ids

array ilSystemNotification::$all_ref_ids = []
protected

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

◆ $changed_by

int ilSystemNotification::$changed_by = 0
protected

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

◆ $goto_caption

string ilSystemNotification::$goto_caption = ""
protected

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

◆ $introduction

string ilSystemNotification::$introduction = ""
protected

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

◆ $introduction_direct

string ilSystemNotification::$introduction_direct = ""
protected

Definition at line 31 of file class.ilSystemNotification.php.

◆ $reason

string ilSystemNotification::$reason = ""
protected

Definition at line 33 of file class.ilSystemNotification.php.

◆ $subject_direct

string ilSystemNotification::$subject_direct = ""
protected

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

◆ $subject_lang_id

string ilSystemNotification::$subject_lang_id = ""
protected

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

◆ $task

string ilSystemNotification::$task = ""
protected

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


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