Permalink
Browse files

export only selected contacts from addressbook

  • Loading branch information...
1 parent e0a3288 commit b6df4dfdc90492d0c33264dcd6ccb03bca183c86 @JohnDoh JohnDoh committed Oct 7, 2012
Showing with 27 additions and 1 deletion.
  1. +4 −1 program/js/app.js
  2. +23 −0 program/steps/addressbook/export.inc
View
5 program/js/app.js 100644 → 100755
@@ -1066,7 +1066,10 @@ function rcube_webmail()
case 'export':
if (this.contact_list.rowcount > 0) {
- this.goto_url('export', { _source: this.env.source, _gid: this.env.group, _search: this.env.search_request });
+ if (this.contact_list.get_selection().length > 0)
+ this.goto_url('export', { _source: this.env.source, _gid: this.env.group, _cid: this.contact_list.get_selection().join(',') });
+ else
+ this.goto_url('export', { _source: this.env.source, _gid: this.env.group, _search: this.env.search_request });
}
break;
View
23 program/steps/addressbook/export.inc 100644 → 100755
@@ -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);

0 comments on commit b6df4df

Please sign in to comment.