summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-07-29 15:37:08 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2016-11-01 19:51:11 +0100
commit0a6f02801f333c17ca6455906bc816020883477d (patch)
tree790140cc6dd30d7ef9db50b281fca4769097119b /apps
parentef467c3195731cb1e4fff504b39c06b017deb5ec (diff)
downloadnextcloud-server-0a6f02801f333c17ca6455906bc816020883477d.tar.gz
nextcloud-server-0a6f02801f333c17ca6455906bc816020883477d.zip
introduce share by mail, ui part
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php90
1 files changed, 23 insertions, 67 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 99c6b55240d..d5d877f4673 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -405,68 +405,6 @@ class ShareesAPIController extends OCSController {
}
/**
- * @param string $search
- */
- protected function getEmails($search) {
- $this->result['emails'] = [];
- $this->result['exact']['emails'] = [];
-
- $foundEmail = false;
-
- // Search in contacts
- //@todo Pagination missing
- $addressBookContacts = $this->contactsManager->search($search, ['FN', 'EMAIL']);
- foreach ($addressBookContacts as $contact) {
- if (!isset($contact['EMAIL'])) {
- continue;
- }
-
- $emails = $contact['EMAIL'];
- if (!is_array($emails)) {
- $emails = [$emails];
- }
-
- foreach ($emails as $email) {
- if (strtolower($search) === strtolower($contact['FN']) ||
- strtolower($search) === strtolower($email)
- ) {
- if (strtolower($search) === strtolower($email)) {
- $foundEmail = true;
- }
-
- $this->result['exact']['emails'][] = [
- 'label' => $contact['FN'],
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $email,
- ],
- ];
- } else if ($this->shareeEnumeration) {
- $this->result['emails'][] = [
- 'label' => $contact['FN'],
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $email,
- ],
- ];
- }
- }
- }
-
- if (!$foundEmail && substr_count($search, '@') >= 1 && $this->offset === 0) {
- $this->result['exact']['emails'][] = [
- 'label' => $search,
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
- 'shareWith' => $search,
- ],
- ];
- }
-
- $this->reachedEndFor[] = 'emails';
- }
-
- /**
* @NoAdminRequired
*
* @param string $search
@@ -487,17 +425,16 @@ class ShareesAPIController extends OCSController {
$shareTypes = [
Share::SHARE_TYPE_USER,
+ Share::SHARE_TYPE_EMAIL,
+ Share::SHARE_TYPE_REMOTE
];
if ($this->shareManager->allowGroupSharing()) {
$shareTypes[] = Share::SHARE_TYPE_GROUP;
}
- $shareTypes[] = Share::SHARE_TYPE_EMAIL;
- $shareTypes[] = Share::SHARE_TYPE_REMOTE;
-
- if (is_array($shareType)) {
- $shareTypes = array_intersect($shareTypes, $shareType);
+ if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
+ $shareTypes = array_intersect($shareTypes, $_GET['shareType']);
sort($shareTypes);
} else if (is_numeric($shareType)) {
$shareTypes = array_intersect($shareTypes, [(int) $shareType]);
@@ -584,6 +521,25 @@ class ShareesAPIController extends OCSController {
}
/**
+ * add option to send share by mail
+ *
+ * @param string $search
+ */
+ protected function getEmail($search) {
+ $this->result['emails'] = [];
+
+ if (substr_count($search, '@') >= 1 && substr_count($search, ' ') === 0 && $this->offset === 0) {
+ $this->result['exact']['emails'][] = [
+ 'label' => $search,
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareWith' => $search,
+ ],
+ ];
+ }
+ }
+
+ /**
* Generates a bunch of pagination links for the current page
*
* @param int $page Current page