// so just removing duration for now as it's implied by the start and end anyway - TODO better
     // $ea['Duration']=($duration);
     $ea['Contact'] = array($event['user']);
     if (!empty($event['organizers'])) {
         $ea['organizer'] = array($event['organizers']);
     }
     if (!empty($event['url'])) {
         $ea['URL'] = $event['url'];
     }
     $ea['DateStamp'] = $event['created'];
     //$ea['RequestStatus']=$event['status'];
     $ea['UID'] = 'tiki-' . $event['calendarId'] . '-' . $event['calitemId'];
     $c = $iCal->factory('Event', $ea);
     $cal->addEvent($c);
 }
 $iCal->addCalendar($cal);
 $iCal->sendHeader("calendar");
 $calendar_str = $iCal->__toString();
 header("Content-Length: " . strlen($calendar_str));
 header("Expires: 0");
 // These two lines fix pb with IE and HTTPS
 header("Cache-Control: private");
 header("Pragma: dummy=bogus");
 // Outlook needs iso8859 encoding
 header("Content-Type:text/calendar; method=REQUEST; charset=iso-8859-15");
 header("Content-Transfer-Encoding:quoted-printable");
 $re_encode = stripos($_SERVER['HTTP_USER_AGENT'], 'windows');
 // only re-encode to ISO-8859-15 if client on Windows
 if (function_exists('recode') && $re_encode !== false) {
     print recode('utf-8..iso8859-15', $calendar_str);
 } elseif (function_exists('iconv') && $re_encode !== false) {