ILIAS  release_4-4 Revision
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)
 Constructor. More...
 
 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 ($a_rcp)
 set mail recipients More...
 
 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)
 Set ref id. More...
 
 getRefId ()
 get reference id More...
 
 getObjId ()
 get object id More...
 
 setObjId ($a_obj_id)
 set obj id More...
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation ($a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 Get additional information for generating notification mails. More...
 
 sendMail ($a_rcp, $a_type, $a_parse_recipients=true)
 Send Mail. More...
 
 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)
 Set mail subject. More...
 
 getSubject ()
 Get mail subject. More...
 
 setBody ($a_body)
 Set mail body. More...
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 Get body. More...
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 A language. More...
 
 getLanguage ()
 get language object More...
 
 getLanguageText ($a_keyword)
 Replace new lines. More...
 
 getObjectTitle ($a_shorten=false)
 Get object title. More...
 
 initMail ()
 Init mail. More...
 
 getMail ()
 Get mail object. More...
 
 createPermanentLink ($a_params=array(), $a_append='')
 Create a permanent link for an object. More...
 
 userToString ($a_usr_id)
 Utility function. More...
 
 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 
54  $this->setSender(ANONYMOUS_USER_ID);
55  }
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 390 of file class.ilCalendarMailNotification.php.

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

Referenced by send().

391  {
392  global $ilUser;
393 
394  include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
395  $export = new ilCalendarExport();
396  $export->setExportType(ilCalendarExport::EXPORT_APPOINTMENTS);
397  $export->setAppointments(array($this->getAppointmentId()));
398  $export->export();
399 
400  include_once './Services/Mail/classes/class.ilFileDataMail.php';
401  $attachment = new ilFileDataMail($this->getSender());
402  $attachment->storeAsAttachment(
403  'appointment.ics',
404  $export->getExportString()
405  );
406 
407  $this->setAttachments(
408  array(
409  'appointment.ics'
410  )
411  );
412  }
This class handles all operations on files (attachments) in directory ilias_data/mail.
setAttachments($a_att)
Set attachments.
Export calendar(s) to ical format
global $ilUser
Definition: imgupload.php:15
getSender()
get sender of mail
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendAppointmentDetails()

ilCalendarMailNotification::appendAppointmentDetails ( )

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

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

Referenced by send().

89  {
90  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
91  $app = new ilCalendarEntry($this->getAppointmentId());
92  $this->appendBody($app->appointmentToMailString($this->getLanguage()));
93  }
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 417 of file class.ilCalendarMailNotification.php.

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

Referenced by send().

418  {
419  include_once './Services/Mail/classes/class.ilFileDataMail.php';
420  $attachment = new ilFileDataMail($this->getSender());
421  $attachment->unlinkFiles($this->getAttachments());
422 
423  }
This class handles all operations on files (attachments) in directory ilias_data/mail.
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 74 of file class.ilCalendarMailNotification.php.

Referenced by send().

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

◆ getAppointmentId()

ilCalendarMailNotification::getAppointmentId ( )

get appointment id

Returns

Definition at line 83 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 100 of file class.ilCalendarMailNotification.php.

References $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.

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");
123  $this->appendAppointmentDetails();
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 
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()),array('system'),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()),array('system'),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()),array('system'),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()),array('system'),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),array('system'),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()),array('system'),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),array('system'),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()),array('system'),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),array('system'),true);
383  break;
384  }
385 
386  $this->deleteAttachments();
387 
388  }
getLanguage()
get language object
getType()
Get notification type.
Model for a calendar entry.
setBody($a_body)
Set mail body.
sendMail($a_rcp, $a_type, $a_parse_recipients=true)
Send Mail.
getLanguageText($a_keyword)
Replace new lines.
initLanguage($a_usr_id)
Init language.
Booking definition.
setLanguage($a_language)
A language.
setSubject($a_subject)
Set mail subject.
_lookupFullname($a_user_id)
Lookup Full Name.
static _getLanguage($a_lang_key='')
Get langauge object.
getObjectTitle($a_shorten=false)
Get object title.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
getRecipients()
get array of recipients
createPermanentLink($a_params=array(), $a_append='')
Create a permanent link for an object.
global $lng
Definition: privfeed.php:40
appendBody($a_body)
Append body text.
+ 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 62 of file class.ilCalendarMailNotification.php.

References getAppointmentId().

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  }
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: