Hello! We are running our annual fundraising. Please consider making a donation if you value this freely available service or want to support people around the world working towards liberatory social change. https://riseup.net/donate.

Commit 1b5c3dc2 authored by ekes's avatar ekes
Browse files

Add GEO and STATUS, correct LOCATION for iCal. Fixes #140,

parent ee62f985
......@@ -122,4 +122,47 @@ function radar_event_ical_date_ical_export_raw_event_alter(&$event, $view, $cont
if (isset($event['rrule'])) {
unset($event['rrule']);
}
// Add LOCATION
// Only one location is valid in iCal. We join on the first field_offline.
if (!empty($context['row']->field_field_address)) {
$location_html = render($context['row']->field_field_address[0]['rendered']);
$location_array = [];
preg_match_all("'<[^>]*>(.*?)</[^>]*>'si", $location_html, $location_array);
if (!empty($location_array)) {
foreach ($location_array[0] as $delta => $row) {
$location_array[0][$delta] = strip_tags($row);
}
$event['location'] = implode(', ', $location_array[0]);
}
}
// Add GEO.
if (
!empty($context['row']->field_field_map)
&& $context['row']->field_field_map[0]['raw']['geo_type'] == 'point'
) {
$event['geo']['lat'] = $context['row']->field_field_map[0]['raw']['lat'];
$event['geo']['lon'] = $context['row']->field_field_map[0]['raw']['lon'];
}
// Add STATUS.
if (!empty($context['row']->field_field_event_status)) {
$event['status'] = strtoupper(render($context['row']->field_field_event_status[0]['rendered']));
}
}
/**
* Implements hook_ical_date_ical_export_vevent_alter().
*/
function radar_event_ical_date_ical_export_vevent_alter(&$vevent, $view, $event) {
// Location is already set.
// Add GEO and STATUS.
if (!empty($event['geo'])) {
$vevent->setGeo($event['geo']['lat'], $event['geo']['lon']);
}
if (!empty($event['status'])) {
$vevent->setStatus($event['status']);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment