ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
102
103 $rbacreview = $DIC['rbacreview'];
104 $lng = $DIC['lng'];
105
106 switch ($this->getType()) {
107 case self::TYPE_USER:
108 $rcp = array_pop($this->getRecipients());
109 $this->initLanguage($rcp);
110 $this->getLanguage()->loadLanguageModule('dateplaner');
111 $this->initMail();
112 $this->setSubject(
113 sprintf(
114 $this->getLanguageText('cal_mail_notification_subject'),
115 $this->getAppointment()->getTitle()
116 )
117 );
118 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
119 $this->appendBody("\n\n");
120 $this->appendBody(
121 $this->getLanguageText('cal_mail_notification_body')
122 );
123 $this->appendBody("\n\n");
125 $this->appendBody("\n\n");
126 $this->getMail()->appendInstallationSignature(true);
127 $this->addAttachment();
128
129 $this->sendMail(
130 $this->getRecipients(),
131 array('system'),
132 true
133 );
134 break;
135
137
138 $rcp = array_pop($this->getRecipients());
139
140 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
141 $this->getLanguage()->loadLanguageModule('dateplaner');
142 $this->getLanguage()->loadLanguageModule('mail');
143 $this->initMail();
144 $this->setSubject(
145 sprintf(
146 $this->getLanguageText('cal_mail_notification_subject'),
147 $this->getAppointment()->getTitle()
148 )
149 );
150 $this->setBody(ilMail::getSalutation(0, $this->getLanguage()));
151 $this->appendBody("\n\n");
152 $this->appendBody(
153 $this->getLanguageText('cal_mail_notification_body')
154 );
155 $this->appendBody("\n\n");
157 $this->appendBody("\n\n");
158 $this->getMail()->appendInstallationSignature(true);
159 $this->addAttachment();
160
161 $this->sendMail(
162 $this->getRecipients(),
163 array('email'),
164 false
165 );
166 break;
167
169
170 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
171 $this->getLanguage()->loadLanguageModule('grp');
172 $this->getLanguage()->loadLanguageModule('dateplaner');
173 $this->initMail();
174 $this->setSubject(
175 sprintf($this->getLanguageText('cal_grp_new_notification_sub'), $this->getObjectTitle(true))
176 );
177 $this->setBody($this->getLanguageText('grp_notification_salutation'));
178 $this->appendBody("\n\n");
179 $this->appendBody(
180 sprintf($this->getLanguageText('cal_grp_new_notification_body'), $this->getObjectTitle(true))
181 );
182 $this->appendBody("\n\n");
183 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
184 $this->appendBody("\n\n");
185
187
188 $this->appendBody("\n\n");
189 $this->appendBody($this->createPermanentLink());
190 $this->getMail()->appendInstallationSignature(true);
191
192 $this->addAttachment();
193
194 $this->sendMail(array('#il_grp_admin_' . $this->getRefId(),'#il_grp_member_' . $this->getRefId()), array('system'), false);
195 break;
196
198
199 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
200 $this->getLanguage()->loadLanguageModule('grp');
201 $this->getLanguage()->loadLanguageModule('dateplaner');
202 $this->initMail();
203 $this->setSubject(
204 sprintf($this->getLanguageText('cal_grp_notification_sub'), $this->getObjectTitle(true))
205 );
206 $this->setBody($this->getLanguageText('grp_notification_salutation'));
207 $this->appendBody("\n\n");
208 $this->appendBody(
209 sprintf($this->getLanguageText('cal_grp_notification_body'), $this->getObjectTitle(true))
210 );
211 $this->appendBody("\n\n");
212
214
215 $this->appendBody("\n\n");
216 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
217 $this->appendBody("\n\n");
218 $this->appendBody($this->createPermanentLink());
219 $this->getMail()->appendInstallationSignature(true);
220
221 $this->addAttachment();
222
223 $this->sendMail(array('#il_grp_admin_' . $this->getRefId(),'#il_grp_member_' . $this->getRefId()), array('system'), false);
224 break;
225
227
228 $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
229 $this->getLanguage()->loadLanguageModule('crs');
230 $this->getLanguage()->loadLanguageModule('dateplaner');
231 $this->initMail();
232 $this->setSubject(
233 sprintf($this->getLanguageText('cal_crs_new_notification_sub'), $this->getObjectTitle(true))
234 );
235 $this->setBody($this->getLanguageText('crs_notification_salutation'));
236 $this->appendBody("\n\n");
237 $this->appendBody(
238 sprintf($this->getLanguageText('cal_crs_new_notification_body'), $this->getObjectTitle(true))
239 );
240 $this->appendBody("\n\n");
241 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
242 $this->appendBody("\n\n");
243 $this->appendBody($this->createPermanentLink());
244 $this->appendBody("\n\n");
246
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 protected function addAttachment()
391 {
392 global $DIC;
393
394 $ilUser = $DIC['ilUser'];
395
396 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
397 $export = new ilCalendarExport();
398 $export->setExportType(ilCalendarExport::EXPORT_APPOINTMENTS);
399 $export->setAppointments(array($this->getAppointmentId()));
400 $export->export();
401
402 include_once './Services/Mail/classes/class.ilFileDataMail.php';
403 $attachment = new ilFileDataMail($this->getSender());
404 $attachment->storeAsAttachment(
405 'appointment.ics',
406 $export->getExportString()
407 );
408
409 $this->setAttachments(
410 array(
411 'appointment.ics'
412 )
413 );
414 }
415
419 protected function deleteAttachments()
420 {
421 include_once './Services/Mail/classes/class.ilFileDataMail.php';
422 $attachment = new ilFileDataMail($this->getSender());
423 $attachment->unlinkFiles($this->getAttachments());
424 }
425}
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.
Class ilFileDataMail.
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 $DIC
Definition: saml.php:7
$lng
$ilUser
Definition: imgupload.php:18