1
0
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:
Thomas Tanghus 2013-12-20 00:11:13 +01:00
parent 39a74188ea
commit 3cb61fc10c
2 changed files with 13 additions and 15 deletions

View File

@ -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;
});

View File

@ -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) {