ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $this->setSender(ANONYMOUS_USER_ID);
54 }
55
61 public function setAppointmentId($a_id)
62 {
63 $this->appointment_id = $a_id;
64
65 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
66 $this->appointment = new ilCalendarEntry($this->getAppointmentId());
67 }
68
73 public function getAppointment()
74 {
75 return $this->appointment;
76 }
77
82 public function getAppointmentId()
83 {
85 }
86
87 public function appendAppointmentDetails()
88 {
89 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
90 $app = new ilCalendarEntry($this->getAppointmentId());
91 $this->appendBody($app->appointmentToMailString($this->getLanguage()));
92 }
93
94
99 public function send()
100 {
101 global $rbacreview,$lng;
102
103 switch ($this->getType()) {
104 case self::TYPE_USER:
105 $rcp = array_pop($this->getRecipients());
106 $this->initLanguage($rcp);
107 $this->getLanguage()->loadLanguageModule('dateplaner');
108 $this->initMail();
109 $this->setSubject(
110 sprintf(
111 $this->getLanguageText('cal_mail_notification_subject'),
112 $this->getAppointment()->getTitle()
113 )
114 );
115 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
116 $this->appendBody("\n\n");
117 $this->appendBody(
118 $this->getLanguageText('cal_mail_notification_body')
119 );
120 $this->appendBody("\n\n");
122 $this->appendBody("\n\n");
123 $this->getMail()->appendInstallationSignature(true);
124 $this->addAttachment();
125
126 $this->sendMail(
127 $this->getRecipients(),
128 array('system'),
129 true
130 );
131 break;
132
134
135 $rcp = array_pop($this->getRecipients());
136
137 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
138 $this->getLanguage()->loadLanguageModule('dateplaner');
139 $this->getLanguage()->loadLanguageModule('mail');
140 $this->initMail();
141 $this->setSubject(
142 sprintf(
143 $this->getLanguageText('cal_mail_notification_subject'),
144 $this->getAppointment()->getTitle()
145 )
146 );
147 $this->setBody(ilMail::getSalutation(0, $this->getLanguage()));
148 $this->appendBody("\n\n");
149 $this->appendBody(
150 $this->getLanguageText('cal_mail_notification_body')
151 );
152 $this->appendBody("\n\n");
154 $this->appendBody("\n\n");
155 $this->getMail()->appendInstallationSignature(true);
156 $this->addAttachment();
157
158 $this->sendMail(
159 $this->getRecipients(),
160 array('email'),
161 false
162 );
163 break;
164
166
167 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
168 $this->getLanguage()->loadLanguageModule('grp');
169 $this->getLanguage()->loadLanguageModule('dateplaner');
170 $this->initMail();
171 $this->setSubject(
172 sprintf($this->getLanguageText('cal_grp_new_notification_sub'), $this->getObjectTitle(true))
173 );
174 $this->setBody($this->getLanguageText('grp_notification_salutation'));
175 $this->appendBody("\n\n");
176 $this->appendBody(
177 sprintf($this->getLanguageText('cal_grp_new_notification_body'), $this->getObjectTitle(true))
178 );
179 $this->appendBody("\n\n");
180 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
181 $this->appendBody("\n\n");
182
184
185 $this->appendBody("\n\n");
186 $this->appendBody($this->createPermanentLink());
187 $this->getMail()->appendInstallationSignature(true);
188
189 $this->addAttachment();
190
191 $this->sendMail(array('#il_grp_admin_' . $this->getRefId(),'#il_grp_member_' . $this->getRefId()), array('system'), false);
192 break;
193
195
196 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
197 $this->getLanguage()->loadLanguageModule('grp');
198 $this->getLanguage()->loadLanguageModule('dateplaner');
199 $this->initMail();
200 $this->setSubject(
201 sprintf($this->getLanguageText('cal_grp_notification_sub'), $this->getObjectTitle(true))
202 );
203 $this->setBody($this->getLanguageText('grp_notification_salutation'));
204 $this->appendBody("\n\n");
205 $this->appendBody(
206 sprintf($this->getLanguageText('cal_grp_notification_body'), $this->getObjectTitle(true))
207 );
208 $this->appendBody("\n\n");
209
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->addAttachment();
219
220 $this->sendMail(array('#il_grp_admin_' . $this->getRefId(),'#il_grp_member_' . $this->getRefId()), array('system'), false);
221 break;
222
224
225 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
226 $this->getLanguage()->loadLanguageModule('crs');
227 $this->getLanguage()->loadLanguageModule('dateplaner');
228 $this->initMail();
229 $this->setSubject(
230 sprintf($this->getLanguageText('cal_crs_new_notification_sub'), $this->getObjectTitle(true))
231 );
232 $this->setBody($this->getLanguageText('crs_notification_salutation'));
233 $this->appendBody("\n\n");
234 $this->appendBody(
235 sprintf($this->getLanguageText('cal_crs_new_notification_body'), $this->getObjectTitle(true))
236 );
237 $this->appendBody("\n\n");
238 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
239 $this->appendBody("\n\n");
240 $this->appendBody($this->createPermanentLink());
241 $this->appendBody("\n\n");
243
244 $this->getMail()->appendInstallationSignature(true);
245
246 $this->addAttachment();
247
248 $this->sendMail(array('#il_crs_admin_' . $this->getRefId(),'#il_crs_tutor_' . $this->getRefId(),'#il_crs_member_' . $this->getRefId()), array('system'), false);
249 break;
250
252
253 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
254 $this->getLanguage()->loadLanguageModule('crs');
255 $this->getLanguage()->loadLanguageModule('dateplaner');
256 $this->initMail();
257 $this->setSubject(
258 sprintf($this->getLanguageText('cal_crs_notification_sub'), $this->getObjectTitle(true))
259 );
260 $this->setBody($this->getLanguageText('crs_notification_salutation'));
261 $this->appendBody("\n\n");
262 $this->appendBody(
263 sprintf($this->getLanguageText('cal_crs_notification_body'), $this->getObjectTitle(true))
264 );
265 $this->appendBody("\n\n");
266
268
269 $this->appendBody("\n\n");
270 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
271 $this->appendBody("\n\n");
272 $this->appendBody($this->createPermanentLink());
273 $this->getMail()->appendInstallationSignature(true);
274
275 $this->addAttachment();
276
277 $this->sendMail(array('#il_crs_admin_' . $this->getRefId(),'#il_crs_tutor_' . $this->getRefId(),'#il_crs_member_' . $this->getRefId()), array('system'), false);
278 break;
279
281
282 $user_id = array_pop($this->getRecipients());
283 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
284 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
285 $entry = new ilCalendarEntry($this->getAppointmentId());
286 $booking = new ilBookingEntry($entry->getContextId());
287
288 $this->initLanguage($user_id);
289 $this->getLanguage()->loadLanguageModule('dateplaner');
290 $this->initMail();
291 $this->setSubject(
292 sprintf($this->getLanguageText('cal_booking_confirmation_subject'), $entry->getTitle())
293 );
294 $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
295 $this->appendBody("\n\n");
296 $this->appendBody(
297 sprintf($this->getLanguageText('cal_booking_confirmation_body'), ilObjUser::_lookupFullname($booking->getObjId()))
298 );
299 $this->appendBody("\n\n");
300
301 $this->appendAppointmentDetails($booking);
302
303 /*
304 $this->appendBody("\n\n");
305 $this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
306 $this->appendBody("\n\n");
307 $this->appendBody($this->createPermanentLink());
308 */
309 $this->getMail()->appendInstallationSignature(true);
310
311 $this->sendMail(array($user_id), array('system'), true);
312
313 $this->appendBody("\n\n");
314 $this->appendBody($this->getLanguageText('cal_booking_confirmation_user') . "\n");
315 $this->appendBody(ilObjUser::_lookupFullname($user_id));
316
317 $this->sendMail(array($booking->getObjId()), array('system'), true);
318 break;
319
321
322 $user_id = array_pop($this->getRecipients());
323 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
324 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
325 $entry = new ilCalendarEntry($this->getAppointmentId());
326 $booking = new ilBookingEntry($entry->getContextId());
327
328 $user_id = array_pop($this->getRecipients());
329 $this->initLanguage($user_id);
330 $this->getLanguage()->loadLanguageModule('dateplaner');
331 $this->initMail();
332 $this->setSubject(
333 sprintf($this->getLanguageText('cal_booking_cancellation_subject'), $entry->getTitle())
334 );
335 $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
336 $this->appendBody("\n\n");
337 $this->appendBody(
338 sprintf($this->getLanguageText('cal_booking_cancellation_body'), ilObjUser::_lookupFullname($booking->getObjId()))
339 );
340 $this->appendBody("\n\n");
341
342 $this->appendAppointmentDetails($booking);
343
344 $this->getMail()->appendInstallationSignature(true);
345
346 $this->sendMail(array($user_id), array('system'), true);
347
348 $this->appendBody("\n\n");
349 $this->appendBody($this->getLanguageText('cal_booking_cancellation_user') . "\n");
350 $this->appendBody(ilObjUser::_lookupFullname($user_id));
351
352 $this->sendMail(array($booking->getObjId()), array('system'), true);
353 break;
354
356
357 $user_id = array_pop($this->getRecipients());
358
359 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
360 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
361 $entry = new ilCalendarEntry($this->getAppointmentId());
362 $booking = new ilBookingEntry($entry->getContextId());
363
364 $this->initLanguage($user_id);
365 $this->getLanguage()->loadLanguageModule('dateplaner');
366 $this->initMail();
367 $this->setSubject(
368 sprintf($this->getLanguageText('cal_ch_booking_reminder_subject'), $entry->getTitle())
369 );
370 $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
371 $this->appendBody("\n\n");
372 $this->appendBody(
373 sprintf($this->getLanguageText('cal_ch_booking_reminder_body'), ilObjUser::_lookupFullname($booking->getObjId()))
374 );
375 $this->appendBody("\n\n");
376
377 $this->appendAppointmentDetails($booking);
378
379 $this->getMail()->appendInstallationSignature(true);
380 $this->sendMail(array($user_id), array('system'), true);
381 break;
382 }
383
384 $this->deleteAttachments();
385 }
386
387 protected function addAttachment()
388 {
389 global $ilUser;
390
391 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
392 $export = new ilCalendarExport();
393 $export->setExportType(ilCalendarExport::EXPORT_APPOINTMENTS);
394 $export->setAppointments(array($this->getAppointmentId()));
395 $export->export();
396
397 include_once './Services/Mail/classes/class.ilFileDataMail.php';
398 $attachment = new ilFileDataMail($this->getSender());
399 $attachment->storeAsAttachment(
400 'appointment.ics',
401 $export->getExportString()
402 );
403
404 $this->setAttachments(
405 array(
406 'appointment.ics'
407 )
408 );
409 }
410
414 protected function deleteAttachments()
415 {
416 include_once './Services/Mail/classes/class.ilFileDataMail.php';
417 $attachment = new ilFileDataMail($this->getSender());
418 $attachment->unlinkFiles($this->getAttachments());
419 }
420}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
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.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
getType()
Get notification type.
getSender()
get sender of mail
initLanguage($a_usr_id)
Init language.
setSender($a_usr_id)
Set sender of mail.
getRecipients()
get array of recipients
getAttachments()
Get attachments.
getObjectTitle($a_shorten=false)
setAttachments($a_att)
Set attachments.
createPermanentLink($a_params=array(), $a_append='')
static getSalutation($a_usr_id, ilLanguage $a_language=null)
static _lookupFullname($a_user_id)
Lookup Full Name.
global $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18