summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller/ShareesAPIController.php
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-02-21 18:10:38 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-02-21 18:31:20 +0100
commit869ea38ffe77e92b9a5651fe07020b4035d1f1d3 (patch)
treea36225e8e1a858478a6f615277865f14f42ac1c5 /apps/files_sharing/lib/Controller/ShareesAPIController.php
parent0453a7dabd031cacd43843660d921f7a861f4eef (diff)
downloadnextcloud-server-869ea38ffe77e92b9a5651fe07020b4035d1f1d3.tar.gz
nextcloud-server-869ea38ffe77e92b9a5651fe07020b4035d1f1d3.zip
allow to configure a min-length of search strings for auto-compeltion and a max number for of results returned
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareesAPIController.php')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 40a9b272bc8..171fac4dbd2 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -413,6 +413,18 @@ class ShareesAPIController extends OCSController {
* @throws OCSBadRequestException
*/
public function search($search = '', $itemType = null, $page = 1, $perPage = 200, $shareType = null, $lookup = true) {
+
+ // only search for string larger than a given threshold
+ $threshold = $this->config->getSystemValue('sharing.minSearchStringLength', 0);
+ if (strlen($search) < $threshold) {
+ return new Http\DataResponse($this->result);
+ }
+
+ // never return more than the max. number of results configured in the config.php
+ $maxResults = $this->config->getSystemValue('sharing.maxAutocompleteResults', 0);
+ if ($maxResults > 0) {
+ $perPage = min($perPage, $maxResults);
+ }
if ($perPage <= 0) {
throw new OCSBadRequestException('Invalid perPage argument');
}