Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Email autocomplete for link shares without local users #30998

Merged
merged 6 commits into from Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/dav/lib/CardDAV/AddressBookImpl.php
Expand Up @@ -241,9 +241,13 @@ protected function vCard2Array($uri, VCard $vCard) {
$result[$property->name] = $property->getValue();
}
}
if ($this->addressBookInfo['principaluri'] === 'principals/system/system' &&
$this->addressBookInfo['uri'] === 'system') {
$result['isLocalSystemBook'] = true;
if ($this->addressBookInfo['principaluri'] === 'principals/system/system' ) {
$result['isSystemBook'] = true;
if ($this->addressBookInfo['uri'] === 'system') {
$result['isLocalSystemBook'] = true;
} else {
$result['isFederatedSystemBook'] = true;
}
}
return $result;
}
Expand Down
19 changes: 15 additions & 4 deletions core/ajax/share.php
Expand Up @@ -307,12 +307,23 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
if (isset($_GET['search'])) {
$cm = OC::$server->getContactsManager();

$userEnumerationAllowed = OC::$server->getConfig()
->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') == 'yes';
$config = OC::$server->getConfig();
$userEnumerationAllowed = $config
->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$pattern = (string)$_GET['search'];
$searchConfig = new \OCP\Util\UserSearch($config);
if (!$searchConfig->isSearchable($pattern)) {
OC_JSON::error();
return;
}

if (!is_null($cm) && $cm->isEnabled() && $userEnumerationAllowed) {
$contacts = $cm->search((string)$_GET['search'], ['FN', 'EMAIL']);
if ($cm !== null && $cm->isEnabled() && $userEnumerationAllowed) {
$contacts = $cm->search($pattern, ['FN', 'EMAIL']);
foreach ($contacts as $contact) {
// We don't want contacts from system address books
if (isset($contact['isSystemBook'])) {
continue;
}
if (!isset($contact['EMAIL'])) {
continue;
}
Expand Down
36 changes: 29 additions & 7 deletions core/js/sharedialogmailview.js
Expand Up @@ -186,15 +186,37 @@
containerCssClass: 'emailPrivateLinkForm--dropDown',
tags: true,
tokenSeparators:[","],
xhr: null,
query: function(query) {
// directly from search
query.callback({
results: [{
"id" : query.term,
"text" : query.term,
"disabled" : !_this.validateEmail(query.term)
}]
});
var data = [{
"id": query.term,
"text" : query.term
}];

// return query data ASAP
query.callback({results: data});

if (query.term.length >= OC.getCapabilities().files_sharing.search_min_length) {
if (this.xhr != null)
this.xhr.abort();

var xhr = $.get(OC.generateUrl('core/ajax/share.php'), {
'fetch' : 'getShareWithEmail',
'search': query.term
}).done(function(result) {
// enrich with share results
ajaxData = _.map(result.data, function(item) {
return {
'id' : item.email,
'text' : item.displayname + ' (' + item.email + ')'
}
});

query.callback({results: data.concat(ajaxData)});
})
this.xhr = xhr;
}
}
}).on("change", function(e) {
if (e.added)
Expand Down