mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Shorten request URI on selected export. Refs. #304
This commit is contained in:
parent
39a74188ea
commit
3cb61fc10c
13
js/app.js
13
js/app.js
@ -1069,7 +1069,18 @@ OC.Contacts = OC.Contacts || {
|
||||
var contacts = self.contacts.getSelectedContacts();
|
||||
// Only get backend, addressbookid and contactid
|
||||
contacts = $.map(contacts, function(c) {return c.metaData();});
|
||||
var url = OC.Router.generate('contacts_export_selected', {contacts:contacts});
|
||||
var targets = {};
|
||||
// Try to shorten request URI
|
||||
$.each(contacts, function(idx, contact) {
|
||||
if(!targets[contact.backend]) {
|
||||
targets[contact.backend] = {};
|
||||
}
|
||||
if(!targets[contact.backend][contact.addressBookId]) {
|
||||
targets[contact.backend][contact.addressBookId] = [];
|
||||
}
|
||||
targets[contact.backend][contact.addressBookId].push(contact.contactId);
|
||||
});
|
||||
var url = OC.Router.generate('contacts_export_selected', {t:targets});
|
||||
console.log('export url', url);
|
||||
document.location.href = url;
|
||||
});
|
||||
|
@ -78,20 +78,7 @@ class ExportController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function exportSelected() {
|
||||
$contacts = $this->request['contacts'];
|
||||
|
||||
// First sort the contacts by backend and address book.
|
||||
$targets = array();
|
||||
|
||||
foreach($contacts as $contact) {
|
||||
if(!isset($targets[$contact['backend']])) {
|
||||
$targets[$contact['backend']] = array();
|
||||
}
|
||||
if(!isset($targets[$contact['backend']][$contact['addressBookId']])) {
|
||||
$targets[$contact['backend']][$contact['addressBookId']] = array();
|
||||
}
|
||||
$targets[$contact['backend']][$contact['addressBookId']][] = $contact['contactId'];
|
||||
}
|
||||
$targets = $this->request['t'];
|
||||
|
||||
$exports = '';
|
||||
foreach($targets as $backend => $addressBooks) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user