ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCalendarMailNotification Class Reference

Distributes calendar mail notifications. More...

+ Inheritance diagram for ilCalendarMailNotification:
+ Collaboration diagram for ilCalendarMailNotification:

Public Member Functions

 __construct ()
 Constructor. More...
 
 setAppointmentId ($a_id)
 Set calendar appointment id. More...
 
 getAppointment ()
 Get appointment. More...
 
 getAppointmentId ()
 get appointment id More...
 
 appendAppointmentDetails ()
 
 send ()
 
- Public Member Functions inherited from ilMailNotification
 __construct ($a_is_personal_workspace=false)
 
 setType ($a_type)
 Set notification type. More...
 
 getType ()
 Get notification type. More...
 
 setSender ($a_usr_id)
 Set sender of mail. More...
 
 getSender ()
 get sender of mail More...
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 get array of recipients More...
 
 setAttachments ($a_att)
 Set attachments. More...
 
 getAttachments ()
 Get attachments. More...
 
 setLangModules (array $a_modules)
 Set lang modules. More...
 
 getUserLanguage ($a_usr_id)
 Get user language. More...
 
 setRefId ($a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId ($a_obj_id)
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation (array $a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, $a_parse_recipients=true)
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

Data Fields

const TYPE_GRP_NOTIFICATION = 1
 
const TYPE_GRP_NEW_NOTIFICATION = 2
 
const TYPE_CRS_NOTIFICATION = 3
 
const TYPE_CRS_NEW_NOTIFICATION = 4
 
const TYPE_BOOKING_CONFIRMATION = 5
 
const TYPE_BOOKING_CANCELLATION = 6
 
const TYPE_USER = 7
 
const TYPE_USER_ANONYMOUS = 8
 
const TYPE_BOOKING_REMINDER = 9
 
- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 

Protected Member Functions

 addAttachment ()
 
 deleteAttachments ()
 Delete attachments. More...
 
- Protected Member Functions inherited from ilMailNotification
 setSubject ($a_subject)
 
 getSubject ()
 
 setBody ($a_body)
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 
 getLanguage ()
 
 getLanguageText ($a_keyword)
 
 getObjectTitle ($a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink ($a_params=array(), $a_append='')
 
 userToString ($a_usr_id)
 
 isRefIdAccessible ($a_user_id, $a_ref_id, $a_permission="read")
 Check if ref id is accessible for user. More...
 

Private Attributes

 $appointment_id = null
 

Additional Inherited Members

- Protected Attributes inherited from ilMailNotification
 $type = null
 
 $sender = null
 
 $mail = null
 
 $subject = ''
 
 $body = ''
 
 $attachments = array()
 
 $language = null
 
 $lang_modules = array()
 
 $recipients = array()
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $additional_info = array()
 
 $is_in_wsp
 
 $wsp_tree
 
 $wsp_access_handler
 

Detailed Description

Distributes calendar mail notifications.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 34 of file class.ilCalendarMailNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarMailNotification::__construct ( )

Constructor.

Definition at line 51 of file class.ilCalendarMailNotification.php.

References ilMailNotification\setSender().

52  {
53  $this->setSender(ANONYMOUS_USER_ID);
54  }
setSender($a_usr_id)
Set sender of mail.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAttachment()

ilCalendarMailNotification::addAttachment ( )
protected

Definition at line 389 of file class.ilCalendarMailNotification.php.

References $DIC, $ilUser, ilCalendarExport\EXPORT_APPOINTMENTS, getAppointmentId(), ilMailNotification\getSender(), and ilMailNotification\setAttachments().

Referenced by send().

390  {
391  global $DIC;
392 
393  $ilUser = $DIC['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  }
Class ilFileDataMail.
setAttachments($a_att)
Set attachments.
Export calendar(s) to ical format
$ilUser
Definition: imgupload.php:18
getSender()
get sender of mail
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendAppointmentDetails()

ilCalendarMailNotification::appendAppointmentDetails ( )

Definition at line 87 of file class.ilCalendarMailNotification.php.

References $app, ilMailNotification\appendBody(), and getAppointmentId().

Referenced by send().

88  {
89  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
90  $app = new ilCalendarEntry($this->getAppointmentId());
91  $this->appendBody($app->appointmentToMailString($this->getLanguage()));
92  }
$app
Definition: cli.php:38
Model for a calendar entry.
appendBody($a_body)
Append body text.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAttachments()

ilCalendarMailNotification::deleteAttachments ( )
protected

Delete attachments.

Definition at line 418 of file class.ilCalendarMailNotification.php.

References ilMailNotification\getAttachments(), and ilMailNotification\getSender().

Referenced by send().

419  {
420  include_once './Services/Mail/classes/class.ilFileDataMail.php';
421  $attachment = new ilFileDataMail($this->getSender());
422  $attachment->unlinkFiles($this->getAttachments());
423  }
Class ilFileDataMail.
getAttachments()
Get attachments.
getSender()
get sender of mail
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAppointment()

ilCalendarMailNotification::getAppointment ( )

Get appointment.

Returns
ilCalendarEntry

Definition at line 73 of file class.ilCalendarMailNotification.php.

Referenced by send().

74  {
75  return $this->appointment;
76  }
+ Here is the caller graph for this function:

◆ getAppointmentId()

ilCalendarMailNotification::getAppointmentId ( )

get appointment id

Returns

Definition at line 82 of file class.ilCalendarMailNotification.php.

References $appointment_id.

Referenced by addAttachment(), appendAppointmentDetails(), send(), and setAppointmentId().

+ Here is the caller graph for this function:

◆ send()

ilCalendarMailNotification::send ( )
Returns

Definition at line 99 of file class.ilCalendarMailNotification.php.

References $DIC, $lng, ilLanguageFactory\_getLanguage(), ilObjUser\_lookupFullname(), addAttachment(), appendAppointmentDetails(), ilMailNotification\appendBody(), ilMailNotification\createPermanentLink(), deleteAttachments(), getAppointment(), getAppointmentId(), ilMailNotification\getLanguage(), ilMailNotification\getLanguageText(), ilMailNotification\getMail(), ilMailNotification\getObjectTitle(), ilMailNotification\getRecipients(), ilMailNotification\getRefId(), ilMail\getSalutation(), ilMailNotification\getType(), ilMailNotification\initLanguage(), ilMailNotification\initMail(), ilMailNotification\sendMail(), ilMailNotification\setBody(), ilMailNotification\setLanguage(), ilMailNotification\setSubject(), and TYPE_BOOKING_REMINDER.

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");
124  $this->appendAppointmentDetails();
125  $this->appendBody("\n\n");
126  $this->getMail()->appendInstallationSignature(true);
127  $this->addAttachment();
128 
129  $this->sendMail(
130  $this->getRecipients(),
131  true
132  );
133  break;
134 
135  case self::TYPE_USER_ANONYMOUS:
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");
155  $this->appendAppointmentDetails();
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 
167  case self::TYPE_GRP_NEW_NOTIFICATION:
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 
185  $this->appendAppointmentDetails();
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()), false);
194  break;
195 
196  case self::TYPE_GRP_NOTIFICATION:
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 
212  $this->appendAppointmentDetails();
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()), false);
223  break;
224 
225  case self::TYPE_CRS_NEW_NOTIFICATION:
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  $this->appendBody($this->createPermanentLink());
243  $this->appendBody("\n\n");
244  $this->appendAppointmentDetails();
245 
246  $this->getMail()->appendInstallationSignature(true);
247 
248  $this->addAttachment();
249 
250  $this->sendMail(array('#il_crs_admin_' . $this->getRefId(),'#il_crs_tutor_' . $this->getRefId(),'#il_crs_member_' . $this->getRefId()), false);
251  break;
252 
253  case self::TYPE_CRS_NOTIFICATION:
254 
255  $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
256  $this->getLanguage()->loadLanguageModule('crs');
257  $this->getLanguage()->loadLanguageModule('dateplaner');
258  $this->initMail();
259  $this->setSubject(
260  sprintf($this->getLanguageText('cal_crs_notification_sub'), $this->getObjectTitle(true))
261  );
262  $this->setBody($this->getLanguageText('crs_notification_salutation'));
263  $this->appendBody("\n\n");
264  $this->appendBody(
265  sprintf($this->getLanguageText('cal_crs_notification_body'), $this->getObjectTitle(true))
266  );
267  $this->appendBody("\n\n");
268 
269  $this->appendAppointmentDetails();
270 
271  $this->appendBody("\n\n");
272  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
273  $this->appendBody("\n\n");
274  $this->appendBody($this->createPermanentLink());
275  $this->getMail()->appendInstallationSignature(true);
276 
277  $this->addAttachment();
278 
279  $this->sendMail(array('#il_crs_admin_' . $this->getRefId(),'#il_crs_tutor_' . $this->getRefId(),'#il_crs_member_' . $this->getRefId()), false);
280  break;
281 
282  case self::TYPE_BOOKING_CONFIRMATION:
283 
284  $user_id = array_pop($this->getRecipients());
285  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
286  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
287  $entry = new ilCalendarEntry($this->getAppointmentId());
288  $booking = new ilBookingEntry($entry->getContextId());
289 
290  $this->initLanguage($user_id);
291  $this->getLanguage()->loadLanguageModule('dateplaner');
292  $this->initMail();
293  $this->setSubject(
294  sprintf($this->getLanguageText('cal_booking_confirmation_subject'), $entry->getTitle())
295  );
296  $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
297  $this->appendBody("\n\n");
298  $this->appendBody(
299  sprintf($this->getLanguageText('cal_booking_confirmation_body'), ilObjUser::_lookupFullname($booking->getObjId()))
300  );
301  $this->appendBody("\n\n");
302 
303  $this->appendAppointmentDetails($booking);
304 
305  /*
306  $this->appendBody("\n\n");
307  $this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
308  $this->appendBody("\n\n");
309  $this->appendBody($this->createPermanentLink());
310  */
311  $this->getMail()->appendInstallationSignature(true);
312 
313  $this->sendMail(array($user_id), true);
314 
315  $this->appendBody("\n\n");
316  $this->appendBody($this->getLanguageText('cal_booking_confirmation_user') . "\n");
317  $this->appendBody(ilObjUser::_lookupFullname($user_id));
318 
319  $this->sendMail(array($booking->getObjId()), true);
320  break;
321 
322  case self::TYPE_BOOKING_CANCELLATION:
323 
324  $user_id = array_pop($this->getRecipients());
325  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
326  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
327  $entry = new ilCalendarEntry($this->getAppointmentId());
328  $booking = new ilBookingEntry($entry->getContextId());
329 
330  $user_id = array_pop($this->getRecipients());
331  $this->initLanguage($user_id);
332  $this->getLanguage()->loadLanguageModule('dateplaner');
333  $this->initMail();
334  $this->setSubject(
335  sprintf($this->getLanguageText('cal_booking_cancellation_subject'), $entry->getTitle())
336  );
337  $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
338  $this->appendBody("\n\n");
339  $this->appendBody(
340  sprintf($this->getLanguageText('cal_booking_cancellation_body'), ilObjUser::_lookupFullname($booking->getObjId()))
341  );
342  $this->appendBody("\n\n");
343 
344  $this->appendAppointmentDetails($booking);
345 
346  $this->getMail()->appendInstallationSignature(true);
347 
348  $this->sendMail(array($user_id), true);
349 
350  $this->appendBody("\n\n");
351  $this->appendBody($this->getLanguageText('cal_booking_cancellation_user') . "\n");
352  $this->appendBody(ilObjUser::_lookupFullname($user_id));
353 
354  $this->sendMail(array($booking->getObjId()), true);
355  break;
356 
358 
359  $user_id = array_pop($this->getRecipients());
360 
361  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
362  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
363  $entry = new ilCalendarEntry($this->getAppointmentId());
364  $booking = new ilBookingEntry($entry->getContextId());
365 
366  $this->initLanguage($user_id);
367  $this->getLanguage()->loadLanguageModule('dateplaner');
368  $this->initMail();
369  $this->setSubject(
370  sprintf($this->getLanguageText('cal_ch_booking_reminder_subject'), $entry->getTitle())
371  );
372  $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
373  $this->appendBody("\n\n");
374  $this->appendBody(
375  sprintf($this->getLanguageText('cal_ch_booking_reminder_body'), ilObjUser::_lookupFullname($booking->getObjId()))
376  );
377  $this->appendBody("\n\n");
378 
379  $this->appendAppointmentDetails($booking);
380 
381  $this->getMail()->appendInstallationSignature(true);
382  $this->sendMail(array($user_id), true);
383  break;
384  }
385 
386  $this->deleteAttachments();
387  }
getType()
Get notification type.
Model for a calendar entry.
static _lookupFullname($a_user_id)
Lookup Full Name.
initLanguage($a_usr_id)
Init language.
Booking definition.
sendMail(array $a_rcp, $a_parse_recipients=true)
static _getLanguage($a_lang_key='')
Get langauge object.
$lng
getObjectTitle($a_shorten=false)
getRecipients()
get array of recipients
createPermanentLink($a_params=array(), $a_append='')
$DIC
Definition: xapitoken.php:46
appendBody($a_body)
Append body text.
static getSalutation($a_usr_id, ilLanguage $a_language=null)
+ Here is the call graph for this function:

◆ setAppointmentId()

ilCalendarMailNotification::setAppointmentId (   $a_id)

Set calendar appointment id.

Parameters
object$a_id
Returns

Definition at line 61 of file class.ilCalendarMailNotification.php.

References getAppointmentId().

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  }
Model for a calendar entry.
+ Here is the call graph for this function:

Field Documentation

◆ $appointment_id

ilCalendarMailNotification::$appointment_id = null
private

Definition at line 46 of file class.ilCalendarMailNotification.php.

Referenced by getAppointmentId().

◆ TYPE_BOOKING_CANCELLATION

const ilCalendarMailNotification::TYPE_BOOKING_CANCELLATION = 6

Definition at line 41 of file class.ilCalendarMailNotification.php.

Referenced by ilBookingEntry\cancelBooking().

◆ TYPE_BOOKING_CONFIRMATION

const ilCalendarMailNotification::TYPE_BOOKING_CONFIRMATION = 5

Definition at line 40 of file class.ilCalendarMailNotification.php.

Referenced by ilBookingEntry\book().

◆ TYPE_BOOKING_REMINDER

const ilCalendarMailNotification::TYPE_BOOKING_REMINDER = 9

Definition at line 44 of file class.ilCalendarMailNotification.php.

Referenced by ilConsultationHourCron\run(), and send().

◆ TYPE_CRS_NEW_NOTIFICATION

const ilCalendarMailNotification::TYPE_CRS_NEW_NOTIFICATION = 4

◆ TYPE_CRS_NOTIFICATION

const ilCalendarMailNotification::TYPE_CRS_NOTIFICATION = 3

◆ TYPE_GRP_NEW_NOTIFICATION

const ilCalendarMailNotification::TYPE_GRP_NEW_NOTIFICATION = 2

◆ TYPE_GRP_NOTIFICATION

const ilCalendarMailNotification::TYPE_GRP_NOTIFICATION = 1

◆ TYPE_USER

const ilCalendarMailNotification::TYPE_USER = 7

◆ TYPE_USER_ANONYMOUS

const ilCalendarMailNotification::TYPE_USER_ANONYMOUS = 8

The documentation for this class was generated from the following file: