From 0dbac3218130dfe418d6c7dc162f819c746bec2d Mon Sep 17 00:00:00 2001 From: thomascube Date: Thu, 4 Sep 2008 18:20:27 +0000 Subject: Enable export of contacts as vCard + DRY --- program/steps/addressbook/export.inc | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 program/steps/addressbook/export.inc (limited to 'program/steps/addressbook') 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 @@ + | + +-----------------------------------------------------------------------+ + + $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; + +?> -- cgit v1.2.3