3 abstract class Sabre_CardDAV_Backend_Common extends Sabre_CardDAV_Backend_Abstract
9 abstract public function getNamespace();
16 abstract public static function getBackendTypeName();
21 static private $addressbookCache = array();
26 static private $addressbookObjectCache = array();
30 * @param int $addressbookId
33 static public function loadCalendarById($addressbookId)
35 if (!isset(self::$addressbookCache[$addressbookId])) {
36 $c = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId));
37 self::$addressbookCache[$addressbookId] = $c[0];
39 return self::$addressbookCache[$addressbookId];
47 static public function loadAddressbookobjectById($obj_id)
49 if (!isset(self::$addressbookObjectCache[$obj_id])) {
50 $o = q("SELECT * FROM %s%saddressbookobjects WHERE `id` = %d",
51 CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($obj_id)
53 self::$addressbookObjectCache[$obj_id] = $o[0];
55 return self::$addressbookObjectCache[$obj_id];
60 * Updates an addressbook's properties
62 * See Sabre_DAV_IProperties for a description of the mutations array, as
63 * well as the return value.
65 * @param mixed $addressBookId
66 * @param array $mutations
67 * @throws Sabre_DAV_Exception_Forbidden
68 * @see Sabre_DAV_IProperties::updateProperties
71 public function updateAddressBook($addressBookId, array $mutations)
75 foreach ($mutations as $property=> $newValue) {
78 case '{DAV:}displayname' :
79 $updates['displayname'] = $newValue;
81 case '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' :
82 $updates['description'] = $newValue;
85 // If any unsupported values were being updated, we must
86 // let the entire request fail.
92 // No values are being updated?
97 $query = 'UPDATE ' . CALDAV_SQL_DB . CALDAV_SQL_PREFIX . 'addressbooks SET ctag = ctag + 1 ';
98 foreach ($updates as $key=> $value) {
99 $query .= ', `' . dbesc($key) . '` = ' . dbesc($key) . ' ';
101 $query .= ' WHERE id = ' . IntVal($addressBookId);
109 * @param int $addressbookId
111 protected function increaseAddressbookCtag($addressbookId)
113 q("UPDATE %s%saddressbooks SET `ctag` = `ctag` + 1 WHERE `id` = '%d'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId));
114 self::$addressbookCache = array();