diff --git a/lib/addressbookprovider.php b/lib/addressbookprovider.php index 031fb8cf..5f34c436 100644 --- a/lib/addressbookprovider.php +++ b/lib/addressbookprovider.php @@ -46,7 +46,7 @@ class AddressbookProvider implements \OCP\IAddressBook { /** * Constructor - * @param integer $id + * @param AddressBook $addressBook */ public function __construct($addressBook) { $this->addressBook = $addressBook; diff --git a/lib/backend/localusers.php b/lib/backend/localusers.php index db5e5046..5d312787 100644 --- a/lib/backend/localusers.php +++ b/lib/backend/localusers.php @@ -101,7 +101,8 @@ class LocalUsers extends AbstractBackend { "id" => $addressBookId, "displayname" => (string)self::$l10n->t('On this %s', array(self::$defaults->getName())), "description" => (string)self::$l10n->t('On this %s', array(self::$defaults->getName())), - "ctag" => time(), + "lastmodified" => time(), + /* FIXME: we need on 'owner' here */ "permissions" => \OCP\PERMISSION_READ, "backend" => $this->name, "active" => 1 @@ -124,7 +125,7 @@ class LocalUsers extends AbstractBackend { if (\OCP\DB::isError($result)) { \OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); - return true; + return $contacts; } else { while($row = $result->fetchRow()){ $row['permissions'] = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE; @@ -135,7 +136,7 @@ class LocalUsers extends AbstractBackend { } catch(\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__.' exception: ' . $e->getMessage(), \OCP\Util::ERROR); - return array(); + return $contacts; } } @@ -156,7 +157,7 @@ class LocalUsers extends AbstractBackend { if (\OCP\DB::isError($result)) { \OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); - return array(); + return null; } else { $row = $result->fetchRow(); $row['permissions'] = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE; @@ -165,7 +166,7 @@ class LocalUsers extends AbstractBackend { } catch(\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__.' exception: ' . $e->getMessage(), \OCP\Util::ERROR); - return array(); + return null; } } @@ -182,7 +183,7 @@ class LocalUsers extends AbstractBackend { $sql = 'INSERT INTO ' . $this->cardsTableName . ' (' . 'id, ' . 'addressbookid, ' - . 'fullname, ' + . 'fullname, ' /* Change to displayname*/ . 'carddata, ' . 'lastmodified' . ') VALUES (' @@ -308,8 +309,8 @@ class LocalUsers extends AbstractBackend { * This is a hack so backends can have different search functions. * @return \OCA\Contacts\LocalUsersAddressbookProvider */ - public function getSearchProvider(){ - return new LocalUsersAddressbookProvider($this); + public function getSearchProvider($addressBook) { + return new LocalUsersAddressbookProvider($addressBook); } /** @@ -408,4 +409,12 @@ class LocalUsers extends AbstractBackend { return true; } } + + /** + * Don't cache + */ + public function lastModifiedAddressBook($addressBookId) { + return time(); + } + } diff --git a/lib/localusersaddressbookprovider.php b/lib/localusersaddressbookprovider.php index 952dc8f2..e0cc28f8 100644 --- a/lib/localusersaddressbookprovider.php +++ b/lib/localusersaddressbookprovider.php @@ -52,8 +52,12 @@ class LocalUsersAddressbookProvider implements \OCP\IAddressBook { */ private $backend; - public function __construct(LocalUsers $backend) { - $this->backend = $backend; + /** + * Constructor + * @param AddressBook $addressBook + */ + public function __construct(AddressBook $addressBook) { + $this->addressBook = $addressBook; } /** @@ -64,7 +68,7 @@ class LocalUsersAddressbookProvider implements \OCP\IAddressBook { */ public function search($pattern, $searchProperties, $options) { // First make sure the database is updated - $this->backend->updateDatabase(); + $this->addressBook->getBackend()->updateDatabase(); $ids = array(); $results = array();