introduce auto completion on share email - integrated with the contactsmanager api
This commit is contained in:
parent
8d0d0836ba
commit
d4c0ac7790
|
@ -261,6 +261,30 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
||||||
OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares)));
|
OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares)));
|
||||||
}
|
}
|
||||||
break;
|
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':
|
case 'getShareWith':
|
||||||
if (isset($_GET['search'])) {
|
if (isset($_GET['search'])) {
|
||||||
$sharePolicy = OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
|
$sharePolicy = OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
|
||||||
|
|
|
@ -314,6 +314,26 @@ OC.Share={
|
||||||
.append( insert )
|
.append( insert )
|
||||||
.appendTo( ul );
|
.appendTo( ul );
|
||||||
};
|
};
|
||||||
|
$('#email').autocomplete({
|
||||||
|
minLength: 1,
|
||||||
|
source: function (search, response) {
|
||||||
|
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWithEmail', search: search.term }, function(result) {
|
||||||
|
if (result.status == 'success' && result.data.length > 0) {
|
||||||
|
response(result.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
select: function( event, item ) {
|
||||||
|
$('#email').val(item.item.email);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.data("ui-autocomplete")._renderItem = function( ul, item ) {
|
||||||
|
return $( "<li>" )
|
||||||
|
.append( "<a>" + item.displayname + "<br>" + item.email + "</a>" )
|
||||||
|
.appendTo( ul );
|
||||||
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Resharing is not allowed')+'" style="width:90%;" disabled="disabled"/>';
|
html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Resharing is not allowed')+'" style="width:90%;" disabled="disabled"/>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
Loading…
Reference in New Issue