diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-02-21 20:10:38 +0300 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-06-01 13:31:34 +0300 |
commit | a5f0f3f4f6eb5f212d6c5fa0bfa72a19c44b0c37 (patch) | |
tree | d707c30e12980d4a0f2b7e33fe488d8f4c83d9a3 /apps | |
parent | 0b8deebb4f99bbc3813ffbdb629a4b4a7da5c463 (diff) |
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')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 12 |
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 6b3208dc289..8f44e650c43 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -427,6 +427,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'); } |