diff options
Diffstat (limited to 'lib/private/Contacts/ContactsMenu/Manager.php')
-rw-r--r-- | lib/private/Contacts/ContactsMenu/Manager.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/private/Contacts/ContactsMenu/Manager.php b/lib/private/Contacts/ContactsMenu/Manager.php index 676ba602894..15f724e6ee6 100644 --- a/lib/private/Contacts/ContactsMenu/Manager.php +++ b/lib/private/Contacts/ContactsMenu/Manager.php @@ -26,6 +26,7 @@ namespace OC\Contacts\ContactsMenu; use OCP\App\IAppManager; use OCP\Contacts\ContactsMenu\IEntry; +use OCP\IConfig; use OCP\IUser; class Manager { @@ -39,15 +40,19 @@ class Manager { /** @var IAppManager */ private $appManager; + /** @var IConfig */ + private $config; + /** * @param ContactsStore $store * @param ActionProviderStore $actionProviderStore * @param IAppManager $appManager */ - public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) { + public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IConfig $config) { $this->store = $store; $this->actionProviderStore = $actionProviderStore; $this->appManager = $appManager; + $this->config = $config; } /** @@ -56,11 +61,16 @@ class Manager { * @return array */ public function getEntries(IUser $user, $filter) { - $entries = $this->store->getContacts($user, $filter); + $maxAutocompleteResults = $this->config->getSystemValueInt('sharing.maxAutocompleteResults', 25); + $minSearchStringLength = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0); + $topEntries = []; + if (strlen($filter) >= $minSearchStringLength) { + $entries = $this->store->getContacts($user, $filter); - $sortedEntries = $this->sortEntries($entries); - $topEntries = array_slice($sortedEntries, 0, 25); - $this->processEntries($topEntries, $user); + $sortedEntries = $this->sortEntries($entries); + $topEntries = array_slice($sortedEntries, 0, $maxAutocompleteResults); + $this->processEntries($topEntries, $user); + } $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user); return [ |