summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-04-18 15:00:02 +0200
committerGitHub <noreply@github.com>2019-04-18 15:00:02 +0200
commit049d613dba7ce39ed643a24c9880bf5196d3b670 (patch)
treefd253746077e089ba726f8147583670530de46b1 /lib/private
parente55e425a5922c013fb4ad222eca78f9995484328 (diff)
parentdb17c14f8039cef674f4c07f5dff05c105b39c49 (diff)
downloadnextcloud-server-049d613dba7ce39ed643a24c9880bf5196d3b670.tar.gz
nextcloud-server-049d613dba7ce39ed643a24c9880bf5196d3b670.zip
Merge pull request #15152 from nextcloud/enhancement/noid/contactsmenu-sharing-enum-settings
Respect sharing enumeration config in contacts menu
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Contacts/ContactsMenu/Manager.php20
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 [