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

Fix issue when updating a contact

This commit is contained in:
LEDfan 2014-04-02 21:44:03 +02:00
parent ef12447f8d
commit 615077b900

View File

@ -28,7 +28,6 @@ use OCA\Contacts\Contact,
Sabre\VObject\Reader, Sabre\VObject\Reader,
OCA\Contacts\Addressbook; OCA\Contacts\Addressbook;
/** /**
* Contact backend for storing all the ownCloud users in this installation. * Contact backend for storing all the ownCloud users in this installation.
* Every user has *1* personal addressbook. The id of this addresbook is the * Every user has *1* personal addressbook. The id of this addresbook is the
@ -124,6 +123,8 @@ class LocalUsers extends AbstractBackend {
$this->removeContacts($remove, $addressbookid); $this->removeContacts($remove, $addressbookid);
$recall = true; $recall = true;
} }
//var_dump($contacts);
//throw new \Exception('err');
if($recall === true){ if($recall === true){
return $this->getContacts($addressbookid); return $this->getContacts($addressbookid);
@ -148,9 +149,9 @@ class LocalUsers extends AbstractBackend {
*/ */
public function getContact($addressbookid, $id, array $options = array()){ public function getContact($addressbookid, $id, array $options = array()){
try{ try{
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?'; $sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
$query = \OCP\DB::prepare($sql); $query = \OCP\DB::prepare($sql);
$result = $query->execute(array($this->userid)); $result = $query->execute(array($this->userid, $id));
if (\OCP\DB::isError($result)) { if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' \OCP\Util::writeLog('contacts', __METHOD__. 'DB error: '
@ -272,19 +273,17 @@ class LocalUsers extends AbstractBackend {
} }
$data = $contact->serialize(); $data = $contact->serialize();
try{ try{
$sql = 'UPDATE ' . $this->cardsTableName $sql = 'UPDATE ' . $this->cardsTableName
. ' SET ' . ' SET '
. '`addressbookid` = ?, '
. '`fullname` = ?, ' . '`fullname` = ?, '
. '`carddata` = ?, ' . '`carddata` = ?, '
. '`lastmodified` = ? ' . '`lastmodified` = ? '
. ' WHERE ' . ' WHERE '
. '`id` = ? ' . '`id` = ? '
. 'AND `owner` = ? '; . 'AND `addressbookid` = ? ';
$query = \OCP\DB::prepare($sql); $query = \OCP\DB::prepare($sql);
$result = $query->execute(array($addressBookId, $contact->FN, $data, time(), $id, $this->userid)); $result = $query->execute(array($contact->FN, $data, time(), $id, $this->userid));
if (\OCP\DB::isError($result)) { if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' \OCP\Util::writeLog('contacts', __METHOD__. 'DB error: '
. \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);