ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilGroupMembershipMailNotification.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{
14 // v Notifications affect members & co. v
17
20
22
25
29
30 // v Notifications affect admins v
34
41 self::TYPE_NOTIFICATION_REGISTRATION,
42 self::TYPE_NOTIFICATION_REGISTRATION_REQUEST,
43 self::TYPE_NOTIFICATION_UNSUBSCRIBE
44 );
45
46 private $force_sending_mail = false;
47
48
49
50
54 public function __construct()
55 {
56 parent::__construct();
57 }
58
63 public function forceSendingMail($a_status)
64 {
65 $this->force_sending_mail = $a_status;
66 }
67
68
69
74 public function send()
75 {
76 if(!$this->isNotificationTypeEnabled($this->getType()))
77 {
78 $GLOBALS['ilLog']->write(__METHOD__.': Membership mail disabled globally.');
79 return false;
80 }
81 // parent::send();
82
83 switch($this->getType())
84 {
86
87 foreach($this->getRecipients() as $rcp)
88 {
89 $this->initLanguage($rcp);
90 $this->initMail();
91 $this->setSubject(
92 sprintf($this->getLanguageText('grp_mail_admission_new_sub'),$this->getObjectTitle(true))
93 );
94 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
95 $this->appendBody("\n\n");
96 $this->appendBody(
97 sprintf($this->getLanguageText('grp_mail_admission_new_bod'),$this->getObjectTitle())
98 );
99 $this->appendBody("\n\n");
100 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
101 $this->appendBody("\n\n");
102 $this->appendBody($this->createPermanentLink());
103 $this->getMail()->appendInstallationSignature(true);
104
105 $this->sendMail(array($rcp),array('system'));
106 }
107 break;
108
110
111 foreach($this->getRecipients() as $rcp)
112 {
113 $this->initLanguage($rcp);
114 $this->initMail();
115 $this->setSubject(
116 sprintf($this->getLanguageText('grp_mail_dismiss_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_dismiss_bod'),$this->getObjectTitle())
122 );
123 $this->getMail()->appendInstallationSignature(true);
124 $this->sendMail(array($rcp),array('system'));
125 }
126 break;
127
128
130
131 foreach($this->getRecipients() as $rcp)
132 {
133 $this->initLanguage($rcp);
134 $this->initMail();
135 $this->setSubject(
136 sprintf($this->getLanguageText('grp_mail_notification_reg_sub'),$this->getObjectTitle(true))
137 );
138 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
139 $this->appendBody("\n\n");
140
142 $this->appendBody(
143 sprintf($this->getLanguageText('grp_mail_notification_reg_bod'),
144 $this->userToString($info['usr_id']),
145 $this->getObjectTitle()
146 )
147 );
148 $this->appendBody("\n\n");
149 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
150 $this->appendBody("\n\n");
151 $this->appendBody($this->createPermanentLink(array(),'_mem'));
152
153 $this->appendBody("\n\n");
154 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
155
156 $this->getMail()->appendInstallationSignature(true);
157 $this->sendMail(array($rcp),array('system'));
158 }
159 break;
160
162
163 foreach($this->getRecipients() as $rcp)
164 {
165 $this->initLanguage($rcp);
166 $this->initMail();
167 $this->setSubject(
168 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_sub'),$this->getObjectTitle(true))
169 );
170 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
171 $this->appendBody("\n\n");
172 $this->appendBody(
173 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_bod'),$this->getObjectTitle())
174 );
175 $this->getMail()->appendInstallationSignature(true);
176 $this->sendMail(array($rcp),array('system'));
177 }
178 break;
179
181
182 foreach($this->getRecipients() as $rcp)
183 {
184 $this->initLanguage($rcp);
185 $this->initMail();
186 $this->setSubject(
187 sprintf($this->getLanguageText('grp_mail_notification_unsub_sub'),$this->getObjectTitle(true))
188 );
189 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
190 $this->appendBody("\n\n");
191
193 $this->appendBody(
194 sprintf($this->getLanguageText('grp_mail_notification_unsub_bod'),
195 $this->userToString($info['usr_id']),
196 $this->getObjectTitle()
197 )
198 );
199 $this->appendBody("\n\n");
200 $this->appendBody($this->getLanguageText('grp_mail_notification_unsub_bod2'));
201 $this->appendBody("\n\n");
202 $this->appendBody($this->createPermanentLink(array(),'_mem'));
203
204 $this->appendBody("\n\n");
205 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
206
207 $this->getMail()->appendInstallationSignature(true);
208 $this->sendMail(array($rcp),array('system'));
209 }
210 break;
211
212
214
215 foreach($this->getRecipients() as $rcp)
216 {
217 $this->initLanguage($rcp);
218 $this->initMail();
219 $this->setSubject(
220 sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'),$this->getObjectTitle(true))
221 );
222 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
223 $this->appendBody("\n\n");
224 $this->appendBody(
225 sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'),$this->getObjectTitle())
226 );
227
228 $this->appendBody("\n\n");
229 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
230 $this->appendBody("\n\n");
231 $this->appendBody($this->createPermanentLink());
232 $this->getMail()->appendInstallationSignature(true);
233
234 $this->sendMail(array($rcp),array('system'));
235 }
236 break;
237
238
240
241 foreach($this->getRecipients() as $rcp)
242 {
243 $this->initLanguage($rcp);
244 $this->initMail();
245 $this->setSubject(
246 sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'),$this->getObjectTitle(true))
247 );
248 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
249 $this->appendBody("\n\n");
250
252 $this->appendBody(
253 sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'),
254 $this->userToString($info['usr_id']),
255 $this->getObjectTitle()
256 )
257 );
258 $this->appendBody("\n\n");
259 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
260 $this->appendBody("\n");
261 $this->appendBody($this->createPermanentLink(array(),'_mem'));
262
263 $this->appendBody("\n\n");
264 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
265
266 $this->getMail()->appendInstallationSignature(true);
267 $this->sendMail(array($rcp),array('system'));
268 }
269 break;
270
272
273 foreach($this->getRecipients() as $rcp)
274 {
275 $this->initLanguage($rcp);
276 $this->initMail();
277 $this->setSubject(
278 sprintf($this->getLanguageText('grp_mail_sub_dec_sub'),$this->getObjectTitle(true))
279 );
280 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
281 $this->appendBody("\n\n");
282 $this->appendBody(
283 sprintf($this->getLanguageText('grp_mail_sub_dec_bod'),$this->getObjectTitle())
284 );
285
286 $this->getMail()->appendInstallationSignature(true);
287
288 $this->sendMail(array($rcp),array('system'));
289 }
290 break;
291
293
294 foreach($this->getRecipients() as $rcp)
295 {
296 $this->initLanguage($rcp);
297 $this->initMail();
298 $this->setSubject(
299 sprintf($this->getLanguageText('grp_mail_sub_acc_sub'),$this->getObjectTitle(true))
300 );
301 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
302 $this->appendBody("\n\n");
303 $this->appendBody(
304 sprintf($this->getLanguageText('grp_mail_sub_acc_bod'),$this->getObjectTitle())
305 );
306 $this->appendBody("\n\n");
307 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
308 $this->appendBody("\n\n");
309 $this->appendBody($this->createPermanentLink());
310 $this->getMail()->appendInstallationSignature(true);
311
312 $this->sendMail(array($rcp),array('system'));
313 }
314 break;
315
317 foreach($this->getRecipients() as $rcp)
318 {
319 $this->initLanguage($rcp);
320 $this->initMail();
321 $this->setSubject(
322 sprintf($this->getLanguageText('grp_mail_wl_sub'),$this->getObjectTitle(true))
323 );
324
325 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
326
328 $this->appendBody("\n\n");
329 $this->appendBody(
330 sprintf($this->getLanguageText('grp_mail_wl_bod'),
331 $this->getObjectTitle(),
332 $info['position']
333 )
334 );
335 $this->getMail()->appendInstallationSignature(true);
336 $this->sendMail(array($rcp),array('system'));
337 }
338 break;
339
340
342 foreach($this->getRecipients() as $rcp)
343 {
344 $this->initLanguage($rcp);
345 $this->initMail();
346 $this->setSubject(
347 sprintf($this->getLanguageText('grp_mail_status_sub'),$this->getObjectTitle(true))
348 );
349 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
350 $this->appendBody("\n\n");
351 $this->appendBody(
352 sprintf($this->getLanguageText('grp_mail_status_bod'),$this->getObjectTitle())
353 );
354
355 $this->appendBody("\n\n");
356 $this->appendBody($this->createGroupStatus($rcp));
357
358 $this->appendBody("\n\n");
359 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
360 $this->appendBody("\n\n");
361 $this->appendBody($this->createPermanentLink());
362
363 $this->getMail()->appendInstallationSignature(true);
364
365 $this->sendMail(array($rcp),array('system'));
366 }
367 break;
368
369 }
370 return true;
371 }
372
378 protected function initLanguage($a_usr_id)
379 {
380 parent::initLanguage($a_usr_id);
381 $this->getLanguage()->loadLanguageModule('grp');
382 }
383
389 protected function createGroupStatus($a_usr_id)
390 {
392
393 $body = $this->getLanguageText('grp_new_status')."\n";
394 $body .= $this->getLanguageText('role').': ';
395
396
397 if($part->isAdmin($a_usr_id))
398 {
399 $body .= $this->getLanguageText('il_grp_admin')."\n";
400
401 }
402 else
403 {
404 $body .= $this->getLanguageText('il_grp_member')."\n";
405 }
406
407 if($part->isAdmin($a_usr_id))
408 {
409 $body .= $this->getLanguageText('grp_notification').': ';
410
411 if($part->isNotificationEnabled($a_usr_id))
412 {
413 $body .= $this->getLanguageText('grp_notify_on')."\n";
414 }
415 else
416 {
417 $body .= $this->getLanguageText('grp_notify_off')."\n";
418 }
419 }
420 return $body;
421 }
422
431 {
432 global $ilSetting;
433
434 return
435 $this->force_sending_mail ||
436 $ilSetting->get('mail_grp_member_notification',true) ||
437 in_array($a_type, $this->permanent_enabled_notifications);
438 }
439}
440?>
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
isNotificationTypeEnabled($a_type)
get setting "mail_grp_member_notification" and excludes types which are not affected by this setting ...
$permanent_enabled_notifications
Notifications which are not affected by "mail_grp_member_notification" setting because they addresses...
forceSendingMail($a_status)
Force sending mail independent from global setting.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
getType()
Get notification type.
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
createPermanentLink($a_params=array(), $a_append='')
$info
Definition: example_052.php:80
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilSetting
Definition: privfeed.php:17
$a_type
Definition: workflow.php:93