1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

extend func getIDFromUri

uri is no unique value; only combination of uri and addressbookid is unique
This commit is contained in:
ionum 2014-12-01 13:16:52 +01:00
parent 9862f45652
commit 15d2d74246

View File

@ -660,7 +660,7 @@ class Database extends AbstractBackend {
} elseif (isset($id['uri'])) {
$updateRevision = false;
$isCardDAV = true;
$id = $this->getIdFromUri($id['uri']);
$id = $this->getIdFromUri($addressBookId,$id['uri']);
if (is_null($id)) {
\OCP\Util::writeLog('contacts', __METHOD__ . ' Couldn\'t find contact', \OCP\Util::ERROR);
@ -744,7 +744,7 @@ class Database extends AbstractBackend {
$id = $id['id'];
} elseif (isset($id['uri'])) {
$id = $this->getIdFromUri($id['uri']);
$id = $this->getIdFromUri($addressBookId,$id['uri']);
if (is_null($id)) {
\OCP\Util::writeLog('contacts', __METHOD__ . ' Couldn\'t find contact', \OCP\Util::ERROR);
@ -812,13 +812,13 @@ class Database extends AbstractBackend {
/**
* @brief Get the contact id from the uri.
*
* @param mixed $id
* @param mixed $addressBookId,$id
* @returns int | null
*/
public function getIdFromUri($uri) {
public function getIdFromUri($addressBookId,$uri) {
$stmt = $this->getPreparedQuery('contactidfromuri');
$result = $stmt->execute(array($uri));
$result = $stmt->execute(array($addressBookId,$uri));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
@ -966,7 +966,7 @@ class Database extends AbstractBackend {
case 'contactidfromuri':
$args[] = 'SELECT `id` FROM `'
. $this->cardsTableName
. '` WHERE `uri` = ?';
. '` WHERE `addressbookid` = ? AND `uri` = ? ';
break;
case 'deletecontact':
$args[] = 'DELETE FROM `'