url); // What is FEEDAPI_FEED_NOT_UPDATED supposed to be? It is not defined. //if ($downloaded_string === FALSE || $downloaded_string === FEEDAPI_FEED_NOT_UPDATED) { if ($downloaded_string === FALSE || empty($downloaded_string)) { return $downloaded_string; } return _parser_ical_parse($downloaded_string); } /** * Parse iCal feeds. * * Uses patched ical_upload. */ function _parser_ical_parse($feed_content) { include_once(drupal_get_path('module', 'date_api') .'/date_api_ical.inc'); $feed_folded = explode("\n", $feed_content); $ical_parsed = date_ical_parse($feed_folded); $ical = $ical_parsed[0]; // Any or all of these items could be missing, so always use isset() to test. $parsed_source = new stdClass(); // Detect the title $parsed_source->title = isset($ical['X-WR-CALNAME']) ? $ical['X-WR-CALNAME'] : ''; // Detect the description $parsed_source->description = isset($ical['X-WR-CALDESC']) ? $ical['X-WR-CALDESC'] : ''; $parsed_source->options = new stdClass(); $parsed_source->options->calscale = isset($ical['CALSCALE']) ? $ical['CALSCALE'] : ''; $parsed_source->options->timezone = isset($ical['X-WR-TIMEZONE']) ? $ical['X-WR-TIMEZONE'] : ''; $parsed_source->items = array(); foreach ($ical['VEVENT'] as $event) { $item = new stdClass(); $item->title = $event['SUMMARY']; $item->description = isset($event['DESCRIPTION']) ? $event['DESCRIPTION'] : ''; $item->options = new stdClass(); $item->options->original_author = ''; $item->options->location = isset($event['URL']) ? $event['URL'] : ''; $item->options->original_url = $item->options->location; // Make sure a valid timestamp is created. $item->options->timestamp = time(); if (isset($event['DTSTAMP'])){ $date = date_ical_date($event['DTSTAMP']); if (date_is_valid($date, DATE_OBJECT)) { $item->options->timestamp = date_format($date, 'U'); } } $item->options->guid = isset($event['UID']) ? $event['UID'] : ''; // intention $item->options->tags = isset($event['CATEGORIES']) ? explode(',',$event['CATEGORIES']) : array(); // Keep iCal timezone information in the feed item so we can create the right date value. $dates = array('CREATED', 'LAST-MODIFIED', 'DTSTART', 'DTEND', 'DTSTAMP', 'RDATE', 'TRIGGER', 'FREEBUSY', 'DUE', 'COMPLETED', 'EXDATE'); foreach ($dates as $key) { if (isset($event[$key])) { $date = date_ical_date($event[$key]); $item->options->$key = date_format($date, DATE_FORMAT_DATETIME) .';tz='. $event[$key]['tz']; unset($event[$key]); } } $item->raw = $event; $parsed_source->items[] = $item; } return $parsed_source; } /****************************************************************************************************************** * PATCHED FUNCTIONS */ /******************************************** * _parser_common_syndication_download * * Just changed to allow passing of $allowed_mine array() */ function _parser_ical_download($url) { $method = 'GET'; $follow = 3; $data = NULL; $headers = array(); if (!empty($username)) { $headers['Authorization'] = 'Basic '. base64_encode("$username:$password"); } $result = drupal_http_request($url, $headers, $method, $data, $follow); return $result->data; }