/** * Returns a list of calendars for a principal. * * Every project is an array with the following keys: * * id, a unique id that will be used by other functions to modify the * calendar. This can be the same as the uri or a database key. * * uri, which the basename of the uri with which the calendar is * accessed. * * principalUri. The owner of the calendar. Almost always the same as * principalUri passed to this method. * * Furthermore it can contain webdav properties in clark notation. A very * common one is '{DAV:}displayname'. * * @param string $principalUri * @return array */ public function getCalendarsForUser($principalUri) { $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri); $calendars = array(); foreach ($raw as $row) { $components = explode(',', $row['components']); if ($row['userid'] != OCP\USER::getUser()) { $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid']; } $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet($components)); foreach ($this->propertyMap as $xmlName => $dbName) { $calendar[$xmlName] = isset($row[$dbName]) ? $row[$dbName] : ''; } $calendars[] = $calendar; } if (\OCP\App::isEnabled('contacts')) { $ctag = 0; $app = new \OCA\Contacts\App(); $addressBooks = $app->getAddressBooksForUser(); foreach ($addressBooks as $addressBook) { $tmp = $addressBook->lastModified(); if (!is_null($tmp)) { $ctag = max($ctag, $tmp); } } $ctag++; $calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/contact_birthdays', '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $ctag, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{http://apple.com/ns/ical/}calendar-color' => '#CCCCCC'); } return $calendars; }
/** * Returns a list of calendars for a principal. * * Every project is an array with the following keys: * * id, a unique id that will be used by other functions to modify the * calendar. This can be the same as the uri or a database key. * * uri, which the basename of the uri with which the calendar is * accessed. * * principalUri. The owner of the calendar. Almost always the same as * principalUri passed to this method. * * Furthermore it can contain webdav properties in clark notation. A very * common one is '{DAV:}displayname'. * * @param string $principalUri * @return array */ public function getCalendarsForUser($principalUri) { $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri); $calendars = array(); foreach ($raw as $row) { $components = explode(',', $row['components']); $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components)); foreach ($this->propertyMap as $xmlName => $dbName) { $calendar[$xmlName] = $row[$dbName]; } $calendars[] = $calendar; } return $calendars; }
/** * Returns a list of calendars for a principal. * * Every project is an array with the following keys: * * id, a unique id that will be used by other functions to modify the * calendar. This can be the same as the uri or a database key. * * uri, which the basename of the uri with which the calendar is * accessed. * * principalUri. The owner of the calendar. Almost always the same as * principalUri passed to this method. * * Furthermore it can contain webdav properties in clark notation. A very * common one is '{DAV:}displayname'. * * @param string $principalUri * @return array */ public function getCalendarsForUser($principalUri) { $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri); $calendars = array(); foreach ($raw as $row) { $components = explode(',', $row['components']); if ($row['userid'] != OCP\USER::getUser()) { $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid']; } $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components)); foreach ($this->propertyMap as $xmlName => $dbName) { $calendar[$xmlName] = $row[$dbName]; } $calendars[] = $calendar; } if (\OCP\App::isEnabled('contacts')) { \OCP\Share::registerBackend('addressbook', 'OCA\\Contacts\\Share\\Addressbook', 'contact'); $app = new \OCA\Contacts\App(\OCP\User::getUser()); $calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/contact_birthdays', '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT'))); } return $calendars; }