The addition of alarms to iCal .ics export would be an excellent feature. The code to add a basic alarm to every event 15 minutes before the event start is shown below. Adding a user interface to allow setting of alarms and how long before the event would be a bonus.
The following is added starting at line 58 in ical.inc from 4.7-cvs version.

    $output .= "UID:" . ($event['uid'] ? $event['uid'] : $uid) . "\n";
    # GPD Alarm Patch
    $output .= "BEGIN:VALARM\n";
    $output .= "ACTION:AUDIO\n";
    $output .= "TRIGGER:-PT15M\n";
    $output .= "X-WR-ALARMUID:" . ($event['uid'] ? $event['uid'] : $uid) . "\n";
    $output .= "ATTACH;VALUE=URI:Basso\n";
    $output .= "END:VALARM\n";
    # /GPD Alarm Patch
    $output .= "END:VEVENT\n";

Comments

frank005’s picture

Version: 4.7.x-1.x-dev » 6.x-2.x-dev
Status: Active » Needs review

The Action is probably better to be DISPLAY so it is more universally accepted by the various products.

You also don't need a X-WR-ALARMUID.

Here is how I modified my ical.ics file. Something like this really should be committed in to the dev build:

function ical_export($events, $calname = NULL) {
  $output = "BEGIN:VCALENDAR\nVERSION:2.0\n";
  $output .= "METHOD:PUBLISH\n";
  $output .= 'X-WR-CALNAME:'. variable_get('site_name', '') .' | '. ical_escape_text($calname) ."\n";
  $output .= "PRODID:-//strange bird labs//Drupal iCal API//EN\n";
  foreach ($events as $uid => $event) {
    $output .= "BEGIN:VEVENT\n";
    $output .= "DTSTAMP;VALUE=DATE-TIME:". gmdate("Ymd\THis\Z", time()) ."\n";
    if (!$event['has_time']) { // all day event
      $output .= "DTSTART;VALUE=DATE-TIME:" . event_format_date($event['start_utc'], 'custom', "Ymd\THis\Z") ."\n";
      //If allday event, set to day after allday start
      $end_date = event_date_later($event['start'], 1);
      $output .= "DTEND;VALUE=DATE-TIME:" . event_format_date($end_date, 'custom', 'Ymd') ."\n";
    }
    else if (!empty($event['start_utc']) && !empty($event['end_utc'])) {
      $output .= "DTSTART;VALUE=DATE-TIME:". event_format_date($event['start_utc'], 'custom', "Ymd\THis\Z") ."\n";
      $output .= "DTEND;VALUE=DATE-TIME:". event_format_date($event['end_utc'], 'custom', "Ymd\THis\Z") ."\n";
    }
    else if (!empty($event['start_utc'])) {
      $output .= "DTSTART;VALUE=DATE-TIME:". event_format_date($event['start_utc'], 'custom', "Ymd\THis\Z") ."\n";
    }
    $output .= "UID:". ($event['uid'] ? $event['uid'] : $uid) ."\n";
    if (!empty($event['url'])) {
      $output .= "URL;VALUE=URI:" . $event['url'] ."\n";
    }
    if (!empty($event['location'])) {
      $output .= "LOCATION:" . ical_escape_text($event['location']) ."\n";
    }
    $output .= "SUMMARY:" . ical_escape_text($event['summary']) ."\n";
    if (!empty($event['description'])) {
      $output .= "DESCRIPTION:" . ical_escape_text($event['description']) ."\n";
    }
	$output .= "BEGIN:VALARM\nACTION:DISPLAY\nTRIGGER;RELATED=START:-PT1H\n";
	
	$output .= "SUMMARY:" . ical_escape_text($event['summary']) ."\n";
    if (!empty($event['description'])) {
      $output .= "DESCRIPTION:" . ical_escape_text($event['description']) ."\n";
    }
	$output .="END:VALARM\n";
  }
  $output .= "END:VEVENT\n";
  $output .= "END:VCALENDAR\n";
  return $output;
}
japerry’s picture

Status: Needs review » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.