public function actionImportIcs($params) { $response = array('success' => true); $count = 0; $failed = array(); if (!file_exists($_FILES['ical_file']['tmp_name'][0])) { throw new \Exception($lang['common']['noFileUploaded']); } else { $file = new \GO\Base\Fs\File($_FILES['ical_file']['tmp_name'][0]); $file->convertToUtf8(); $contents = $file->getContents(); $vcal = \GO\Base\VObject\Reader::read($contents); \GO\Base\VObject\Reader::convertVCalendarToICalendar($vcal); foreach ($vcal->vtodo as $vtask) { $event = new \GO\Tasks\Model\Task(); try { $event->importVObject($vtask, array('tasklist_id' => $params['tasklist_id'])); $count++; } catch (\Exception $e) { $failed[] = $e->getMessage(); } } } $response['feedback'] = sprintf(\GO::t('import_success', 'tasks'), $count); if (count($failed)) { $response['feedback'] .= "\n\n" . count($failed) . " tasks failed: " . implode('\\n', $failed); } return $response; }
public function next() { // \GO::debug("next"); $data = $this->getNextData(); // \GO::debug($data); $this->current = false; if (empty($data)) { return false; } $vcal = \GO\Base\VObject\Reader::read($data); $vevents = $vcal->select($this->type); // \GO::debug("Found: ".count($vevents)); $vevent = array_shift($vevents); if ($vevent) { // \GO::debug("Found event"); $this->current = $vevent; $this->key++; return $this->current; } else { return false; } }
public function actionIcs() { $data = 'BEGIN:VCALENDAR CALSCALE:GREGORIAN PRODID:-//Apple Inc.//iOS 7.0//EN VERSION:2.0 BEGIN:VTIMEZONE TZID:Europe/Amsterdam BEGIN:DAYLIGHT DTSTART:19810329T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU TZNAME:CEST TZOFFSETFROM:+0100 TZOFFSETTO:+0200 END:DAYLIGHT BEGIN:STANDARD DTSTART:19961027T030000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU TZNAME:CET TZOFFSETFROM:+0200 TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE BEGIN:VEVENT CREATED:20140120T131840Z DTEND;TZID=Europe/Amsterdam:20140120T160000 DTSTAMP:20140120T131925Z DTSTART;TZID=Europe/Amsterdam:20140120T141500 LAST-MODIFIED:20140120T131840Z RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=20140120T131500Z;BYDAY=MO,WE SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Weekly1 TRANSP:OPAQUE UID:26ae3ffb-546c-5a32-b87e-49306b68de91 X-GO-REMINDER-TIME:20140120T140500 BEGIN:VALARM ACTION:DISPLAY DESCRIPTION:Alarm TRIGGER:-PT10M UID:A1AA22FB-D65D-438F-A03E-D93DC744B7EF X-WR-ALARMUID:A1AA22FB-D65D-438F-A03E-D93DC744B7EF END:VALARM END:VEVENT END:VCALENDAR'; $vcalendar = \GO\Base\VObject\Reader::read($data); echo (string) $vcalendar->vevent[0]->rrule; }
/** * Get the VCALENDAR object as SabreDav vobject component * * @return Sabre\VObject\Component */ public function getInvitationVcalendar() { $attachments = $this->getAttachments(); foreach ($attachments as $attachment) { if ($attachment->isVcalendar()) { $data = $this->getImapConnection()->get_message_part_decoded($this->uid, $attachment->number, $attachment->encoding); $vcalendar = \GO\Base\VObject\Reader::read($data); if ($vcalendar && isset($vcalendar->vevent[0])) { return $vcalendar; } } } return false; }
protected function actionImportIcs($params) { $file = new \GO\Base\Fs\File($params['file']); $data = $file->getContents(); $vcalendar = \GO\Base\VObject\Reader::read($data); \GO\Base\VObject\Reader::convertVCalendarToICalendar($vcalendar); foreach ($vcalendar->vtodo as $vtodo) { $task = new \GO\Tasks\Model\Task(); $task->importVObject($vtodo); } }
private function _importSmarterMailXml($params, File $file) { $sXml = new SimpleXMLElement($file->getContents()); $count = 0; $failed = array(); foreach ($sXml->children() as $obj) { if ($obj->getName() == 'Event') { $event = new Event(); try { $data = (string) $obj->Data; // \GO::debug($data); $vObject = \GO\Base\VObject\Reader::read($data); $event->importVObject($vObject->vevent[0], array('calendar_id' => $params['calendar_id'])); $count++; // break; } catch (\Exception $e) { $failed[] = $e->getMessage(); } } } $response['feedback'] = sprintf(\GO::t('import_success', 'calendar'), $count); if (count($failed)) { $response['feedback'] .= "\n\n" . count($failed) . " events failed: " . implode("\n", $failed); } return $response; }