summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/export.inc
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-09-04 18:20:27 +0000
committerthomascube <thomas@roundcube.net>2008-09-04 18:20:27 +0000
commit0dbac3218130dfe418d6c7dc162f819c746bec2d (patch)
tree12fe7f8ac96d3fcbff68d32f6e048374b474d9a2 /program/steps/addressbook/export.inc
parentd41f9762a7fa9e206a499bfa197435a578e36360 (diff)
Enable export of contacts as vCard + DRY
Diffstat (limited to 'program/steps/addressbook/export.inc')
-rw-r--r--program/steps/addressbook/export.inc43
1 files changed, 43 insertions, 0 deletions
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
new file mode 100644
index 000000000..bfffac1f8
--- /dev/null
+++ b/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;
+
+?>