CMS  Version 3.9
iCalendarEventManager Class Reference

Note: we may wish to add someting like this to description: More...

Public Member Functions

 __construct ($id, $start, $end, $title, $description="", $location="", $sequence_id=0, $timeZone=null)
 The iCalendarManager obj is typically instantiated through the EventHandler for an event. More...
 
 setAliases ()
 
 setEventDates ($start, $end, $timeZone)
 For all day events: DTSTART;VALUE=DATE:20100101 DTEND;VALUE=DATE:20100101. More...
 
 setTimeZone ($timeZone, $start_value)
 If time zone is not provided, exlcude the time zone fields so they are not included in the output. More...
 
 formatTimeZoneHours ($offset)
 Given the numeric time zone value (pos or neg), convert to hour format for iCalendar such as "-0700". More...
 
 excludeTimeZoneFields ()
 If no time zone provided, exclude all fields between begin_timezone through end_timezone. More...
 
 isAllDay ($date)
 
 setAttachment ($path)
 
 setOrganizer ($replyTo, $replyToName="")
 
 setAttendee ($mailTo)
 Called from EmailHandler to set the attendee email address. More...
 
 setAttendeeName ($name)
 
 formatOrganizer ()
 We wait until final formatting of the iCalendar data to set the organizer properties because values can be set after the iCalendar object is instantiated. More...
 
 formatAttendee ()
 Given all the settings applied to vars, build the ATTENDEE property to be used in the calendar invitation. More...
 
 format ()
 Given the icalendar data values and the var settings, format the iCalendar data into a list of properties and values in the field order of the iCalendarData object values. More...
 

Public Attributes

 $replyTo
 organizer email set in EmailHandler More...
 
 $replyToName
 organizer name set in EmailHandler More...
 
 $mailTo
 Attendee email address. More...
 
 $attendeeName
 optionally include display name of recipient More...
 
 $rsvp = true
 organizer wants reply More...
 
 $attendeeStatus
 PARSTAT=TENTATIVE, PARSTAT=NEEDS-ACTION. More...
 
 $required = false
 ROLE=REQ-PARTICIPANT if required to attend. More...
 
 $invitees = array()
 optionally show others invited to event More...
 
 $data
 iCalendarData obj More...
 
 $aliases = array()
 field aliases or labels More...
 

Detailed Description

Note: we may wish to add someting like this to description:

The following is a new meeting request:
\nSubject: test send to mac \nOrganizer: "Janice Gallant" janic.nosp@m.e@so.nosp@m.njara.nosp@m..com
\nTime: Wednesday\ , March 20\, 2013\, 1:00:00 PM - 2:00:00 PM GMT -05:00 US/Canada Eastern
\ nInvitees: janic.nosp@m.e.ga.nosp@m.llant.nosp@m.@ver.nosp@m.izon..nosp@m.net


*~*~*~*~*~*~*~*~*~*

X-ALT-DESC;FMTTYPE=text/html:<html><body>

The following is a new meeting request:




Subject:<t d>test send to mac

Organizer:

"Janice Gallant" &lt\;janic.nosp@m.e@so.nosp@m.njara.nosp@m..com&gt\;



Time:

Wednesday\, March 20\, 2013\, 1:0 0:00 PM - 2:00:00 PM GMT -05:00 US/Canada Eastern


\ n

Invitees:

janice.gallant@ver izon.net


*~*~*~*~*~*~*~*~*~*


</body></ht>

Definition at line 126 of file i_calendar_manager.inc.

Constructor & Destructor Documentation

◆ __construct()

iCalendarEventManager::__construct (   $id,
  $start,
  $end,
  $title,
  $description = "",
  $location = "",
  $sequence_id = 0,
  $timeZone = null 
)

The iCalendarManager obj is typically instantiated through the EventHandler for an event.

E.g., the StandardEventHandler class can all formatiCalendar to instantiate an iCalendarManager obj by providing its event details such as start_date, end_date, location, etc.

After the obj is created, the calling code can set other configurable values such as attendee name, if known. It can also override default values set in the constructor, such as method.

Parameters
Number$id- event id or other unique identifier for the invitation
DATEor DATETIME $start
DATEor DATETIME $end
String$title
HTML$description
String$location
Number$sequence_id- increment sequence id when event is updated
obj$timeZone- instance of TimeZone, optional. If provided, set timezone properties

Definition at line 158 of file i_calendar_manager.inc.

159  {
160  global $config;
161 
162  $this->data = new iCalendarData();
163  $this->data->set("summary", $title);
164  $this->data->set("description", $description);
165  $this->data->set("location", $location);
166 
167  // The uid must be globally unique thus is includes the http_host
168  // and the event id.
169  $uid = $id . $config["http_host"];
170  $this->data->set("uid", $uid);
171 
172  $this->data->set("sequence", $sequence_id);
173 
174  $this->data->set("dtstart", $start);
175  $this->data->set("dtend", $end);
176 
177  $today = new DateTime(now());
178  $this->data->set("dtstamp", $today->format('Ymd\THis'));
179 
180  $this->data->filter = new ExclusionFilter("last_modified", "standard_rrule", "daylight_rrule");
181  // is last modified needed?
182  //$this->data->last_modified = $today;
183 
184  $this->data->set("priority", 5);
185  $this->data->set("class", "PUBLIC");
186 
187  $this->data->set("begin_calendar", "VCALENDAR");
188  $this->data->set("prodid", "-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN");
189  $this->data->set("version", "2.0");
190  $this->data->set("begin_event", "VEVENT");
191  $this->data->set("transp", "OPAQUE");
192  $this->data->set("display_status", "BUSY");
193  $this->data->set("end_event", "VEVENT");
194  $this->data->set("end_calendar", "VCALENDAR");
195  $this->data->set("method", "REQUEST");
196  $this->data->set("event_status", "CONFIRMED");
197 
198  $this->setEventDates($start, $end, $timeZone);
199 
200  $this->setAliases();
201  }
Dummy datamodel to helper manage the calendar data values.
setEventDates($start, $end, $timeZone)
For all day events: DTSTART;VALUE=DATE:20100101 DTEND;VALUE=DATE:20100101.
global $config
Definition: import.inc:4

Member Function Documentation

◆ excludeTimeZoneFields()

iCalendarEventManager::excludeTimeZoneFields ( )

If no time zone provided, exclude all fields between begin_timezone through end_timezone.

Definition at line 328 of file i_calendar_manager.inc.

329  {
330  $filter = $this->data->getFilter();
331  if(!$filter)
332  {
333  $filter = new ExclusionFilter();
334  }
335 
336  $fields = $this->data->getFields();
337  $tz_field = false;
338  foreach($fields as $name => $type)
339  {
340  if($name == "begin_timezone")
341  {
342  $tz_field = true;
343  }
344  if($tz_field)
345  {
346  $filter->excludeField($name);
347  }
348  if($name == "end_timezone")
349  {
350  $tz_field = false;
351  }
352  }
353  }
$filter
Definition: update.inc:44
$name
Definition: upload.inc:54

◆ format()

iCalendarEventManager::format ( )

Given the icalendar data values and the var settings, format the iCalendar data into a list of properties and values in the field order of the iCalendarData object values.

This format function is called from the EmailHandler when formatting the message.

Example:

BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN VERSION:2.0 METHOD:METHOD BEGIN:VEVENT ORGANIZER;CN=Web Site Administrator:MAILTO:andy@.nosp@m.sonj.nosp@m.ara.c.nosp@m.om ATTENDEE;RSVP=true;CN=Janice Gallant:MAILTO:janic.nosp@m.e@so.nosp@m.njara.nosp@m..com DTSTART;VALUE=DATE:20130328 DTEND;VALUE=DATE:20130328 LOCATION:test TRANSP:OPAQUE STATUS:CONFIRMED X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY UID:243stem2stern SEQUENCE:2 DTSTAMP:20130321T120233 DESCRIPTION:test SUMMARY:test all day PRIORITY:5 CLASS:PUBLIC END:VEVENT END:VCALENDAR

Returns
string

Definition at line 484 of file i_calendar_manager.inc.

485  {
486  $this->data->organizer = $this->formatOrganizer();
487  $this->data->attendee = $this->formatAttendee();
488 
489  $filter = $this->data->getFilter();
490  $fields = $this->data->getFields();
491  foreach (array_keys($fields) as $field)
492  {
493  if ($field != $pk && !($filter && $filter->isExcluded($field)))
494  {
495  $label = strtoupper($field);
496  if(array_key_exists($field, $this->aliases))
497  {
498  $label = $this->aliases[$field];
499  }
500 
501  $value = $this->data->$field;
502  if(!preg_match("/^;|:/", $value))
503  {
504  $value = ":". $value;
505  }
506  $properties[] = $label . $value;
507  }
508  }
509 
510  $out = "\r\n";
511  $out .= implode("\n", $properties);
512  $out .= "\r\n";
513 
514  return $out;
515  }
$out
Definition: page.inc:66
formatOrganizer()
We wait until final formatting of the iCalendar data to set the organizer properties because values c...
formatAttendee()
Given all the settings applied to vars, build the ATTENDEE property to be used in the calendar invita...

◆ formatAttendee()

iCalendarEventManager::formatAttendee ( )

Given all the settings applied to vars, build the ATTENDEE property to be used in the calendar invitation.

Example: ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;DELEGATED-FROM= "MAILTO:iamboss@host2.com";CN=Henry Cabot:MAILTO:hcabot@ host2.com

Definition at line 423 of file i_calendar_manager.inc.

424  {
425  if($this->required)
426  {
427  $attendee .= ";ROLE=REQ-PARTICIPANT";
428  }
429 
430  if($this->attendeeStatus)
431  {
432  $attendee .= ";PARTSTAT={$this->attendeeStatus}";
433  }
434 
435  if($this->rsvp)
436  {
437  $attendee .= ";RSVP=true";
438  }
439 
440  if($this->attendeeName)
441  {
442  $attendee .= ";CN={$this->attendeeName}";
443  }
444 
445  $attendee .= ":MAILTO:{$this->mailTo}";
446 
447  return $attendee;
448  }

◆ formatOrganizer()

iCalendarEventManager::formatOrganizer ( )

We wait until final formatting of the iCalendar data to set the organizer properties because values can be set after the iCalendar object is instantiated.

EmailHandler calls setOrganizer to set the replyTo email address and replyToName

Example: ORGANIZER;CN=John Smith:MAILTO:jsmit.nosp@m.h@ho.nosp@m.st1.c.nosp@m.om

Definition at line 402 of file i_calendar_manager.inc.

403  {
404  if($this->replyToName)
405  {
406  $organizer .= ";CN={$this->replyToName}";
407  }
408 
409  $organizer .= ":MAILTO:{$this->replyTo}";
410 
411  return $organizer;
412  }

◆ formatTimeZoneHours()

iCalendarEventManager::formatTimeZoneHours (   $offset)

Given the numeric time zone value (pos or neg), convert to hour format for iCalendar such as "-0700".

Noninteger time zones offset are rare and none are segments other than the half hour. If non integer, set the min to 30 regardless of the entered value.

Parameters
Number$offset
Returns
String

Definition at line 297 of file i_calendar_manager.inc.

298  {
299  $neg = false;
300  if($offset < 0)
301  {
302  $neg = true;
303  $offset = abs($offset);
304  }
305 
306  $hour = $offset;
307  $min = "00";
308  if(!is_int($offset))
309  {
310  $hour = floor($offset);
311  $min = "30";
312  }
313 
314  $out = str_pad($hour, 2, STR_PAD_LEFT) . $min;
315 
316  if($neg)
317  {
318  $out = "-" . $out;
319  }
320 
321  return $out;
322  }

◆ isAllDay()

iCalendarEventManager::isAllDay (   $date)

Definition at line 355 of file i_calendar_manager.inc.

356  {
357  if(preg_match("/00:00:00$/", $date))
358  {
359  return true;
360  }
361 
362  return false;
363  }
$date
Definition: event_list.inc:51

◆ setAliases()

iCalendarEventManager::setAliases ( )

Definition at line 203 of file i_calendar_manager.inc.

204  {
205  $aliases = $this->data->getFieldAliases();
206  // Read in default alias definitions from DataItem
207  if ($aliases)
208  {
209  foreach($aliases as $field => $alias)
210  {
211  $this->aliases[$field] = $alias;
212  }
213  }
214  }
$aliases
field aliases or labels

◆ setAttachment()

iCalendarEventManager::setAttachment (   $path)

Definition at line 365 of file i_calendar_manager.inc.

366  {
367  //ATTACH;FMTTYPE=image/jpeg:http://domain.com/images/bastille.jpg
368  }

◆ setAttendee()

iCalendarEventManager::setAttendee (   $mailTo)

Called from EmailHandler to set the attendee email address.

The code that calls the EmailHandler can set the attendee name if known.

Parameters
String$mailTo

Definition at line 382 of file i_calendar_manager.inc.

383  {
384  $this->mailTo = $mailTo;;
385  }
$mailTo
Attendee email address.

◆ setAttendeeName()

iCalendarEventManager::setAttendeeName (   $name)

Definition at line 387 of file i_calendar_manager.inc.

388  {
389  $this->attendeeName = $name;
390  }

◆ setEventDates()

iCalendarEventManager::setEventDates (   $start,
  $end,
  $timeZone 
)

For all day events: DTSTART;VALUE=DATE:20100101 DTEND;VALUE=DATE:20100101.

Definition at line 221 of file i_calendar_manager.inc.

222  {
223  $startObj = new DateTime($start);
224  $endObj = new DateTime($end);
225 
226  if($this->isAllDay($start) && $this->isAllDay($end))
227  {
228  $start_value = ";VALUE=DATE:" . $startObj->format("Ymd");
229  $end_value = ";VALUE=DATE:" . $endObj->format("Ymd");
230  }
231  else
232  {
233  $start_value = $startObj->format('Ymd\THis');
234  $end_value = $endObj->format('Ymd\THis');
235  }
236 
237  if($timeZone)
238  {
239  $this->setTimeZone($timeZone, $start_value);
240  $this->data->set("dtstart", ";TZID=" . $timeZone->time_zone_name . ":". $start_value);
241  $this->data->set("dtend", ";TZID=" . $timeZone->time_zone_name . ":". $end_value);
242  }
243  else
244  {
245  $this->excludeTimeZoneFields();
246  $this->data->set("dtstart", $start_value);
247  $this->data->set("dtend", $end_value);
248  }
249  }
excludeTimeZoneFields()
If no time zone provided, exclude all fields between begin_timezone through end_timezone.
setTimeZone($timeZone, $start_value)
If time zone is not provided, exlcude the time zone fields so they are not included in the output.

◆ setOrganizer()

iCalendarEventManager::setOrganizer (   $replyTo,
  $replyToName = "" 
)

Definition at line 370 of file i_calendar_manager.inc.

371  {
372  $this->replyTo = $replyTo;
373  $this->replyToName = $replyToName;
374  }
$replyTo
organizer email set in EmailHandler
$replyToName
organizer name set in EmailHandler

◆ setTimeZone()

iCalendarEventManager::setTimeZone (   $timeZone,
  $start_value 
)

If time zone is not provided, exlcude the time zone fields so they are not included in the output.

If provided, set the values.

Parameters
obj$timeZoneclass TimeZone

Definition at line 259 of file i_calendar_manager.inc.

260  {
261  $this->data->set("begin_timezone", "VTIMEZONE");
262  $this->data->set("begin_standard", "STANDARD");
263  $this->data->set("end_standard", "STANDARD");
264  $this->data->set("begin_daylight", "DAYLIGHT");
265  $this->data->set("end_daylight", "DAYLIGHT");
266  $this->data->set("end_timezone", "VTIMEZONE");
267 
268  $this->data->set("tzid", $timeZone->get("time_zone_name"));
269 
270  $standard_offset = $this->formatTimeZoneHours($timeZone->standard_offset);
271  $daylight_offset = $this->formatTimeZoneHours($timeZone->daylight_offset);
272 
273  $this->data->set("standard_name", "EST");
274  $this->data->set("daylight_name", "EDT");
275  $this->data->set("standard_offset", $standard_offset);
276  $this->data->set("standard_dst_offset", $daylight_offset);
277  $this->data->set("daylight_offset", $daylight_offset);
278  $this->data->set("daylight_dst_offset", $standard_offset);
279 
280  $this->data->set("standard_start", $start_value);
281  $this->data->set("daylight_start", $start_value);
282  }
formatTimeZoneHours($offset)
Given the numeric time zone value (pos or neg), convert to hour format for iCalendar such as "-0700".

Member Data Documentation

◆ $aliases

iCalendarEventManager::$aliases = array()

field aliases or labels

Definition at line 137 of file i_calendar_manager.inc.

◆ $attendeeName

iCalendarEventManager::$attendeeName

optionally include display name of recipient

Definition at line 131 of file i_calendar_manager.inc.

◆ $attendeeStatus

iCalendarEventManager::$attendeeStatus

PARSTAT=TENTATIVE, PARSTAT=NEEDS-ACTION.

Definition at line 133 of file i_calendar_manager.inc.

◆ $data

iCalendarEventManager::$data

iCalendarData obj

Definition at line 136 of file i_calendar_manager.inc.

◆ $invitees

iCalendarEventManager::$invitees = array()

optionally show others invited to event

Definition at line 135 of file i_calendar_manager.inc.

◆ $mailTo

iCalendarEventManager::$mailTo

Attendee email address.

Definition at line 130 of file i_calendar_manager.inc.

◆ $replyTo

iCalendarEventManager::$replyTo

organizer email set in EmailHandler

Definition at line 128 of file i_calendar_manager.inc.

◆ $replyToName

iCalendarEventManager::$replyToName

organizer name set in EmailHandler

Definition at line 129 of file i_calendar_manager.inc.

◆ $required

iCalendarEventManager::$required = false

ROLE=REQ-PARTICIPANT if required to attend.

Definition at line 134 of file i_calendar_manager.inc.

◆ $rsvp

iCalendarEventManager::$rsvp = true

organizer wants reply

Definition at line 132 of file i_calendar_manager.inc.


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