ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 include_once './Services/Mail/classes/class.ilMailNotification.php';
25 
35 {
42 
43  private $appointment_id = null;
44 
48  public function __construct()
49  {
50  $this->setSender(ANONYMOUS_USER_ID);
51  }
52 
58  public function setAppointmentId($a_id)
59  {
60  $this->appointment_id = $a_id;
61  }
62 
67  public function getAppointmentId()
68  {
69  return $this->appointment_id;
70  }
71 
72  public function appendAppointmentDetails()
73  {
74  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
75  $app = new ilCalendarEntry($this->getAppointmentId());
76  $this->appendBody($app->appointmentToMailString($this->getLanguage()));
77  }
78 
79 
84  public function send()
85  {
86  global $rbacreview,$lng;
87 
88  switch($this->getType())
89  {
90  case self::TYPE_GRP_NEW_NOTIFICATION:
91 
92  $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
93  $this->getLanguage()->loadLanguageModule('grp');
94  $this->getLanguage()->loadLanguageModule('dateplaner');
95  $this->initMail();
96  $this->setSubject(
97  sprintf($this->getLanguageText('cal_grp_new_notification_sub'),$this->getObjectTitle(true))
98  );
99  $this->setBody($this->getLanguageText('grp_notification_salutation'));
100  $this->appendBody("\n\n");
101  $this->appendBody(
102  sprintf($this->getLanguageText('cal_grp_new_notification_body'),$this->getObjectTitle(true))
103  );
104  $this->appendBody("\n\n");
105  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
106  $this->appendBody("\n\n");
107 
108  $this->appendAppointmentDetails();
109 
110  $this->appendBody("\n\n");
111  $this->appendBody($this->createPermanentLink());
112  $this->getMail()->appendInstallationSignature(true);
113 
114  $this->sendMail(array('#il_grp_admin_'.$this->getRefId(),'#il_grp_member_'.$this->getRefId()),array('system'),false);
115  break;
116 
117  case self::TYPE_GRP_NOTIFICATION:
118 
119  $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
120  $this->getLanguage()->loadLanguageModule('grp');
121  $this->getLanguage()->loadLanguageModule('dateplaner');
122  $this->initMail();
123  $this->setSubject(
124  sprintf($this->getLanguageText('cal_grp_notification_sub'),$this->getObjectTitle(true))
125  );
126  $this->setBody($this->getLanguageText('grp_notification_salutation'));
127  $this->appendBody("\n\n");
128  $this->appendBody(
129  sprintf($this->getLanguageText('cal_grp_notification_body'),$this->getObjectTitle(true))
130  );
131  $this->appendBody("\n\n");
132 
133  $this->appendAppointmentDetails();
134 
135  $this->appendBody("\n\n");
136  $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
137  $this->appendBody("\n\n");
138  $this->appendBody($this->createPermanentLink());
139  $this->getMail()->appendInstallationSignature(true);
140 
141  $this->sendMail(array('#il_grp_admin_'.$this->getRefId(),'#il_grp_member_'.$this->getRefId()),array('system'),false);
142  break;
143 
144  case self::TYPE_CRS_NEW_NOTIFICATION:
145 
146  $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
147  $this->getLanguage()->loadLanguageModule('crs');
148  $this->getLanguage()->loadLanguageModule('dateplaner');
149  $this->initMail();
150  $this->setSubject(
151  sprintf($this->getLanguageText('cal_crs_new_notification_sub'),$this->getObjectTitle(true))
152  );
153  $this->setBody($this->getLanguageText('crs_notification_salutation'));
154  $this->appendBody("\n\n");
155  $this->appendBody(
156  sprintf($this->getLanguageText('cal_crs_new_notification_body'),$this->getObjectTitle(true))
157  );
158  $this->appendBody("\n\n");
159  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
160  $this->appendBody("\n\n");
161 
162  $this->appendAppointmentDetails();
163 
164  $this->appendBody("\n\n");
165  $this->appendBody($this->createPermanentLink());
166  $this->getMail()->appendInstallationSignature(true);
167 
168  $this->sendMail(array('#il_crs_admin_'.$this->getRefId(),'#il_crs_tutor_'.$this->getRefId(),'#il_crs_member_'.$this->getRefId()),array('system'),false);
169  break;
170 
171  case self::TYPE_CRS_NOTIFICATION:
172 
173  $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
174  $this->getLanguage()->loadLanguageModule('crs');
175  $this->getLanguage()->loadLanguageModule('dateplaner');
176  $this->initMail();
177  $this->setSubject(
178  sprintf($this->getLanguageText('cal_crs_notification_sub'),$this->getObjectTitle(true))
179  );
180  $this->setBody($this->getLanguageText('crs_notification_salutation'));
181  $this->appendBody("\n\n");
182  $this->appendBody(
183  sprintf($this->getLanguageText('cal_crs_notification_body'),$this->getObjectTitle(true))
184  );
185  $this->appendBody("\n\n");
186 
187  $this->appendAppointmentDetails();
188 
189  $this->appendBody("\n\n");
190  $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
191  $this->appendBody("\n\n");
192  $this->appendBody($this->createPermanentLink());
193  $this->getMail()->appendInstallationSignature(true);
194 
195  $this->sendMail(array('#il_crs_admin_'.$this->getRefId(),'#il_crs_tutor_'.$this->getRefId(),'#il_crs_member_'.$this->getRefId()),array('system'),false);
196  break;
197 
198  case self::TYPE_BOOKING_CONFIRMATION:
199 
200  $user_id = array_pop($this->getRecipients());
201  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
202  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
203  $entry = new ilCalendarEntry($this->getAppointmentId());
204  $booking = new ilBookingEntry($entry->getContextId());
205 
206  $this->initLanguage($user_id);
207  $this->getLanguage()->loadLanguageModule('dateplaner');
208  $this->initMail();
209  $this->setSubject(
210  sprintf($this->getLanguageText('cal_booking_confirmation_subject'),$entry->getTitle())
211  );
212  $this->setBody(ilMail::getSalutation($user_id,$this->getLanguage()));
213  $this->appendBody("\n\n");
214  $this->appendBody(
215  sprintf($this->getLanguageText('cal_booking_confirmation_body'),ilObjUser::_lookupFullname($booking->getObjId()))
216  );
217  $this->appendBody("\n\n");
218 
219  $this->appendAppointmentDetails($booking);
220 
221  /*
222  $this->appendBody("\n\n");
223  $this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
224  $this->appendBody("\n\n");
225  $this->appendBody($this->createPermanentLink());
226  */
227  $this->getMail()->appendInstallationSignature(true);
228 
229  $this->sendMail(array($user_id),array('system'),true);
230 
231  $this->appendBody("\n\n");
232  $this->appendBody($this->getLanguageText('cal_booking_confirmation_user')."\n");
233  $this->appendBody(ilObjUser::_lookupFullname($user_id));
234 
235  $this->sendMail(array($booking->getObjId()),array('system'),true);
236  break;
237 
238  case self::TYPE_BOOKING_CANCELLATION:
239 
240  $user_id = array_pop($this->getRecipients());
241  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
242  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
243  $entry = new ilCalendarEntry($this->getAppointmentId());
244  $booking = new ilBookingEntry($entry->getContextId());
245 
246  $user_id = array_pop($this->getRecipients());
247  $this->initLanguage($user_id);
248  $this->getLanguage()->loadLanguageModule('dateplaner');
249  $this->initMail();
250  $this->setSubject(
251  sprintf($this->getLanguageText('cal_booking_cancellation_subject'),$entry->getTitle())
252  );
253  $this->setBody(ilMail::getSalutation($user_id,$this->getLanguage()));
254  $this->appendBody("\n\n");
255  $this->appendBody(
256  sprintf($this->getLanguageText('cal_booking_cancellation_body'),ilObjUser::_lookupFullname($booking->getObjId()))
257  );
258  $this->appendBody("\n\n");
259 
260  $this->appendAppointmentDetails($booking);
261 
262  $this->getMail()->appendInstallationSignature(true);
263 
264  $this->sendMail(array($user_id),array('system'),true);
265 
266  $this->appendBody("\n\n");
267  $this->appendBody($this->getLanguageText('cal_booking_cancellation_user')."\n");
268  $this->appendBody(ilObjUser::_lookupFullname($user_id));
269 
270  $this->sendMail(array($booking->getObjId()),array('system'),true);
271  break;
272 
273  }
274  }
275 }
276 ?>