summaryrefslogtreecommitdiff
path: root/roundcubemail/program/steps/addressbook
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-09-04 18:20:27 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-09-04 18:20:27 +0000
commit46de7563c2bf659895ae1c6680e73dba49e2158c (patch)
treeefefc61a4d92ca127cd228196444d50df058c17d /roundcubemail/program/steps/addressbook
parentc371f5c8d312284a8722aed04119b7f50c4928d5 (diff)
Enable export of contacts as vCard + DRY
git-svn-id: https://svn.roundcube.net/trunk@1732 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/steps/addressbook')
-rw-r--r--roundcubemail/program/steps/addressbook/export.inc43
1 files changed, 43 insertions, 0 deletions
diff --git a/roundcubemail/program/steps/addressbook/export.inc b/roundcubemail/program/steps/addressbook/export.inc
new file mode 100644
index 000000000..bfffac1f8
--- /dev/null
+++ b/roundcubemail/program/steps/addressbook/export.inc
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/addressbook/export.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Export the selected address book as vCard file |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+// get contacts for this user
+$CONTACTS->set_pagesize(999);
+$result = $CONTACTS->list_records();
+
+// send downlaod headers
+send_nocacheing_headers();
+header('Content-Type: text/x-vcard; charset=UTF-8');
+header('Content-Disposition: attachment; filename="rcube_contacts.vcf"');
+
+while ($result && ($row = $result->next())) {
+ $vcard = new rcube_vcard($row['vcard']);
+ $vcard->set('displayname', $row['name']);
+ $vcard->set('firstname', $row['firstname']);
+ $vcard->set('surname', $row['surname']);
+ $vcard->set('email', $row['email']);
+
+ echo $vcard->export();
+}
+
+exit;
+
+?>