X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=dav%2Ffriendica%2Fdav_carddav_backend_virtual_friendica.inc.php;h=3a06d042b5290dbac039d401fea00ae932d19683;hb=5360f08f4295f2306d815a7659fbdff94fda01a3;hp=3d7e09745574f55bd246dd5210cc504f4b8e65a8;hpb=8751d2221b2be61e81219d0b8d9dfc38483f2f09;p=friendica-addons.git diff --git a/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php index 3d7e0974..3a06d042 100644 --- a/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php @@ -128,15 +128,15 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual /** * @static * @param int $addressbookId + * @param bool $force * @throws Sabre_DAV_Exception_NotFound */ - static protected function createCache_internal($addressbookId) { + static protected function createCache_internal($addressbookId, $force = false) { //$notin = (count($exclude_ids) > 0 ? " AND id NOT IN (" . implode(", ", $exclude_ids) . ") " : ""); $addressbook = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId)); if (count($addressbook) != 1 || $addressbook[0]["namespace"] != CARDDAV_NAMESPACE_PRIVATE) throw new Sabre_DAV_Exception_NotFound(); $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC", $addressbook[0]["namespace_id"]); - $retdata = array(); foreach ($contacts as $contact) { $x = static::dav_contactarr2vcardsource($contact); q("INSERT INTO %s%saddressbookobjects (`addressbook_id`, `contact`, `carddata`, `uri`, `lastmodified`, `etag`, `size`) VALUES (%d, %d, '%s', '%s', NOW(), '%s', %d)", @@ -146,6 +146,27 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual } + /** + * @static + * @param int $addressbookId + * @param int $contactId + * @param bool $force + * @throws Sabre_DAV_Exception_NotFound + */ + static protected function createCardCache($addressbookId, $contactId, $force = false) + { + $addressbook = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId)); + if (count($addressbook) != 1 || $addressbook[0]["namespace"] != CARDDAV_NAMESPACE_PRIVATE) throw new Sabre_DAV_Exception_NotFound(); + + $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 AND `id` = %d ORDER BY `name` ASC", + $addressbook[0]["namespace_id"], IntVal($contactId)); + $contact = $contacts[0]; + + $x = static::dav_contactarr2vcardsource($contact); + q("INSERT INTO %s%saddressbookobjects (`addressbook_id`, `contact`, `carddata`, `uri`, `lastmodified`, `etag`, `size`) VALUES (%d, %d, '%s', '%s', NOW(), '%s', %d)", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId, $contact["id"], dbesc($x["carddata"]), dbesc($x["uri"]), dbesc($x["etag"]), $x["size"] + ); + } /** * Updates a card. * @@ -202,4 +223,5 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual return true; } + }