/** * @brief creates an VCalendar Object from the request data * @param array $request * @return object created $vcalendar */ public function createVCalendarFromRequest($request) { $vcalendar = new VObject('VCALENDAR'); $vcalendar->add('PRODID', 'ownCloud Calendar'); $vcalendar->add('VERSION', '2.0'); $vevent = new VObject('VEVENT'); $vcalendar->add($vevent); $vevent->setDateTime('CREATED', 'now'); //$vevent->setUID(); return $this->updateVCalendarFromRequest($request, $vcalendar); }
/** * Extracts all matching contacts with email address and name * * @param string $term * @return array */ public function addBirthdays($userid, $calId) { if (!$this->contactsManager->isEnabled()) { return array(); } $addrBooks = $this->contactsManager->getAddressBooks(); $aContacts = array(); foreach ($addrBooks as $key => $addrBook) { if (is_integer($key)) { $bContacts = \OCA\ContactsPlus\VCard::all($key); $aContacts = array_merge($aContacts, $bContacts); } } $sDateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y'); if ($sDateFormat === 'd-m-Y') { $sDateFormat = 'd.m.Y'; } $aResult = array(); foreach ($aContacts as $contact) { $vcard = \Sabre\VObject\Reader::read($contact['carddata']); if (isset($vcard->BDAY)) { $Birthday = new \DateTime((string) $vcard->BDAY); $checkForm = $Birthday->format('d-m-Y'); $temp = explode('-', $checkForm); $getAge = $this->getAge($temp[2], $temp[1], $temp[0]); $title = $contact['fullname']; $birthdayOutput = $Birthday->format($sDateFormat); $aktYear = $Birthday->format('d-m'); $aktYear = $aktYear . date('-Y'); $start = new \DateTime($aktYear); $end = new \DateTime($aktYear . ' +1 day'); $vcalendar = new VObject('VCALENDAR'); $vcalendar->add('PRODID', 'ownCloud Calendar'); $vcalendar->add('VERSION', '2.0'); $vevent = new VObject('VEVENT'); $vcalendar->add($vevent); $vevent->setDateTime('CREATED', 'now'); $vevent->add('DTSTART'); $vevent->DTSTART->setDateTime($start); $vevent->add('DTEND'); $vevent->DTEND->setDateTime($end); $vevent->DTSTART['VALUE'] = 'date'; $vevent->DTEND['VALUE'] = 'date'; $vevent->{'RRULE'} = 'FREQ=YEARLY;INTERVAL=1'; $vevent->{'TRANSP'} = 'TRANSPARENT'; $vevent->{'SUMMARY'} = (string) $title . ' (' . $getAge . ')'; $description = (string) $this->l10n->t("Happy Birthday! Born on: ") . $birthdayOutput; $vevent->setString('DESCRIPTION', $description); $vevent->{'UID'} = substr(md5(rand() . time()), 0, 10); $insertid = Object::add($calId, $vcalendar->serialize()); if ($this->isDuplicate($insertid)) { Object::delete($insertid); } } } }
public static function createVCalendarFromRequest($request) { $vcalendar = new VObject('VCALENDAR'); $vcalendar->add('PRODID', 'ownCloud Calendar'); $vcalendar->add('VERSION', '2.0'); $vtodo = new VObject('VTODO'); $vcalendar->add($vtodo); $vtodo->setDateTime('CREATED', 'now'); $vtodo->setUID(); return self::updateVCalendarFromRequest($request, $vcalendar); }