summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-26 11:45:11 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-26 11:54:25 +0200
commit199d1dc239a55f9be25b8779122420537f34ecf8 (patch)
treeb932894a165f833390e0e49031a6d426d2ca0551 /apps/files_sharing/api
parent2a6e676048f1f8e521e5b6c189e71e02bb2e5005 (diff)
downloadnextcloud-server-199d1dc239a55f9be25b8779122420537f34ecf8.tar.gz
nextcloud-server-199d1dc239a55f9be25b8779122420537f34ecf8.zip
Bring the coverage back to 100%
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/sharees.php38
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php
index 807b6b3314f..d7eabb9a550 100644
--- a/apps/files_sharing/api/sharees.php
+++ b/apps/files_sharing/api/sharees.php
@@ -139,8 +139,8 @@ class Sharees {
$foundUserById = false;
foreach ($users as $uid => $userDisplayName) {
- if ($uid === $search || $userDisplayName === $search) {
- if ($uid === $search) {
+ if (strtolower($uid) === $search || strtolower($userDisplayName) === $search) {
+ if (strtolower($uid) === $search) {
$foundUserById = true;
}
$this->result['exact']['users'][] = [
@@ -199,7 +199,7 @@ class Sharees {
}
foreach ($groups as $gid) {
- if ($gid === $search) {
+ if (strtolower($gid) === $search) {
$this->result['exact']['groups'][] = [
'label' => $search,
'value' => [
@@ -222,8 +222,8 @@ class Sharees {
// On page one we try if the search result has a direct hit on the
// user id and if so, we add that to the exact match list
$group = $this->groupManager->get($search);
- if ($group instanceof IGroup && (!$this->shareWithGroupOnly || array_intersect([$group], $userGroups))) {
- array_push($this->result['exact']['users'], [
+ if ($group instanceof IGroup && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
+ array_push($this->result['exact']['groups'], [
'label' => $group->getGID(),
'value' => [
'shareType' => Share::SHARE_TYPE_GROUP,
@@ -241,23 +241,17 @@ class Sharees {
protected function getRemote($search) {
$this->result['remotes'] = [];
- if (substr_count($search, '@') >= 1 && $this->offset === 0) {
- $this->result['exact']['remotes'][] = [
- 'label' => $search,
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
- 'shareWith' => $search,
- ],
- ];
- }
-
// Search in contacts
//@todo Pagination missing
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
+ $foundRemoteById = false;
foreach ($addressBookContacts as $contact) {
if (isset($contact['CLOUD'])) {
foreach ($contact['CLOUD'] as $cloudId) {
- if ($contact['FN'] === $search || $cloudId === $search) {
+ if (strtolower($contact['FN']) === $search || strtolower($cloudId) === $search) {
+ if (strtolower($cloudId) === $search) {
+ $foundRemoteById = true;
+ }
$this->result['exact']['remotes'][] = [
'label' => $contact['FN'],
'value' => [
@@ -278,6 +272,16 @@ class Sharees {
}
}
+ if (!$foundRemoteById && substr_count($search, '@') >= 1 && substr_count($search, ' ') === 0 && $this->offset === 0) {
+ $this->result['exact']['remotes'][] = [
+ 'label' => $search,
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareWith' => $search,
+ ],
+ ];
+ }
+
$this->reachedEndFor[] = 'remotes';
}
@@ -313,7 +317,7 @@ class Sharees {
$this->limit = (int) $perPage;
$this->offset = $perPage * ($page - 1);
- return $this->searchSharees($search, $itemType, $shareTypes, $page, $perPage);
+ return $this->searchSharees(strtolower($search), $itemType, $shareTypes, $page, $perPage);
}
/**