1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-19 08:52:22 +01:00

Fix setting address book active

This commit is contained in:
Thomas Tanghus 2013-11-07 14:24:55 +01:00
parent aa8a51d9a7
commit dd846a15f8
2 changed files with 19 additions and 6 deletions

View File

@ -248,6 +248,18 @@ abstract class AbstractBackend {
public function lastModifiedAddressBook($addressbookid) {
}
/**
* @brief 'touch' an address book.
*
* If implemented this method must mark the address books
* modification date so lastModifiedAddressBook() can be
* used to invalidate the cache.
*
* @param string $addressbookid
*/
public function setModifiedAddressBook($addressbookid) {
}
/**
* Returns all contacts for a specific addressbook id.
*
@ -375,7 +387,7 @@ abstract class AbstractBackend {
$key = $this->combinedKey($addressBookId);
$key = 'active_' . $key;
return (\OCP\Config::getUserValue($this->userid, 'contacts', $key, 'true') === 'true');
return !!(\OCP\Config::getUserValue($this->userid, 'contacts', $key, 1));
}
/**
@ -388,7 +400,8 @@ abstract class AbstractBackend {
$key = $this->combinedKey($addressBookId);
$key = 'active_' . $key;
return \OCP\Config::setUserValue($this->userid, 'contacts', $key, $active);
$this->setModifiedAddressBook($addressBookId);
return \OCP\Config::setUserValue($this->userid, 'contacts', $key, (int)$active);
}
/**

View File

@ -324,7 +324,7 @@ class Database extends AbstractBackend {
* @param integer $id
* @return boolean
*/
public function touchAddressBook($id) {
public function setModifiedAddressBook($id) {
$query = 'UPDATE `' . $this->addressBooksTableName
. '` SET `ctag` = ? + 1 WHERE `id` = ?';
if(!isset(self::$preparedQueries['touchaddressbook'])) {
@ -552,7 +552,7 @@ class Database extends AbstractBackend {
}
$newid = \OCP\DB::insertid($this->cardsTableName);
$this->touchAddressBook($addressbookid);
$this->setModifiedAddressBook($addressbookid);
\OCP\Util::emitHook('OCA\Contacts', 'post_createContact',
array('id' => $newid, 'parent' => $addressbookid, 'backend' => $this->name, 'contact' => $contact)
);
@ -636,7 +636,7 @@ class Database extends AbstractBackend {
return false;
}
$this->touchAddressBook($addressbookid);
$this->setModifiedAddressBook($addressbookid);
if(!$isBatch) {
\OCP\Util::emitHook('OCA\Contacts', 'post_updateContact',
array(
@ -714,7 +714,7 @@ class Database extends AbstractBackend {
. $id, \OCP\Util::DEBUG);
return false;
}
$this->touchAddressBook($addressbookid);
$this->setModifiedAddressBook($addressbookid);
return true;
}