tags to new line characters for descriptions in HTML format. $description = html_to_text($description, 0); $ev->add_property('description', $description); $ev->add_property('class', 'PUBLIC'); // PUBLIC / PRIVATE / CONFIDENTIAL $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified)); if (!empty($event->location)) { $ev->add_property('location', $event->location); } $ev->add_property('dtstamp', Bennu::timestamp_to_datetime()); // now if ($event->timeduration > 0) { //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts. $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration)); } else if ($event->timeduration == 0) { // When no duration is present, the event is instantaneous event, ex - Due date of a module. // Moodle doesn't support all day events yet. See MDL-56227. $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart)); } else { // This can be used to represent all day events in future. throw new coding_exception("Negative duration is not supported yet."); } if ($event->courseid != 0) { $coursecontext = context_course::instance($event->courseid); $ev->add_property('categories', format_string($courses[$event->courseid]->shortname, true, array('context' => $coursecontext))); } $ical->add_component($ev); } $serialized = $ical->serialize(); if(empty($serialized)) { // TODO die('bad serialization'); } $filename = 'icalexport.ics'; header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0'); header('Expires: '. gmdate('D, d M Y H:i:s', 0) .'GMT'); header('Pragma: no-cache'); header('Accept-Ranges: none'); // Comment out if PDFs do not work... header('Content-disposition: attachment; filename='.$filename); header('Content-length: '.strlen($serialized)); header('Content-type: text/calendar; charset=utf-8'); echo $serialized;