From 5e714a7e8ef1635a63db25bc44023b9de0ca33f6 Mon Sep 17 00:00:00 2001 From: LEDfan Date: Thu, 25 Sep 2014 08:08:50 +0200 Subject: [PATCH] Fix additional 404's refs https://github.com/owncloud/contacts/issues/623#issuecomment-56631474 --- js/app.js | 2 +- lib/addressbookprovider.php | 4 ++-- lib/hooks.php | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index 1b14e3bf..e797cca0 100644 --- a/js/app.js +++ b/js/app.js @@ -217,7 +217,7 @@ OC.notify = function(params) { if(!contacts_properties_indexed) { // Wait a couple of mins then check if contacts are indexed. setTimeout(function() { - $.when($.post(OC.generateUrl('apps/contacts/indexproperties/{user}/'))) + $.when($.post(OC.generateUrl('apps/contacts/indexproperties/{user}/', {user: OC.currentUser}))) .then(function(response) { if(!response.isIndexed) { OC.notify({message:t('contacts', 'Indexing contacts'), timeout:20}); diff --git a/lib/addressbookprovider.php b/lib/addressbookprovider.php index 46066f55..34dce065 100644 --- a/lib/addressbookprovider.php +++ b/lib/addressbookprovider.php @@ -91,8 +91,8 @@ class AddressbookProvider implements \OCP\IAddressBook { public function search($pattern, $searchProperties, $options) { $ids = array(); $results = array(); - $query = 'SELECT DISTINCT `contactid` FROM `' . self::PROPERTY_TABLE . '` WHERE ('; - $params = array(); + $query = 'SELECT DISTINCT `contactid` FROM `' . self::PROPERTY_TABLE . '` WHERE `userid` = ? AND ('; + $params = array(\OCP\User::getUser()); foreach($searchProperties as $property) { $params[] = $property; $params[] = '%' . $pattern . '%'; diff --git a/lib/hooks.php b/lib/hooks.php index db64d64c..08fd4c53 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -204,6 +204,11 @@ class Hooks{ } $offset += $limit; } + $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_cards_properties` + WHERE NOT EXISTS(SELECT NULL + FROM `*PREFIX*contacts_cards` + WHERE `*PREFIX*contacts_cards`.id = `*PREFIX*contacts_cards_properties`.contactid)'); + $result = $stmt->execute(array()); } public static function getCalenderSources($parameters) {