export only selected contacts from addressbook #36

Closed
wants to merge 3 commits into
from
View
17 program/js/app.js 100644 → 100755
@@ -1064,12 +1064,19 @@ function rcube_webmail()
this.goto_url('import', (this.env.source ? '_target='+urlencode(this.env.source)+'&' : ''));
break;
- case 'export':
+ case 'export': // depreciated in 0.9
+ case 'export-all':
if (this.contact_list.rowcount > 0) {
this.goto_url('export', { _source: this.env.source, _gid: this.env.group, _search: this.env.search_request });
}
break;
+ case 'export-selected':
+ if (this.contact_list.rowcount > 0) {
+ this.goto_url('export', { _source: this.env.source, _gid: this.env.group, _cid: this.contact_list.get_selection().join(',') });
+ }
+ break;
+
case 'upload-photo':
this.upload_contact_photo(props || this.gui_objects.uploadform);
break;
@@ -4027,6 +4034,7 @@ function rcube_webmail()
// thend we can enable the group-remove-selected command
this.enable_command('group-remove-selected', this.env.group && list.selection.length > 0);
this.enable_command('compose', this.env.group || list.selection.length > 0);
+ this.enable_command('export-selected', list.selection.length > 0);
this.enable_command('edit', id && writable);
this.enable_command('delete', list.selection.length && writable);
@@ -4288,7 +4296,7 @@ function rcube_webmail()
list.insert_row(row);
- this.enable_command('export', list.rowcount > 0);
+ this.enable_command('export', 'export-all', list.rowcount > 0);
};
this.init_contact_form = function()
@@ -6117,7 +6125,8 @@ function rcube_webmail()
}
this.enable_command('compose', (uid && this.contact_list.rows[uid]));
this.enable_command('delete', 'edit', writable);
- this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0));
+ this.enable_command('export', 'export-all', (this.contact_list && this.contact_list.rowcount > 0));
+ this.enable_command('export-selected', false);
}
case 'moveto':
@@ -6163,7 +6172,7 @@ function rcube_webmail()
}
}
else if (this.task == 'addressbook') {
- this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0));
+ this.enable_command('export', 'export-all', (this.contact_list && this.contact_list.rowcount > 0));
if (response.action == 'list' || response.action == 'search') {
this.enable_command('search-create', this.env.source == '');
@@ -279,6 +279,8 @@ $labels['composeto'] = 'Compose mail to';
$labels['contactsfromto'] = 'Contacts $from to $to of $count';
$labels['print'] = 'Print';
$labels['export'] = 'Export';
+$labels['exportall'] = 'Export all';
+$labels['exportsel'] = 'Export selected';
$labels['exportvcards'] = 'Export contacts in vCard format';
$labels['newcontactgroup'] = 'Create new contact group';
$labels['grouprename'] = 'Rename group';
@@ -330,6 +330,8 @@ $labels['composeto'] = 'Compose mail to';
$labels['contactsfromto'] = 'Contacts $from to $to of $count';
$labels['print'] = 'Print';
$labels['export'] = 'Export';
+$labels['exportall'] = 'Export all';
+$labels['exportsel'] = 'Export selected';
$labels['exportvcards'] = 'Export contacts in vCard format';
$labels['newcontactgroup'] = 'Create new contact group';
$labels['grouprename'] = 'Rename group';
View
@@ -56,6 +56,29 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
$result = new rcube_result_set($count);
$result->records = array_values($records);
}
+// selected contacts
+elseif (!empty($_REQUEST['_cid'])) {
+ $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
+ $records = array();
+
+ $cids = explode(',', get_input_value('_cid', RCUBE_INPUT_GET));
+ $CONTACTS = rcmail_contact_source(null, true);
+
+ // Get records from all sources
+ foreach ($cids as $cid) {
+ $record = $CONTACTS->get_record($cid, true);
+ $key = rcmail_contact_key($record, $sort_col);
+ $records[$key] = $record;
+ unset($record);
+ }
+
+ ksort($records, SORT_LOCALE_STRING);
+
+ // create resultset object
+ $count = count($records);
+ $result = new rcube_result_set($count);
+ $result->records = array_values($records);
+}
// selected directory/group
else {
$CONTACTS = rcmail_contact_source(null, true);
@@ -67,6 +67,14 @@
background-position: -128px -32px;
}
+#abooktoolbar a.exportAll {
+ background-position: -128px 0;
+}
+
+#abooktoolbar a.exportAllSel {
+ background-position: -128px -32px;
+}
+
#abooktoolbar span.separator {
width: 5px;
background-position: -162px 0;
View
@@ -27,7 +27,10 @@
<roundcube:button command="delete" type="link" class="buttonPas delete" classAct="button delete" classSel="button deleteSel" title="deletecontact" content=" " />
<span class="separator">&nbsp;</span>
<roundcube:button command="import" type="link" class="buttonPas import" classAct="button import" classSel="button importSel" title="importcontacts" content=" " />
-<roundcube:button command="export" type="link" class="buttonPas export" classAct="button export" classSel="button exportSel" title="exportvcards" content=" " />
+<span class="dropbutton">
+<roundcube:button command="export-all" type="link" class="buttonPas exportAll" classAct="button exportAll" classSel="button exportAllSel" title="exportvcards" content=" " />
+<span id="exportallmenulink" onclick="rcmail_ui.show_popup('exportallmenu');return false"></span>
+</span>
<roundcube:button command="advanced-search" type="link" class="buttonPas search" classAct="button search" classSel="button searchSel" title="advsearch" content=" " />
<roundcube:container name="toolbar" id="abooktoolbar" />
</div>
@@ -38,6 +41,13 @@
<roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" width="13" height="13" />
</div>
+<div id="exportallmenu" class="popupmenu">
+ <ul>
+ <li><roundcube:button command="export-all" label="exportall" prop="sub" classAct="exportalllink active" class="exportalllink" /></li>
+ <li><roundcube:button command="export-selected" label="exportsel" prop="sub" classAct="exportsellink active" class="exportsellink" /></li>
+ </ul>
+</div>
+
<div id="searchmenu" class="popupmenu">
<ul class="toolbarmenu">
<li><input type="checkbox" name="s_mods[]" value="name" id="s_mod_name" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_name"><roundcube:label name="name" /></label></li>
@@ -1496,6 +1496,11 @@ ul.proplist li {
background-position: center -1054px;
}
+.toolbar a.button.export-all {
+ min-width: 64px;
+ background-position: left -1054px;
+}
+
a.menuselector {
display: inline-block;
border: 1px solid #ababab;
@@ -13,7 +13,11 @@
<!-- toolbar -->
<div id="addressbooktoolbar" class="toolbar">
<roundcube:button command="import" type="link" class="button import disabled" classAct="button import" classSel="button import pressed" label="import" title="importcontacts" />
- <roundcube:button command="export" type="link" class="button export disabled" classAct="button export" classSel="button export pressed" label="export" title="exportvcards" />
+ <span class="dropbutton">
+ <roundcube:button command="export-all" type="link" class="button export-all disabled" classAct="button export-all" classSel="button export-all pressed" label="exportall" title="exportvcards" />
+ <span class="dropbuttontip" id="exportallmenulink" onclick="UI.show_popup('exportallmenu');return false"></span>
+ </span>
+
<span class="spacer"></span>
<roundcube:button command="compose" type="link" class="button compose disabled" classAct="button compose" classSel="button compose pressed" label="compose" title="writenewmessage" />
<roundcube:button command="advanced-search" type="link" class="button search disabled" classAct="button search" classSel="button search pressed" label="advanced" title="advsearch" />
@@ -75,6 +79,12 @@ <h2 class="boxtitle"><roundcube:label name="contacts" /></h2>
</div><!-- end mainscreen -->
+<div id="exportallmenu" class="popupmenu">
+ <ul class="toolbarmenu">
+ <li><roundcube:button command="export-all" label="exportall" prop="sub" class="exportalllink" classAct="exportalllink active" /></li>
+ <li><roundcube:button command="export-selected" label="exportsel" prop="sub" class="exportsellink" classAct="exportsellink active" /></li>
+ </ul>
+</div>
<div id="searchmenu" class="popupmenu">
<ul class="toolbarmenu">