1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Database backend: Lookup parent in updateContact() if not known.

This commit is contained in:
Thomas Tanghus 2013-05-21 23:38:02 +02:00
parent 6d4c0fb964
commit 9b6a2fde01

View File

@ -452,7 +452,7 @@ class Database extends AbstractBackend {
}
try {
$query = 'SELECT `id`, `uri`, `carddata`, `lastmodified`, `fullname` AS `displayname` FROM `'
$query = 'SELECT `id`, `uri`, `carddata`, `lastmodified`, `addressbookid` AS `parent`, `fullname` AS `displayname` FROM `'
. $this->cardsTableName . '` WHERE ' . $where_query;
$stmt = \OCP\DB::prepare($query);
$result = $stmt->execute($ids);
@ -598,10 +598,15 @@ class Database extends AbstractBackend {
$data = $contact->serialize();
$updates = array($contact->FN, $data, time(), $id);
if(!$noCollection) {
if($noCollection) {
$me = $this->getContact(null, $id, true);
$addressbookid = $me['parent'];
}
//if(!$noCollection) {
$where_query .= ' AND `addressbookid` = ?';
$updates[] = $addressbookid;
}
//}
$query = 'UPDATE `' . $this->cardsTableName
. '` SET `fullname` = ?,`carddata` = ?, `lastmodified` = ? WHERE ' . $where_query;