summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-06-13 18:07:47 +0200
committerJoas Schilling <coding@schilljs.com>2017-06-13 18:07:47 +0200
commitae693129dbc69d5554c02711809ba292207f4bbc (patch)
treed84cbda87d9386f2361affed337da65fdf0bb526 /apps
parent72ccab0ab69ec9b23f90a0a908a9861c11323e94 (diff)
downloadnextcloud-server-ae693129dbc69d5554c02711809ba292207f4bbc.tar.gz
nextcloud-server-ae693129dbc69d5554c02711809ba292207f4bbc.zip
Allow to find local users by their email address
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php37
1 files changed, 30 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 7d345efb3eb..7766d762d3b 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -593,24 +593,47 @@ class ShareesAPIController extends OCSController {
* @return array
*/
protected function getEmail($search) {
- $result = ['results' => [], 'exact' => []];
+ $result = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
// Search in contacts
//@todo Pagination missing
$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN']);
- $result['exactIdMatch'] = false;
+ $lowerSearch = strtolower($search);
foreach ($addressBookContacts as $contact) {
- if (isset($contact['isLocalSystemBook'])) {
- continue;
- }
if (isset($contact['EMAIL'])) {
$emailAddresses = $contact['EMAIL'];
if (!is_array($emailAddresses)) {
$emailAddresses = [$emailAddresses];
}
foreach ($emailAddresses as $emailAddress) {
- if (strtolower($contact['FN']) === strtolower($search) || strtolower($emailAddress) === strtolower($search)) {
- if (strtolower($emailAddress) === strtolower($search)) {
+ $exactEmailMatch = strtolower($emailAddress) === $lowerSearch;
+ if ($exactEmailMatch || strtolower($contact['FN']) === $lowerSearch) {
+ if (isset($contact['isLocalSystemBook'])) {
+ if ($exactEmailMatch) {
+ $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
+ $this->result['exact']['users'][] = [
+ 'label' => $contact['FN'] . " ($emailAddress)",
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareWith' => $cloud->getUser(),
+ ],
+ ];
+ return ['results' => [], 'exact' => [], 'exactIdMatch' => true];
+ }
+ if ($this->shareeEnumeration) {
+ $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
+ $this->result['users'][] = [
+ 'label' => $contact['FN'] . " ($emailAddress)",
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareWith' => $cloud->getUser(),
+ ],
+ ];
+ }
+ continue;
+ }
+
+ if ($exactEmailMatch) {
$result['exactIdMatch'] = true;
}
$result['exact'][] = [