ILIAS  release_8 Revision v8.24
class.ilSessionMembershipMailNotification.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
29{
30 public const TYPE_ADMISSION_MEMBER = 20;
31 public const TYPE_DISMISS_MEMBER = 21;
32
35
36
37 public const TYPE_BLOCKED_MEMBER = 25;
38 public const TYPE_UNBLOCKED_MEMBER = 26;
39
40 public const TYPE_UNSUBSCRIBE_MEMBER = 27;
41 public const TYPE_SUBSCRIBE_MEMBER = 28;
42
46
47 public const TYPE_ENTER_NOTIFICATION = 100;
48 public const TYPE_REGISTER_NOTIFICATION = 101;
49 public const TYPE_UNREGISTER_NOTIFICATION = 102;
50
52
53 public function __construct()
54 {
55 global $DIC;
56
57 $this->setting = $DIC->settings();
58
60 }
61
62 public function send(int $userId = 0): ?bool
63 {
65
66 // parent::send();
67
68 switch ($this->getType()) {
70
71 // automatic mails about status change disabled
72 if (!$ilSetting->get('mail_grp_member_notification')) {
73 return null;
74 }
75
76 foreach ($this->getRecipients() as $rcp) {
77 $this->initLanguage($rcp);
78 $this->initMail();
79 $this->setSubject(
80 sprintf($this->getLanguageText('grp_mail_admission_new_sub'), $this->getObjectTitle(true))
81 );
82 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
83 $this->appendBody("\n\n");
84 $this->appendBody(
85 sprintf($this->getLanguageText('grp_mail_admission_new_bod'), $this->getObjectTitle())
86 );
87 $this->appendBody("\n\n");
88 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
89 $this->appendBody("\n\n");
90 $this->appendBody($this->createPermanentLink());
91 $this->getMail()->appendInstallationSignature(true);
92
93 $this->sendMail(array($rcp));
94 }
95 break;
96
98
99 // automatic mails about status change disabled
100 if (!$ilSetting->get('mail_grp_member_notification')) {
101 return null;
102 }
103
104 foreach ($this->getRecipients() as $rcp) {
105 $this->initLanguage($rcp);
106 $this->initMail();
107 $this->setSubject(
108 sprintf($this->getLanguageText('grp_mail_dismiss_sub'), $this->getObjectTitle(true))
109 );
110 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
111 $this->appendBody("\n\n");
112 $this->appendBody(
113 sprintf($this->getLanguageText('grp_mail_dismiss_bod'), $this->getObjectTitle())
114 );
115 $this->getMail()->appendInstallationSignature(true);
116 $this->sendMail(array($rcp));
117 }
118 break;
119
121
122 foreach ($this->getRecipients() as $rcp) {
123 $this->initLanguage($rcp);
124 $this->initMail();
125 $this->setSubject(
126 sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'), $this->getObjectTitle(true))
127 );
128 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
129 $this->appendBody("\n\n");
130 $this->appendBody(
131 sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'), $this->getObjectTitle())
132 );
133
134 $this->appendBody("\n\n");
135 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
136 $this->appendBody("\n\n");
137 $this->appendBody($this->createPermanentLink());
138 $this->getMail()->appendInstallationSignature(true);
139
140 $this->sendMail(array($rcp));
141 }
142 break;
143
145
146 foreach ($this->getRecipients() as $rcp) {
147 $this->initLanguage($rcp);
148 $this->initMail();
149 $this->setSubject(
150 sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'), $this->getObjectTitle(true))
151 );
152 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
153 $this->appendBody("\n\n");
154
155 $info = $this->getAdditionalInformation();
156 $this->appendBody(
157 sprintf(
158 $this->getLanguageText('grp_mail_notification_reg_req_bod'),
159 $this->userToString($info['usr_id']),
160 $this->getObjectTitle()
161 )
162 );
163 $this->appendBody("\n\n");
164 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
165 $this->appendBody("\n");
166 $this->appendBody($this->createPermanentLink([], '_mem'));
167
168 $this->appendBody("\n\n");
169 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
170
171 $this->getMail()->appendInstallationSignature(true);
172 $this->sendMail(array($rcp));
173 }
174 break;
175
177
178 foreach ($this->getRecipients() as $rcp) {
179 $this->initLanguage($rcp);
180 $this->initMail();
181 $this->setSubject(
182 sprintf($this->getLanguageText('sess_mail_sub_dec_sub'), $this->getObjectTitle(true))
183 );
184 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
185 $this->appendBody("\n\n");
186 $this->appendBody(
187 sprintf($this->getLanguageText('sess_mail_sub_dec_bod'), $this->getObjectTitle())
188 );
189
190 $this->getMail()->appendInstallationSignature(true);
191
192 $this->sendMail(array($rcp));
193 }
194 break;
195
197
198 foreach ($this->getRecipients() as $rcp) {
199 $this->initLanguage($rcp);
200 $this->initMail();
201 $this->setSubject(
202 sprintf($this->getLanguageText('sess_mail_sub_acc_sub'), $this->getObjectTitle(true))
203 );
204 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
205 $this->appendBody("\n\n");
206 $this->appendBody(
207 sprintf($this->getLanguageText('sess_mail_sub_acc_bod'), $this->getObjectTitle())
208 );
209 $this->appendBody("\n\n");
210 $this->appendBody($this->getLanguageText('sess_mail_permanent_link'));
211 $this->appendBody("\n\n");
212 $this->appendBody($this->createPermanentLink());
213 $this->getMail()->appendInstallationSignature(true);
214
215 $this->sendMail(array($rcp));
216 }
217 break;
218
220 if (0 === $userId) {
221 throw new ilException('No user id given');
222 }
223
224 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
225 if (!($userObject instanceof \ilObjUser)) {
226 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
227 }
228
229 foreach ($this->getRecipients() as $rcp) {
230 $this->initLanguage($rcp);
231 $this->initMail();
232 $this->setSubject(
233 sprintf(
234 $this->getLanguageText('session_mail_subject_entered'),
235 $userObject->getFullname(),
236 $this->getObjectTitle(true)
237 )
238 );
239 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
240 $this->appendBody("\n\n");
241 $this->appendBody(
242 sprintf(
243 $this->getLanguageText('entered_notification'),
244 $userObject->getFullname(),
245 $this->getObjectTitle()
246 )
247 );
248 $this->appendBody("\n\n");
249 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
250 $this->appendBody("\n\n");
251 $this->appendBody($this->createPermanentLink([], '_part'));
252 $this->getMail()->appendInstallationSignature(true);
253
254 $this->sendMail(array($rcp));
255 }
256 break;
257
259 if (0 === $userId) {
260 throw new ilException('No user id given');
261 }
262
263 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
264 if (!($userObject instanceof \ilObjUser)) {
265 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
266 }
267
268 foreach ($this->getRecipients() as $rcp) {
269 $this->initLanguage($rcp);
270 $this->initMail();
271 $this->setSubject(
272 sprintf(
273 $this->getLanguageText('session_mail_subject_registered'),
274 $userObject->getFullname(),
275 $this->getObjectTitle(true)
276 )
277 );
278 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
279 $this->appendBody("\n\n");
280 $this->appendBody(
281 sprintf(
282 $this->getLanguageText('register_notification'),
283 $userObject->getFullname(),
284 $this->getObjectTitle()
285 )
286 );
287 $this->appendBody("\n\n");
288 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
289 $this->appendBody("\n\n");
290 $this->appendBody($this->createPermanentLink([], '_part'));
291 $this->getMail()->appendInstallationSignature(true);
292
293 $this->sendMail(array($rcp));
294 }
295 break;
296
298 if (0 === $userId) {
299 throw new ilException('No user id given');
300 }
301
302 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
303 if (!($userObject instanceof \ilObjUser)) {
304 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
305 }
306
307 foreach ($this->getRecipients() as $rcp) {
308 $this->initLanguage($rcp);
309 $this->initMail();
310 $this->setSubject(
311 sprintf(
312 $this->getLanguageText('session_mail_subject_deletion'),
313 $userObject->getFullname(),
314 $this->getObjectTitle(true)
315 )
316 );
317 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
318 $this->appendBody("\n\n");
319 $this->appendBody(
320 sprintf(
321 $this->getLanguageText('deletion_notification'),
322 $userObject->getFullname(),
323 $this->getObjectTitle()
324 )
325 );
326 $this->appendBody("\n\n");
327 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
328 $this->appendBody("\n\n");
329 $this->appendBody($this->createPermanentLink([], '_part'));
330 $this->getMail()->appendInstallationSignature(true);
331
332 $this->sendMail(array($rcp));
333 }
334 break;
335 }
336 return true;
337 }
338
339 protected function initLanguage(int $a_usr_id): void
340 {
341 parent::initLanguage($a_usr_id);
342 $this->getLanguage()->loadLanguageModule('sess');
343 }
344}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for course/group mail notifications.
getObjectTitle(bool $a_shorten=false)
sendMail(array $a_rcp, bool $a_parse_recipients=true)
createPermanentLink(array $a_params=[], string $a_append='')
getLanguageText(string $a_keyword)
setSubject(string $a_subject)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
User class.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17