diff --git a/package.json b/package.json index dd25eb718..66ced8835 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "RainLoop", "title": "RainLoop Webmail", "version": "1.8.3", - "release": "301", + "release": "302", "description": "Simple, modern & fast web-based email client", "homepage": "http://rainloop.net", "main": "gulpfile.js", @@ -36,7 +36,7 @@ "plugins" ], "readmeFilename": "README.md", - "ownCloudPackageVersion": "3.2", + "ownCloudPackageVersion": "3.3", "engines": { "node": ">= 0.10.0" }, diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php index 1484597fa..d4a7aac97 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php @@ -18,11 +18,13 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion */ public function Process($oAccount, $sQuery, $iLimit = 20) { + $iInputLimit = $iLimit; $aResult = array(); + $sQuery = \trim($sQuery); try { - if (!$oAccount || !\RainLoop\Utils::IsOwnCloud() || + if ('' === $sQuery || !$oAccount || !\RainLoop\Utils::IsOwnCloud() || !\class_exists('\\OCP\\Contacts') || !\OCP\Contacts::isEnabled() || !\class_exists('\\OCP\\User') || !\OCP\User::isLoggedIn() ) @@ -33,7 +35,7 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion $aSearchResult = \OCP\Contacts::search($sQuery, array('FN', 'EMAIL')); //$this->oLogger->WriteDump($aSearchResult); - $aPreResult = array(); + $aHashes = array(); if (\is_array($aSearchResult) && 0 < \count($aSearchResult)) { foreach ($aSearchResult as $aContact) @@ -54,35 +56,23 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion $mEmails = array($mEmails); } - if (!isset($aPreResult[$sUid])) - { - $aPreResult[$sUid] = array(); - } - foreach ($mEmails as $sEmail) { - $sEmail = \trim($sEmail); - if (!empty($sEmail)) + $sHash = '"'.$sFullName.'" <'.$sEmail.'>'; + if (!isset($aHashes[$sHash])) { + $aHashes[$sHash] = true; + $aResult[] = array($sEmail, $sFullName); $iLimit--; - $aPreResult[$sUid][] = array($sEmail, $sFullName); } } } } - $aPreResult = \array_values($aPreResult); -// $this->oLogger->WriteDump($aPreResult); - foreach ($aPreResult as $aData) - { - foreach ($aData as $aSubData) - { - $aResult[] = $aSubData; - } - } + $aResult = \array_slice($aResult, 0, $iInputLimit); } - unset($aSearchResult, $aPreResult); + unset($aSearchResult, $aHashes); } catch (\Exception $oException) {