From d4c0ac779034a47d4fc8a56e0a96a7d84170e03c Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 14 Nov 2013 09:38:55 +0100 Subject: introduce auto completion on share email - integrated with the contactsmanager api --- core/ajax/share.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'core/ajax/share.php') diff --git a/core/ajax/share.php b/core/ajax/share.php index be02c056357..6bac2867c48 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -261,6 +261,30 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares))); } break; + case 'getShareWithEmail': + $result = array(); + if (isset($_GET['search'])) { + $cm = OC::$server->getContactsManager(); + if (!is_null($cm) && $cm->isEnabled()) { + $contacts = $cm->search($_GET['search'], array('FN', 'EMAIL')); + foreach ($contacts as $contact) { + $emails = $contact['EMAIL']; + if (!is_array($emails)) { + $emails = array($emails); + } + + foreach($emails as $email) { + $result[] = array( + 'id' => $contact['ID'], + 'email' => $email, + 'displayname' => $contact['FN'], + ); + } + } + } + } + OC_JSON::success(array('data' => $result)); + break; case 'getShareWith': if (isset($_GET['search'])) { $sharePolicy = OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); -- cgit v1.2.3