public function calendar() { $hookname = 'hook_calendar'; $moduleList = $this->AppUI->getLoadableModuleList(); foreach ($moduleList as $module) { if (class_exists($module['mod_main_class'])) { $object = new $module['mod_main_class'](); if (is_callable(array($object, $hookname))) { $itemList = $object->{$hookname}($this->AppUI->user_id); foreach ($itemList as $calendarItem) { $buffer .= w2p_API_iCalendar::formatCalendarItem($calendarItem, $module['mod_directory']); } } } } return $buffer; }
date_default_timezone_set($defaultTZ); switch ($format) { //TODO: We only output in vCal, are there others we need to consider? case 'vcal': default: $format = 'vcal'; header('Content-Type: text/calendar'); header('Content-disposition: attachment; filename="calendar.ics"'); break; } if ($userId > 0) { $moduleList = $AppUI->getLoadableModuleList(); $myTimezoneName = date('e'); $calendarHeader = "BEGIN:VCALENDAR\nPRODID:-//web2project//EN\nVERSION:2.0\nCALSCALE:GREGORIAN\nMETHOD:PUBLISH\nX-WR-TIMEZONE:Europe/London\n"; $calendarFooter = "END:VCALENDAR"; foreach ($moduleList as $module) { if (!in_array($module['mod_main_class'], get_declared_classes())) { require_once $AppUI->getModuleClass($module['mod_directory']); } $object = new $module['mod_main_class'](); if (is_callable(array($object, 'hook_calendar'))) { $itemList = $object->hook_calendar($userId); if (is_array($itemList)) { foreach ($itemList as $calendarItem) { $buffer .= w2p_API_iCalendar::formatCalendarItem($calendarItem, $module['mod_directory']); } } } } echo $calendarHeader . $buffer . $calendarFooter; }