Esempio n. 1
0
 /**
  * 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 = CalendarCalendar::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/' . \OCP\USER::getUser(), '{' . \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;
     }
     return $calendars;
 }