/**
  * Returns the list of addressbooks for a specific user.
  *
  * @param string $principalUri
  * @return array
  */
 public function getAddressBooksForUser($principalUri)
 {
     $n = dav_compat_principal2namespace($principalUri);
     if ($n["namespace"] != $this->getNamespace()) {
         return array();
     }
     $addressBooks = array();
     $books = q("SELECT * FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($n["namespace"]), IntVal($n["namespace_id"]));
     foreach ($books as $row) {
         if (in_array($row["uri"], $GLOBALS["CARDDAV_PRIVATE_SYSTEM_ADDRESSBOOKS"])) {
             continue;
         }
         $addressBooks[] = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => $principalUri, '{DAV:}displayname' => $row['displayname'], '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['ctag'], '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData());
     }
     return $addressBooks;
 }
 /**
  * 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)
 {
     $n = dav_compat_principal2namespace($principalUri);
     if ($n["namespace"] != $this->getNamespace()) {
         return array();
     }
     $cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), IntVal($n["namespace_id"]));
     $ret = array();
     foreach ($cals as $cal) {
         if (!in_array($cal["uri"], $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"])) {
             continue;
         }
         $dat = array("id" => $cal["id"], "uri" => $cal["uri"], "principaluri" => $principalUri, '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $cal['ctag'] ? $cal['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array("VEVENT")), "calendar_class" => "Sabre_CalDAV_Calendar_Virtual");
         foreach ($this->propertyMap as $key => $field) {
             $dat[$key] = $cal[$field];
         }
         $ret[] = $dat;
     }
     return $ret;
 }