/** * Get the Vobject of this calendar * * @return string */ public function toVObject() { //$stmt = $this->events(\GO\Base\Db\FindParams::newInstance()->select("t.*")); $findParams = \GO\Base\Db\FindParams::newInstance()->select("t.*"); $findParams->getCriteria()->addCondition("calendar_id", $this->id); $stmt = Event::model()->findForPeriod($findParams, \GO\Base\Util\Date::date_add(time(), 0, -1)); $string = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Intermesh//NONSGML " . \GO::config()->product_name . " " . \GO::config()->version . "//EN\r\n"; $t = new \GO\Base\VObject\VTimezone(); $string .= $t->serialize(); while ($event = $stmt->fetch()) { $v = $event->toVObject(); $string .= $v->serialize(); } $string .= "END:VCALENDAR\r\n"; return $string; }
protected function actionExportEventAsIcs($event_id) { $eventModel = \GO\Calendar\Model\Event::model()->findByPk($event_id); if (!$eventModel) { throw new Exception('Could not find event with ID #' . $event_id . '.'); } if ($eventModel->exception_for_event_id > 0) { $eventModel = \GO\Calendar\Model\Event::model()->findByPk($eventModel->exception_for_event_id); } if (!$eventModel) { throw new Exception('Could not find main recurring event of event #' . $event_id . '.'); } \GO\Base\Util\Http::outputDownloadHeaders(new \GO\Base\FS\File($eventModel->calendar->name . ' - ' . \GO\Base\Util\Date::get_timestamp($eventModel->start_time) . ' ' . $eventModel->name . '.ics')); echo "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Intermesh//NONSGML " . \GO::config()->product_name . " " . \GO::config()->version . "//EN\r\n"; $t = new \GO\Base\VObject\VTimezone(); echo $t->serialize(); $v = $eventModel->toVObject(); echo $v->serialize(); $exceptionsStmt = \GO\Calendar\Model\Event::model()->findByAttributes(array('calendar_id' => $eventModel->calendar_id, 'exception_for_event_id' => $eventModel->id)); foreach ($exceptionsStmt as $exceptionEventModel) { $vexc = $exceptionEventModel->toVObject(); echo $vexc->serialize(); } echo "END:VCALENDAR\r\n"; }