ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilCalendarMailNotification.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once './Services/Mail/classes/class.ilMailNotification.php';
25
35{
42 const TYPE_USER = 7;
45
46 private $appointment_id = null;
47
51 public function __construct()
52 {
53
54 $this->setSender(ANONYMOUS_USER_ID);
55 }
56
62 public function setAppointmentId($a_id)
63 {
64 $this->appointment_id = $a_id;
65
66 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
67 $this->appointment = new ilCalendarEntry($this->getAppointmentId());
68 }
69
74 public function getAppointment()
75 {
76 return $this->appointment;
77 }
78
83 public function getAppointmentId()
84 {
86 }
87
88 public function appendAppointmentDetails()
89 {
90 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
91 $app = new ilCalendarEntry($this->getAppointmentId());
92 $this->appendBody($app->appointmentToMailString($this->getLanguage()));
93 }
94
95
100 public function send()
101 {
102 global $rbacreview,$lng;
103
104 switch($this->getType())
105 {
106 case self::TYPE_USER:
107 $rcp = array_pop($this->getRecipients());
108 $this->initLanguage($rcp);
109 $this->getLanguage()->loadLanguageModule('dateplaner');
110 $this->initMail();
111 $this->setSubject(
112 sprintf(
113 $this->getLanguageText('cal_mail_notification_subject'),
114 $this->getAppointment()->getTitle()
115 )
116 );
117 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
118 $this->appendBody("\n\n");
119 $this->appendBody(
120 $this->getLanguageText('cal_mail_notification_body')
121 );
122 $this->appendBody("\n\n");
124 $this->appendBody("\n\n");
125 $this->getMail()->appendInstallationSignature(true);
126 $this->addAttachment();
127
128 $this->sendMail(
129 $this->getRecipients(),
130 array('system'),
131 true
132 );
133 break;
134
136
137 $rcp = array_pop($this->getRecipients());
138
139 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
140 $this->getLanguage()->loadLanguageModule('dateplaner');
141 $this->getLanguage()->loadLanguageModule('mail');
142 $this->initMail();
143 $this->setSubject(
144 sprintf(
145 $this->getLanguageText('cal_mail_notification_subject'),
146 $this->getAppointment()->getTitle()
147 )
148 );
149 $this->setBody(ilMail::getSalutation(0, $this->getLanguage()));
150 $this->appendBody("\n\n");
151 $this->appendBody(
152 $this->getLanguageText('cal_mail_notification_body')
153 );
154 $this->appendBody("\n\n");
156 $this->appendBody("\n\n");
157 $this->getMail()->appendInstallationSignature(true);
158 $this->addAttachment();
159
160 $this->sendMail(
161 $this->getRecipients(),
162 array('email'),
163 false
164 );
165 break;
166
168
169 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
170 $this->getLanguage()->loadLanguageModule('grp');
171 $this->getLanguage()->loadLanguageModule('dateplaner');
172 $this->initMail();
173 $this->setSubject(
174 sprintf($this->getLanguageText('cal_grp_new_notification_sub'),$this->getObjectTitle(true))
175 );
176 $this->setBody($this->getLanguageText('grp_notification_salutation'));
177 $this->appendBody("\n\n");
178 $this->appendBody(
179 sprintf($this->getLanguageText('cal_grp_new_notification_body'),$this->getObjectTitle(true))
180 );
181 $this->appendBody("\n\n");
182 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
183 $this->appendBody("\n\n");
184
186
187 $this->appendBody("\n\n");
188 $this->appendBody($this->createPermanentLink());
189 $this->getMail()->appendInstallationSignature(true);
190
191 $this->addAttachment();
192
193 $this->sendMail(array('#il_grp_admin_'.$this->getRefId(),'#il_grp_member_'.$this->getRefId()),array('system'),false);
194 break;
195
197
198 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
199 $this->getLanguage()->loadLanguageModule('grp');
200 $this->getLanguage()->loadLanguageModule('dateplaner');
201 $this->initMail();
202 $this->setSubject(
203 sprintf($this->getLanguageText('cal_grp_notification_sub'),$this->getObjectTitle(true))
204 );
205 $this->setBody($this->getLanguageText('grp_notification_salutation'));
206 $this->appendBody("\n\n");
207 $this->appendBody(
208 sprintf($this->getLanguageText('cal_grp_notification_body'),$this->getObjectTitle(true))
209 );
210 $this->appendBody("\n\n");
211
213
214 $this->appendBody("\n\n");
215 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
216 $this->appendBody("\n\n");
217 $this->appendBody($this->createPermanentLink());
218 $this->getMail()->appendInstallationSignature(true);
219
220 $this->addAttachment();
221
222 $this->sendMail(array('#il_grp_admin_'.$this->getRefId(),'#il_grp_member_'.$this->getRefId()),array('system'),false);
223 break;
224
226
227 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
228 $this->getLanguage()->loadLanguageModule('crs');
229 $this->getLanguage()->loadLanguageModule('dateplaner');
230 $this->initMail();
231 $this->setSubject(
232 sprintf($this->getLanguageText('cal_crs_new_notification_sub'),$this->getObjectTitle(true))
233 );
234 $this->setBody($this->getLanguageText('crs_notification_salutation'));
235 $this->appendBody("\n\n");
236 $this->appendBody(
237 sprintf($this->getLanguageText('cal_crs_new_notification_body'),$this->getObjectTitle(true))
238 );
239 $this->appendBody("\n\n");
240 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
241 $this->appendBody("\n\n");
242
244
245 $this->appendBody("\n\n");
246 $this->appendBody($this->createPermanentLink());
247 $this->getMail()->appendInstallationSignature(true);
248
249 $this->addAttachment();
250
251 $this->sendMail(array('#il_crs_admin_'.$this->getRefId(),'#il_crs_tutor_'.$this->getRefId(),'#il_crs_member_'.$this->getRefId()),array('system'),false);
252 break;
253
255
256 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
257 $this->getLanguage()->loadLanguageModule('crs');
258 $this->getLanguage()->loadLanguageModule('dateplaner');
259 $this->initMail();
260 $this->setSubject(
261 sprintf($this->getLanguageText('cal_crs_notification_sub'),$this->getObjectTitle(true))
262 );
263 $this->setBody($this->getLanguageText('crs_notification_salutation'));
264 $this->appendBody("\n\n");
265 $this->appendBody(
266 sprintf($this->getLanguageText('cal_crs_notification_body'),$this->getObjectTitle(true))
267 );
268 $this->appendBody("\n\n");
269
271
272 $this->appendBody("\n\n");
273 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
274 $this->appendBody("\n\n");
275 $this->appendBody($this->createPermanentLink());
276 $this->getMail()->appendInstallationSignature(true);
277
278 $this->addAttachment();
279
280 $this->sendMail(array('#il_crs_admin_'.$this->getRefId(),'#il_crs_tutor_'.$this->getRefId(),'#il_crs_member_'.$this->getRefId()),array('system'),false);
281 break;
282
284
285 $user_id = array_pop($this->getRecipients());
286 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
287 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
288 $entry = new ilCalendarEntry($this->getAppointmentId());
289 $booking = new ilBookingEntry($entry->getContextId());
290
291 $this->initLanguage($user_id);
292 $this->getLanguage()->loadLanguageModule('dateplaner');
293 $this->initMail();
294 $this->setSubject(
295 sprintf($this->getLanguageText('cal_booking_confirmation_subject'),$entry->getTitle())
296 );
297 $this->setBody(ilMail::getSalutation($user_id,$this->getLanguage()));
298 $this->appendBody("\n\n");
299 $this->appendBody(
300 sprintf($this->getLanguageText('cal_booking_confirmation_body'),ilObjUser::_lookupFullname($booking->getObjId()))
301 );
302 $this->appendBody("\n\n");
303
304 $this->appendAppointmentDetails($booking);
305
306 /*
307 $this->appendBody("\n\n");
308 $this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
309 $this->appendBody("\n\n");
310 $this->appendBody($this->createPermanentLink());
311 */
312 $this->getMail()->appendInstallationSignature(true);
313
314 $this->sendMail(array($user_id),array('system'),true);
315
316 $this->appendBody("\n\n");
317 $this->appendBody($this->getLanguageText('cal_booking_confirmation_user')."\n");
318 $this->appendBody(ilObjUser::_lookupFullname($user_id));
319
320 $this->sendMail(array($booking->getObjId()),array('system'),true);
321 break;
322
324
325 $user_id = array_pop($this->getRecipients());
326 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
327 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
328 $entry = new ilCalendarEntry($this->getAppointmentId());
329 $booking = new ilBookingEntry($entry->getContextId());
330
331 $user_id = array_pop($this->getRecipients());
332 $this->initLanguage($user_id);
333 $this->getLanguage()->loadLanguageModule('dateplaner');
334 $this->initMail();
335 $this->setSubject(
336 sprintf($this->getLanguageText('cal_booking_cancellation_subject'),$entry->getTitle())
337 );
338 $this->setBody(ilMail::getSalutation($user_id,$this->getLanguage()));
339 $this->appendBody("\n\n");
340 $this->appendBody(
341 sprintf($this->getLanguageText('cal_booking_cancellation_body'),ilObjUser::_lookupFullname($booking->getObjId()))
342 );
343 $this->appendBody("\n\n");
344
345 $this->appendAppointmentDetails($booking);
346
347 $this->getMail()->appendInstallationSignature(true);
348
349 $this->sendMail(array($user_id),array('system'),true);
350
351 $this->appendBody("\n\n");
352 $this->appendBody($this->getLanguageText('cal_booking_cancellation_user')."\n");
353 $this->appendBody(ilObjUser::_lookupFullname($user_id));
354
355 $this->sendMail(array($booking->getObjId()),array('system'),true);
356 break;
357
359
360 $user_id = array_pop($this->getRecipients());
361
362 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
363 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
364 $entry = new ilCalendarEntry($this->getAppointmentId());
365 $booking = new ilBookingEntry($entry->getContextId());
366
367 $this->initLanguage($user_id);
368 $this->getLanguage()->loadLanguageModule('dateplaner');
369 $this->initMail();
370 $this->setSubject(
371 sprintf($this->getLanguageText('cal_ch_booking_reminder_subject'),$entry->getTitle())
372 );
373 $this->setBody(ilMail::getSalutation($user_id,$this->getLanguage()));
374 $this->appendBody("\n\n");
375 $this->appendBody(
376 sprintf($this->getLanguageText('cal_ch_booking_reminder_body'),ilObjUser::_lookupFullname($booking->getObjId()))
377 );
378 $this->appendBody("\n\n");
379
380 $this->appendAppointmentDetails($booking);
381
382 $this->getMail()->appendInstallationSignature(true);
383 $this->sendMail(array($user_id),array('system'),true);
384 break;
385 }
386
387 $this->deleteAttachments();
388
389 }
390
391 protected function addAttachment()
392 {
393 global $ilUser;
394
395 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
396 $export = new ilCalendarExport();
397 $export->setExportType(ilCalendarExport::EXPORT_APPOINTMENTS);
398 $export->setAppointments(array($this->getAppointmentId()));
399 $export->export();
400
401 include_once './Services/Mail/classes/class.ilFileDataMail.php';
402 $attachment = new ilFileDataMail($this->getSender());
403 $attachment->storeAsAttachment(
404 'appointment.ics',
405 $export->getExportString()
406 );
407
408 $this->setAttachments(
409 array(
410 'appointment.ics'
411 )
412 );
413 }
414
418 protected function deleteAttachments()
419 {
420 include_once './Services/Mail/classes/class.ilFileDataMail.php';
421 $attachment = new ilFileDataMail($this->getSender());
422 $attachment->unlinkFiles($this->getAttachments());
423
424 }
425}
426?>
Booking definition.
Model for a calendar entry.
@classDescription Export calendar(s) to ical format
Distributes calendar mail notifications.
setAppointmentId($a_id)
Set calendar appointment id.
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _getLanguage($a_lang_key='')
Get langauge object.
Base class for course/group mail notifications.
appendBody($a_body)
Append body text.
getType()
Get notification type.
getSender()
get sender of mail
getLanguage()
get language object
sendMail($a_rcp, $a_type, $a_parse_recipients=true)
Send Mail.
setBody($a_body)
Set mail body.
setLanguage($a_language)
A language.
initLanguage($a_usr_id)
Init language.
setSender($a_usr_id)
Set sender of mail.
getRecipients()
get array of recipients
getObjectTitle($a_shorten=false)
Get object title.
setAttachments($a_att)
Set attachments
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.
_lookupFullname($a_user_id)
Lookup Full Name.
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15