Skip to content

Commit

Permalink
Implement the autocomplete blocker from #18341 into the OCS endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Aug 17, 2015
1 parent 9f85d1e commit 36aedee
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 12 deletions.
29 changes: 29 additions & 0 deletions apps/files_sharing/api/sharees.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ protected function getUsers($search, $shareWithGroupOnly) {
continue;
}

if ($this->filterAutocompletion($search, $uid, $displayName)) {
// Do not allow autocompletion if disabled
continue;
}

$sharees[] = [
'label' => $displayName,
'value' => [
Expand Down Expand Up @@ -152,6 +157,11 @@ protected function getGroups($search, $shareWithGroupOnly) {
}

foreach ($groups as $gid) {
if ($this->filterAutocompletion($search, $gid, $gid)) {
// Do not allow autocompletion if disabled
continue;
}

$sharees[] = [
'label' => $gid,
'value' => [
Expand Down Expand Up @@ -187,6 +197,11 @@ protected function getRemote($search) {
foreach ($addressBookContacts as $contact) {
if (isset($contact['CLOUD'])) {
foreach ($contact['CLOUD'] as $cloudId) {
if ($this->filterAutocompletion($search, $cloudId, $contact['FN'])) {
// Do not allow autocompletion if disabled
continue;
}

$sharees[] = [
'label' => $contact['FN'] . ' (' . $cloudId . ')',
'value' => [
Expand All @@ -201,6 +216,20 @@ protected function getRemote($search) {
return $sharees;
}

/**
* @param string $search
* @param string $sharee
* @param string $label
* @return bool True if the entry is an autocomplete hint, false otherwise
*/
protected function filterAutocompletion($search, $sharee, $label) {
if ($this->config->getSystemValue('webui-sharing-autocompletion.enabled', true)) {
return false;
}

return $search !== $sharee && $search !== $label;
}

/**
* @return \OC_OCS_Result
*/
Expand Down
Loading

0 comments on commit 36aedee

Please sign in to comment.