ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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{
16
19
21
24
28
32
33
37 public function __construct()
38 {
39 parent::__construct();
40 }
41
46 public function send()
47 {
48 global $ilSetting;
49
50 // parent::send();
51
52 switch($this->getType())
53 {
55
56 // automatic mails about status change disabled
57 if(!$ilSetting->get('mail_grp_member_notification',true))
58 {
59 $GLOBALS['ilLog']->write(__METHOD__.': Membership mail disabled globally.');
60 return;
61 }
62
63 foreach($this->getRecipients() as $rcp)
64 {
65 $this->initLanguage($rcp);
66 $this->initMail();
67 $this->setSubject(
68 sprintf($this->getLanguageText('grp_mail_admission_new_sub'),$this->getObjectTitle(true))
69 );
70 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
71 $this->appendBody("\n\n");
72 $this->appendBody(
73 sprintf($this->getLanguageText('grp_mail_admission_new_bod'),$this->getObjectTitle())
74 );
75 $this->appendBody("\n\n");
76 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
77 $this->appendBody("\n\n");
78 $this->appendBody($this->createPermanentLink());
79 $this->getMail()->appendInstallationSignature(true);
80
81 $this->sendMail(array($rcp),array('system'));
82 }
83 break;
84
86
87 // automatic mails about status change disabled
88 if(!$ilSetting->get('mail_grp_member_notification',true))
89 {
90 $GLOBALS['ilLog']->write(__METHOD__.': Membership mail disabled globally.');
91 return;
92 }
93
94 foreach($this->getRecipients() as $rcp)
95 {
96 $this->initLanguage($rcp);
97 $this->initMail();
98 $this->setSubject(
99 sprintf($this->getLanguageText('grp_mail_dismiss_sub'),$this->getObjectTitle(true))
100 );
101 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
102 $this->appendBody("\n\n");
103 $this->appendBody(
104 sprintf($this->getLanguageText('grp_mail_dismiss_bod'),$this->getObjectTitle())
105 );
106 $this->getMail()->appendInstallationSignature(true);
107 $this->sendMail(array($rcp),array('system'));
108 }
109 break;
110
111
113
114 foreach($this->getRecipients() as $rcp)
115 {
116 $this->initLanguage($rcp);
117 $this->initMail();
118 $this->setSubject(
119 sprintf($this->getLanguageText('grp_mail_notification_reg_sub'),$this->getObjectTitle(true))
120 );
121 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
122 $this->appendBody("\n\n");
123
124 $info = $this->getAdditionalInformation();
125 $this->appendBody(
126 sprintf($this->getLanguageText('grp_mail_notification_reg_bod'),
127 $this->userToString($info['usr_id']),
128 $this->getObjectTitle()
129 )
130 );
131 $this->appendBody("\n\n");
132 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
133 $this->appendBody("\n\n");
134 $this->appendBody($this->createPermanentLink(array(),'_mem'));
135
136 $this->appendBody("\n\n");
137 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
138
139 $this->getMail()->appendInstallationSignature(true);
140 $this->sendMail(array($rcp),array('system'));
141 }
142 break;
143
145
146 foreach($this->getRecipients() as $rcp)
147 {
148 $this->initLanguage($rcp);
149 $this->initMail();
150 $this->setSubject(
151 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_sub'),$this->getObjectTitle(true))
152 );
153 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
154 $this->appendBody("\n\n");
155 $this->appendBody(
156 sprintf($this->getLanguageText('grp_mail_unsubscribe_member_bod'),$this->getObjectTitle())
157 );
158 $this->getMail()->appendInstallationSignature(true);
159 $this->sendMail(array($rcp),array('system'));
160 }
161 break;
162
164
165 foreach($this->getRecipients() as $rcp)
166 {
167 $this->initLanguage($rcp);
168 $this->initMail();
169 $this->setSubject(
170 sprintf($this->getLanguageText('grp_mail_notification_unsub_sub'),$this->getObjectTitle(true))
171 );
172 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
173 $this->appendBody("\n\n");
174
175 $info = $this->getAdditionalInformation();
176 $this->appendBody(
177 sprintf($this->getLanguageText('grp_mail_notification_unsub_bod'),
178 $this->userToString($info['usr_id']),
179 $this->getObjectTitle()
180 )
181 );
182 $this->appendBody("\n\n");
183 $this->appendBody($this->getLanguageText('grp_mail_notification_unsub_bod2'));
184 $this->appendBody("\n\n");
185 $this->appendBody($this->createPermanentLink(array(),'_mem'));
186
187 $this->appendBody("\n\n");
188 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
189
190 $this->getMail()->appendInstallationSignature(true);
191 $this->sendMail(array($rcp),array('system'));
192 }
193 break;
194
195
197
198 foreach($this->getRecipients() as $rcp)
199 {
200 $this->initLanguage($rcp);
201 $this->initMail();
202 $this->setSubject(
203 sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'),$this->getObjectTitle(true))
204 );
205 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
206 $this->appendBody("\n\n");
207 $this->appendBody(
208 sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'),$this->getObjectTitle())
209 );
210
211 $this->appendBody("\n\n");
212 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
213 $this->appendBody("\n\n");
214 $this->appendBody($this->createPermanentLink());
215 $this->getMail()->appendInstallationSignature(true);
216
217 $this->sendMail(array($rcp),array('system'));
218 }
219 break;
220
221
223
224 foreach($this->getRecipients() as $rcp)
225 {
226 $this->initLanguage($rcp);
227 $this->initMail();
228 $this->setSubject(
229 sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'),$this->getObjectTitle(true))
230 );
231 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
232 $this->appendBody("\n\n");
233
234 $info = $this->getAdditionalInformation();
235 $this->appendBody(
236 sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'),
237 $this->userToString($info['usr_id']),
238 $this->getObjectTitle()
239 )
240 );
241 $this->appendBody("\n\n");
242 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
243 $this->appendBody("\n");
244 $this->appendBody($this->createPermanentLink(array(),'_mem'));
245
246 $this->appendBody("\n\n");
247 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
248
249 $this->getMail()->appendInstallationSignature(true);
250 $this->sendMail(array($rcp),array('system'));
251 }
252 break;
253
255
256 foreach($this->getRecipients() as $rcp)
257 {
258 $this->initLanguage($rcp);
259 $this->initMail();
260 $this->setSubject(
261 sprintf($this->getLanguageText('grp_mail_sub_dec_sub'),$this->getObjectTitle(true))
262 );
263 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
264 $this->appendBody("\n\n");
265 $this->appendBody(
266 sprintf($this->getLanguageText('grp_mail_sub_dec_bod'),$this->getObjectTitle())
267 );
268
269 $this->getMail()->appendInstallationSignature(true);
270
271 $this->sendMail(array($rcp),array('system'));
272 }
273 break;
274
276
277 foreach($this->getRecipients() as $rcp)
278 {
279 $this->initLanguage($rcp);
280 $this->initMail();
281 $this->setSubject(
282 sprintf($this->getLanguageText('grp_mail_sub_acc_sub'),$this->getObjectTitle(true))
283 );
284 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
285 $this->appendBody("\n\n");
286 $this->appendBody(
287 sprintf($this->getLanguageText('grp_mail_sub_acc_bod'),$this->getObjectTitle())
288 );
289 $this->appendBody("\n\n");
290 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
291 $this->appendBody("\n\n");
292 $this->appendBody($this->createPermanentLink());
293 $this->getMail()->appendInstallationSignature(true);
294
295 $this->sendMail(array($rcp),array('system'));
296 }
297 break;
298
300 foreach($this->getRecipients() as $rcp)
301 {
302 $this->initLanguage($rcp);
303 $this->initMail();
304 $this->setSubject(
305 sprintf($this->getLanguageText('grp_mail_wl_sub'),$this->getObjectTitle(true))
306 );
307
308 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
309
310 $info = $this->getAdditionalInformation();
311 $this->appendBody("\n\n");
312 $this->appendBody(
313 sprintf($this->getLanguageText('grp_mail_wl_bod'),
314 $this->getObjectTitle(),
315 $info['position']
316 )
317 );
318 $this->getMail()->appendInstallationSignature(true);
319 $this->sendMail(array($rcp),array('system'));
320 }
321 break;
322
323
325 foreach($this->getRecipients() as $rcp)
326 {
327 $this->initLanguage($rcp);
328 $this->initMail();
329 $this->setSubject(
330 sprintf($this->getLanguageText('grp_mail_status_sub'),$this->getObjectTitle(true))
331 );
332 $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage()));
333 $this->appendBody("\n\n");
334 $this->appendBody(
335 sprintf($this->getLanguageText('grp_mail_status_bod'),$this->getObjectTitle())
336 );
337
338 $this->appendBody("\n\n");
339 $this->appendBody($this->createGroupStatus($rcp));
340
341 $this->appendBody("\n\n");
342 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
343 $this->appendBody("\n\n");
344 $this->appendBody($this->createPermanentLink());
345
346 $this->getMail()->appendInstallationSignature(true);
347
348 $this->sendMail(array($rcp),array('system'));
349 }
350 break;
351
352 }
353 return true;
354 }
355
361 protected function initLanguage($a_usr_id)
362 {
363 parent::initLanguage($a_usr_id);
364 $this->getLanguage()->loadLanguageModule('grp');
365 }
366
372 protected function createGroupStatus($a_usr_id)
373 {
375
376 $body = $this->getLanguageText('grp_new_status')."\n";
377 $body .= $this->getLanguageText('role').': ';
378
379
380 if($part->isAdmin($a_usr_id))
381 {
382 $body .= $this->getLanguageText('il_grp_admin')."\n";
383
384 }
385 else
386 {
387 $body .= $this->getLanguageText('il_grp_member')."\n";
388 }
389
390 if($part->isAdmin($a_usr_id))
391 {
392 $body .= $this->getLanguageText('grp_notification').': ';
393
394 if($part->isNotificationEnabled($a_usr_id))
395 {
396 $body .= $this->getLanguageText('grp_notify_on')."\n";
397 }
398 else
399 {
400 $body .= $this->getLanguageText('grp_notify_off')."\n";
401 }
402 }
403 return $body;
404 }
405
406}
407?>
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
userToString($a_usr_id)
Utility function.
getType()
Get notification type.
getLanguage()
get language object
sendMail($a_rcp, $a_type, $a_parse_recipients=true)
Send Mail.
getAdditionalInformation()
Get additional information for generating notification mails.
setBody($a_body)
Set mail body.
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
Get object title.
getLanguageText($a_keyword)
Replace new lines.
setSubject($a_subject)
Set mail subject.
createPermanentLink($a_params=array(), $a_append='')
Create a permanent link for an object.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
$GLOBALS['ct_recipient']
global $ilSetting
Definition: privfeed.php:40