ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
49 public function __construct()
50 {
51 parent::__construct();
52 }
53
58 public function send()
59 {
60 if(!$this->isNotificationTypeEnabled($this->getType()))
61 {
62 $GLOBALS['ilLog']->write(__METHOD__.': Membership mail disabled globally.');
63 return false;
64 }
65 // parent::send();
66
67 switch($this->getType())
68 {
70
71 foreach($this->getRecipients() as $rcp)
72 {
73 $this->initLanguage($rcp);
74 $this->initMail();
75 $this->setSubject(
76 sprintf($this->getLanguageText('grp_mail_admission_new_sub'),$this->getObjectTitle(true))
77 );
78 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
79 $this->appendBody("\n\n");
80 $this->appendBody(
81 sprintf($this->getLanguageText('grp_mail_admission_new_bod'),$this->getObjectTitle())
82 );
83 $this->appendBody("\n\n");
84 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
85 $this->appendBody("\n\n");
86 $this->appendBody($this->createPermanentLink());
87 $this->getMail()->appendInstallationSignature(true);
88
89 $this->sendMail(array($rcp),array('system'));
90 }
91 break;
92
94
95 foreach($this->getRecipients() as $rcp)
96 {
97 $this->initLanguage($rcp);
98 $this->initMail();
99 $this->setSubject(
100 sprintf($this->getLanguageText('grp_mail_dismiss_sub'),$this->getObjectTitle(true))
101 );
102 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
103 $this->appendBody("\n\n");
104 $this->appendBody(
105 sprintf($this->getLanguageText('grp_mail_dismiss_bod'),$this->getObjectTitle())
106 );
107 $this->getMail()->appendInstallationSignature(true);
108 $this->sendMail(array($rcp),array('system'));
109 }
110 break;
111
112
114
115 foreach($this->getRecipients() as $rcp)
116 {
117 $this->initLanguage($rcp);
118 $this->initMail();
119 $this->setSubject(
120 sprintf($this->getLanguageText('grp_mail_notification_reg_sub'),$this->getObjectTitle(true))
121 );
122 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
123 $this->appendBody("\n\n");
124
126 $this->appendBody(
127 sprintf($this->getLanguageText('grp_mail_notification_reg_bod'),
128 $this->userToString($info['usr_id']),
129 $this->getObjectTitle()
130 )
131 );
132 $this->appendBody("\n\n");
133 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
134 $this->appendBody("\n\n");
135 $this->appendBody($this->createPermanentLink(array(),'_mem'));
136
137 $this->appendBody("\n\n");
138 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
139
140 $this->getMail()->appendInstallationSignature(true);
141 $this->sendMail(array($rcp),array('system'));
142 }
143 break;
144
146
147 foreach($this->getRecipients() as $rcp)
148 {
149 $this->initLanguage($rcp);
150 $this->initMail();
151 $this->setSubject(
152 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_sub'),$this->getObjectTitle(true))
153 );
154 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
155 $this->appendBody("\n\n");
156 $this->appendBody(
157 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_bod'),$this->getObjectTitle())
158 );
159 $this->getMail()->appendInstallationSignature(true);
160 $this->sendMail(array($rcp),array('system'));
161 }
162 break;
163
165
166 foreach($this->getRecipients() as $rcp)
167 {
168 $this->initLanguage($rcp);
169 $this->initMail();
170 $this->setSubject(
171 sprintf($this->getLanguageText('grp_mail_notification_unsub_sub'),$this->getObjectTitle(true))
172 );
173 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
174 $this->appendBody("\n\n");
175
177 $this->appendBody(
178 sprintf($this->getLanguageText('grp_mail_notification_unsub_bod'),
179 $this->userToString($info['usr_id']),
180 $this->getObjectTitle()
181 )
182 );
183 $this->appendBody("\n\n");
184 $this->appendBody($this->getLanguageText('grp_mail_notification_unsub_bod2'));
185 $this->appendBody("\n\n");
186 $this->appendBody($this->createPermanentLink(array(),'_mem'));
187
188 $this->appendBody("\n\n");
189 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
190
191 $this->getMail()->appendInstallationSignature(true);
192 $this->sendMail(array($rcp),array('system'));
193 }
194 break;
195
196
198
199 foreach($this->getRecipients() as $rcp)
200 {
201 $this->initLanguage($rcp);
202 $this->initMail();
203 $this->setSubject(
204 sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'),$this->getObjectTitle(true))
205 );
206 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
207 $this->appendBody("\n\n");
208 $this->appendBody(
209 sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'),$this->getObjectTitle())
210 );
211
212 $this->appendBody("\n\n");
213 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
214 $this->appendBody("\n\n");
215 $this->appendBody($this->createPermanentLink());
216 $this->getMail()->appendInstallationSignature(true);
217
218 $this->sendMail(array($rcp),array('system'));
219 }
220 break;
221
222
224
225 foreach($this->getRecipients() as $rcp)
226 {
227 $this->initLanguage($rcp);
228 $this->initMail();
229 $this->setSubject(
230 sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'),$this->getObjectTitle(true))
231 );
232 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
233 $this->appendBody("\n\n");
234
236 $this->appendBody(
237 sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'),
238 $this->userToString($info['usr_id']),
239 $this->getObjectTitle()
240 )
241 );
242 $this->appendBody("\n\n");
243 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
244 $this->appendBody("\n");
245 $this->appendBody($this->createPermanentLink(array(),'_mem'));
246
247 $this->appendBody("\n\n");
248 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
249
250 $this->getMail()->appendInstallationSignature(true);
251 $this->sendMail(array($rcp),array('system'));
252 }
253 break;
254
256
257 foreach($this->getRecipients() as $rcp)
258 {
259 $this->initLanguage($rcp);
260 $this->initMail();
261 $this->setSubject(
262 sprintf($this->getLanguageText('grp_mail_sub_dec_sub'),$this->getObjectTitle(true))
263 );
264 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
265 $this->appendBody("\n\n");
266 $this->appendBody(
267 sprintf($this->getLanguageText('grp_mail_sub_dec_bod'),$this->getObjectTitle())
268 );
269
270 $this->getMail()->appendInstallationSignature(true);
271
272 $this->sendMail(array($rcp),array('system'));
273 }
274 break;
275
277
278 foreach($this->getRecipients() as $rcp)
279 {
280 $this->initLanguage($rcp);
281 $this->initMail();
282 $this->setSubject(
283 sprintf($this->getLanguageText('grp_mail_sub_acc_sub'),$this->getObjectTitle(true))
284 );
285 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
286 $this->appendBody("\n\n");
287 $this->appendBody(
288 sprintf($this->getLanguageText('grp_mail_sub_acc_bod'),$this->getObjectTitle())
289 );
290 $this->appendBody("\n\n");
291 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
292 $this->appendBody("\n\n");
293 $this->appendBody($this->createPermanentLink());
294 $this->getMail()->appendInstallationSignature(true);
295
296 $this->sendMail(array($rcp),array('system'));
297 }
298 break;
299
301 foreach($this->getRecipients() as $rcp)
302 {
303 $this->initLanguage($rcp);
304 $this->initMail();
305 $this->setSubject(
306 sprintf($this->getLanguageText('grp_mail_wl_sub'),$this->getObjectTitle(true))
307 );
308
309 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
310
312 $this->appendBody("\n\n");
313 $this->appendBody(
314 sprintf($this->getLanguageText('grp_mail_wl_bod'),
315 $this->getObjectTitle(),
316 $info['position']
317 )
318 );
319 $this->getMail()->appendInstallationSignature(true);
320 $this->sendMail(array($rcp),array('system'));
321 }
322 break;
323
324
326 foreach($this->getRecipients() as $rcp)
327 {
328 $this->initLanguage($rcp);
329 $this->initMail();
330 $this->setSubject(
331 sprintf($this->getLanguageText('grp_mail_status_sub'),$this->getObjectTitle(true))
332 );
333 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
334 $this->appendBody("\n\n");
335 $this->appendBody(
336 sprintf($this->getLanguageText('grp_mail_status_bod'),$this->getObjectTitle())
337 );
338
339 $this->appendBody("\n\n");
340 $this->appendBody($this->createGroupStatus($rcp));
341
342 $this->appendBody("\n\n");
343 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
344 $this->appendBody("\n\n");
345 $this->appendBody($this->createPermanentLink());
346
347 $this->getMail()->appendInstallationSignature(true);
348
349 $this->sendMail(array($rcp),array('system'));
350 }
351 break;
352
353 }
354 return true;
355 }
356
362 protected function initLanguage($a_usr_id)
363 {
364 parent::initLanguage($a_usr_id);
365 $this->getLanguage()->loadLanguageModule('grp');
366 }
367
373 protected function createGroupStatus($a_usr_id)
374 {
376
377 $body = $this->getLanguageText('grp_new_status')."\n";
378 $body .= $this->getLanguageText('role').': ';
379
380
381 if($part->isAdmin($a_usr_id))
382 {
383 $body .= $this->getLanguageText('il_grp_admin')."\n";
384
385 }
386 else
387 {
388 $body .= $this->getLanguageText('il_grp_member')."\n";
389 }
390
391 if($part->isAdmin($a_usr_id))
392 {
393 $body .= $this->getLanguageText('grp_notification').': ';
394
395 if($part->isNotificationEnabled($a_usr_id))
396 {
397 $body .= $this->getLanguageText('grp_notify_on')."\n";
398 }
399 else
400 {
401 $body .= $this->getLanguageText('grp_notify_off')."\n";
402 }
403 }
404 return $body;
405 }
406
414 protected function isNotificationTypeEnabled($a_type)
415 {
416 global $ilSetting;
417
418 return $ilSetting->get('mail_grp_member_notification',true) || in_array($a_type, $this->permanent_enabled_notifications);
419 }
420}
421?>
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...
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='')
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
$info
Definition: example_052.php:80
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilSetting
Definition: privfeed.php:40