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>
This commit is contained in:
parent
0453a7dabd
commit
869ea38ffe
|
@ -413,6 +413,18 @@ class ShareesAPIController extends OCSController {
|
||||||
* @throws OCSBadRequestException
|
* @throws OCSBadRequestException
|
||||||
*/
|
*/
|
||||||
public function search($search = '', $itemType = null, $page = 1, $perPage = 200, $shareType = null, $lookup = true) {
|
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) {
|
if ($perPage <= 0) {
|
||||||
throw new OCSBadRequestException('Invalid perPage argument');
|
throw new OCSBadRequestException('Invalid perPage argument');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1185,6 +1185,17 @@ $CONFIG = array(
|
||||||
*/
|
*/
|
||||||
'sharing.managerFactory' => '\OC\Share20\ProviderFactory',
|
'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,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue