Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-02-21 20:10:38 +0300
committerBjoern Schiessle <bjoern@schiessle.org>2017-06-01 13:31:34 +0300
commita5f0f3f4f6eb5f212d6c5fa0bfa72a19c44b0c37 (patch)
treed707c30e12980d4a0f2b7e33fe488d8f4c83d9a3
parent0b8deebb4f99bbc3813ffbdb629a4b4a7da5c463 (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>
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php12
-rw-r--r--config/config.sample.php47
2 files changed, 41 insertions, 18 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');
}
diff --git a/config/config.sample.php b/config/config.sample.php
index fc22cf55962..95dbda9933c 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -451,20 +451,20 @@ $CONFIG = array(
*
* Available values:
*
- * * ``auto``
- * default setting. keeps files and folders in the trash bin for 30 days
- * and automatically deletes anytime after that if space is needed (note:
+ * * ``auto``
+ * default setting. keeps files and folders in the trash bin for 30 days
+ * and automatically deletes anytime after that if space is needed (note:
* files may not be deleted if space is not needed).
- * * ``D, auto``
- * keeps files and folders in the trash bin for D+ days, delete anytime if
+ * * ``D, auto``
+ * keeps files and folders in the trash bin for D+ days, delete anytime if
* space needed (note: files may not be deleted if space is not needed)
- * * ``auto, D``
- * delete all files in the trash bin that are older than D days
+ * * ``auto, D``
+ * delete all files in the trash bin that are older than D days
* automatically, delete other files anytime if space needed
- * * ``D1, D2``
- * keep files and folders in the trash bin for at least D1 days and
+ * * ``D1, D2``
+ * keep files and folders in the trash bin for at least D1 days and
* delete when exceeds D2 days
- * * ``disabled``
+ * * ``disabled``
* trash bin auto clean disabled, files and folders will be kept forever
*/
'trashbin_retention_obligation' => 'auto',
@@ -491,19 +491,19 @@ $CONFIG = array(
*
* Available values:
*
- * * ``auto``
- * default setting. Automatically expire versions according to expire
+ * * ``auto``
+ * default setting. Automatically expire versions according to expire
* rules. Please refer to :doc:`../configuration_files/file_versioning` for
* more information.
- * * ``D, auto``
- * keep versions at least for D days, apply expire rules to all versions
+ * * ``D, auto``
+ * keep versions at least for D days, apply expire rules to all versions
* that are older than D days
- * * ``auto, D``
- * delete all versions that are older than D days automatically, delete
+ * * ``auto, D``
+ * delete all versions that are older than D days automatically, delete
* other versions according to expire rules
- * * ``D1, D2``
+ * * ``D1, D2``
* keep versions for at least D1 days and delete when exceeds D2 days
- * * ``disabled``
+ * * ``disabled``
* versions auto clean disabled, versions will be kept forever
*/
'versions_retention_obligation' => 'auto',
@@ -1064,6 +1064,17 @@ $CONFIG = array(
*/
'sharing.managerFactory' => '\OC\Share20\ProviderFactory',
+/**
+ * Define max number of results returned by the user search for auto-completion
+ * Default is unlimited (value set to 0).
+ */
+'sharing.maxAutocompleteResults' => 0,
+
+/**
+ * Define the minimum length of the search string before we start auto-completion
+ * Default is no limit (value set to 0)
+ */
+'sharing.minSearchStringLength' => 0,
/**