summaryrefslogtreecommitdiffstats
path: root/lib/private/Contacts
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-04-18 11:39:49 +0200
committerJulius Härtl <jus@bitgrid.net>2019-04-18 11:39:49 +0200
commitdb17c14f8039cef674f4c07f5dff05c105b39c49 (patch)
tree794c73eddb21c4fb56da37b138ac2a4c6ca9ad9c /lib/private/Contacts
parent16b8017fc906f7a3cf105304f6abdc0e2443a078 (diff)
downloadnextcloud-server-db17c14f8039cef674f4c07f5dff05c105b39c49.tar.gz
nextcloud-server-db17c14f8039cef674f4c07f5dff05c105b39c49.zip
Respect sharing enumeration config in contacts menu
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Contacts')
-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 [