ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSessionMembershipMailNotification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Mail/classes/class.ilMailNotification.php';
5
13{
16
19
20
23
26
30
34
38 public function __construct()
39 {
41 }
42
47 public function send($userId = '')
48 {
49 global $DIC;
50
51 $ilSetting = $DIC['ilSetting'];
52
53 // parent::send();
54
55 switch ($this->getType()) {
57
58 // automatic mails about status change disabled
59 if (!$ilSetting->get('mail_grp_member_notification', false)) {
60 return;
61 }
62
63 foreach ($this->getRecipients() as $rcp) {
64 $this->initLanguage($rcp);
65 $this->initMail();
66 $this->setSubject(
67 sprintf($this->getLanguageText('grp_mail_admission_new_sub'), $this->getObjectTitle(true))
68 );
69 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
70 $this->appendBody("\n\n");
71 $this->appendBody(
72 sprintf($this->getLanguageText('grp_mail_admission_new_bod'), $this->getObjectTitle())
73 );
74 $this->appendBody("\n\n");
75 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
76 $this->appendBody("\n\n");
77 $this->appendBody($this->createPermanentLink());
78 $this->getMail()->appendInstallationSignature(true);
79
80 $this->sendMail(array($rcp));
81 }
82 break;
83
85
86 // automatic mails about status change disabled
87 if (!$ilSetting->get('mail_grp_member_notification', false)) {
88 return;
89 }
90
91 foreach ($this->getRecipients() as $rcp) {
92 $this->initLanguage($rcp);
93 $this->initMail();
94 $this->setSubject(
95 sprintf($this->getLanguageText('grp_mail_dismiss_sub'), $this->getObjectTitle(true))
96 );
97 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
98 $this->appendBody("\n\n");
99 $this->appendBody(
100 sprintf($this->getLanguageText('grp_mail_dismiss_bod'), $this->getObjectTitle())
101 );
102 $this->getMail()->appendInstallationSignature(true);
103 $this->sendMail(array($rcp));
104 }
105 break;
106
107
108
109
111
112 foreach ($this->getRecipients() as $rcp) {
113 $this->initLanguage($rcp);
114 $this->initMail();
115 $this->setSubject(
116 sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'), $this->getObjectTitle(true))
117 );
118 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
119 $this->appendBody("\n\n");
120 $this->appendBody(
121 sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'), $this->getObjectTitle())
122 );
123
124 $this->appendBody("\n\n");
125 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
126 $this->appendBody("\n\n");
127 $this->appendBody($this->createPermanentLink());
128 $this->getMail()->appendInstallationSignature(true);
129
130 $this->sendMail(array($rcp));
131 }
132 break;
133
134
136
137 foreach ($this->getRecipients() as $rcp) {
138 $this->initLanguage($rcp);
139 $this->initMail();
140 $this->setSubject(
141 sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'), $this->getObjectTitle(true))
142 );
143 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
144 $this->appendBody("\n\n");
145
146 $info = $this->getAdditionalInformation();
147 $this->appendBody(
148 sprintf(
149 $this->getLanguageText('grp_mail_notification_reg_req_bod'),
150 $this->userToString($info['usr_id']),
151 $this->getObjectTitle()
152 )
153 );
154 $this->appendBody("\n\n");
155 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
156 $this->appendBody("\n");
157 $this->appendBody($this->createPermanentLink(array(), '_mem'));
158
159 $this->appendBody("\n\n");
160 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
161
162 $this->getMail()->appendInstallationSignature(true);
163 $this->sendMail(array($rcp));
164 }
165 break;
166
168
169 foreach ($this->getRecipients() as $rcp) {
170 $this->initLanguage($rcp);
171 $this->initMail();
172 $this->setSubject(
173 sprintf($this->getLanguageText('sess_mail_sub_dec_sub'), $this->getObjectTitle(true))
174 );
175 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
176 $this->appendBody("\n\n");
177 $this->appendBody(
178 sprintf($this->getLanguageText('sess_mail_sub_dec_bod'), $this->getObjectTitle())
179 );
180
181 $this->getMail()->appendInstallationSignature(true);
182
183 $this->sendMail(array($rcp));
184 }
185 break;
186
188
189 foreach ($this->getRecipients() as $rcp) {
190 $this->initLanguage($rcp);
191 $this->initMail();
192 $this->setSubject(
193 sprintf($this->getLanguageText('sess_mail_sub_acc_sub'), $this->getObjectTitle(true))
194 );
195 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
196 $this->appendBody("\n\n");
197 $this->appendBody(
198 sprintf($this->getLanguageText('sess_mail_sub_acc_bod'), $this->getObjectTitle())
199 );
200 $this->appendBody("\n\n");
201 $this->appendBody($this->getLanguageText('sess_mail_permanent_link'));
202 $this->appendBody("\n\n");
203 $this->appendBody($this->createPermanentLink());
204 $this->getMail()->appendInstallationSignature(true);
205
206 $this->sendMail(array($rcp));
207 }
208 break;
209
211 if ('' === $userId) {
212 throw new ilException('No user id given');
213 }
214
215 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
216 if (!$userObject || !($userObject instanceof \ilObjUser)) {
217 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
218 }
219
220 foreach ($this->getRecipients() as $rcp) {
221 $this->initLanguage($rcp);
222 $this->initMail();
223 $this->setSubject(
224 sprintf(
225 $this->getLanguageText('session_mail_subject_entered'),
226 $userObject->getFullname(),
227 $this->getObjectTitle(true)
228 )
229 );
230 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
231 $this->appendBody("\n\n");
232 $this->appendBody(
233 sprintf(
234 $this->getLanguageText('entered_notification'),
235 $userObject->getFullname(),
236 $this->getObjectTitle()
237 )
238 );
239 $this->appendBody("\n\n");
240 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
241 $this->appendBody("\n\n");
242 $this->appendBody($this->createPermanentLink([], '_part'));
243 $this->getMail()->appendInstallationSignature(true);
244
245 $this->sendMail(array($rcp), array('system'));
246 }
247 break;
248
250 if ('' === $userId) {
251 throw new ilException('No user id given');
252 }
253
254 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
255 if (!$userObject || !($userObject instanceof \ilObjUser)) {
256 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
257 }
258
259 foreach ($this->getRecipients() as $rcp) {
260 $this->initLanguage($rcp);
261 $this->initMail();
262 $this->setSubject(
263 sprintf(
264 $this->getLanguageText('session_mail_subject_registered'),
265 $userObject->getFullname(),
266 $this->getObjectTitle(true)
267 )
268 );
269 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
270 $this->appendBody("\n\n");
271 $this->appendBody(
272 sprintf(
273 $this->getLanguageText('register_notification'),
274 $userObject->getFullname(),
275 $this->getObjectTitle()
276 )
277 );
278 $this->appendBody("\n\n");
279 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
280 $this->appendBody("\n\n");
281 $this->appendBody($this->createPermanentLink([], '_part'));
282 $this->getMail()->appendInstallationSignature(true);
283
284 $this->sendMail(array($rcp), array('system'));
285 }
286 break;
287
289 if ('' === $userId) {
290 throw new ilException('No user id given');
291 }
292
293 $userObject = ilObjectFactory::getInstanceByObjId($userId, false);
294 if (!$userObject || !($userObject instanceof \ilObjUser)) {
295 throw new ilException(sprintf('User with ID "%s" does not exist.', $userId));
296 }
297
298 foreach ($this->getRecipients() as $rcp) {
299 $this->initLanguage($rcp);
300 $this->initMail();
301 $this->setSubject(
302 sprintf(
303 $this->getLanguageText('session_mail_subject_deletion'),
304 $userObject->getFullname(),
305 $this->getObjectTitle(true)
306 )
307 );
308 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
309 $this->appendBody("\n\n");
310 $this->appendBody(
311 sprintf(
312 $this->getLanguageText('deletion_notification'),
313 $userObject->getFullname(),
314 $this->getObjectTitle()
315 )
316 );
317 $this->appendBody("\n\n");
318 $this->appendBody($this->getLanguageText('sess_mail_permanent_link_participants'));
319 $this->appendBody("\n\n");
320 $this->appendBody($this->createPermanentLink([], '_part'));
321 $this->getMail()->appendInstallationSignature(true);
322
323 $this->sendMail(array($rcp), array('system'));
324 }
325 break;
326 }
327 return true;
328 }
329
335 protected function initLanguage($a_usr_id)
336 {
337 parent::initLanguage($a_usr_id);
338 $this->getLanguage()->loadLanguageModule('sess');
339 }
340}
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
getType()
Get notification type.
sendMail(array $a_rcp, $a_parse_recipients=true)
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
createPermanentLink($a_params=array(), $a_append='')
static getSalutation($a_usr_id, ilLanguage $a_language=null)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$DIC
Definition: xapitoken.php:46