You are here

function event_calendar_ical in Event 5

Same name and namespace in other branches
  1. 5.2 event.module \event_calendar_ical()

Creates an ical feed of events.

Parameters

$stamp The GMT starting date for the feed.:

$duration The number of days the feeds duration is.:

$types The content types to filter the feed by.:

$terms The taxonomy term tids to filter the feed by.:

$title The filter title to append to the channel description.:

Return value

A formatted ical feed.

Related topics

1 call to event_calendar_ical()
event_page in ./event.module
Displays a page containing event information. The page layout defaults to a graphical calendar.

File

./event.module, line 756

Code

function event_calendar_ical($stamp, $duration, $types = NULL, $terms = NULL, $title = NULL) {
  global $base_url, $locale;
  $endstamp = $stamp + $duration * 86400;
  $headertitle = t('!startmonth !startdate, !startyear - !endmonth !enddate, !endyear', array(
    '!startmonth' => t(gmdate('F', $stamp)),
    '!startdate' => gmdate('d', $stamp),
    '!startyear' => gmdate('Y', $stamp),
    '!endmonth' => t(gmdate('F', $endstamp)),
    '!enddate' => gmdate('d', $endstamp),
    '!endyear' => gmdate('Y', $endstamp),
  ));
  $result = db_query(db_rewrite_sql('SELECT n.nid, e.event_start FROM {node} n INNER JOIN {event} e ON n.nid = e.nid WHERE n.status = 1 AND ((e.event_start > %d AND e.event_start < %d) OR (e.event_end > %d AND e.event_end < %d) OR (e.event_start < %d AND e.event_end > %d)) ORDER BY event_start '), $stamp, $endstamp, $stamp, $endstamp, $stamp, $endstamp);
  $events = array();
  while ($nid = db_fetch_object($result)) {
    $node = node_load($nid->nid);
    if (event_filter_node($node, $types, $terms)) {
      $events[] = _event_node_ical($node);
    }
  }
  $description = $headertitle . ($title ? ' | ' . $title : '');
  return ical_export($events, $description);
}