summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/export.inc
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-01-18 18:00:57 +0000
committerthomascube <thomas@roundcube.net>2011-01-18 18:00:57 +0000
commit0501b637a3177cce441166b5fcfe27c9bd9fbe0f (patch)
tree5460128ef65d2510a7538c4a0e7336987e090ca1 /program/steps/addressbook/export.inc
parente81a30752b244394b03cbcaa0df254c93b379782 (diff)
Merge branch devel-addressbook (r4193:4382) back into trunk
Diffstat (limited to 'program/steps/addressbook/export.inc')
-rw-r--r--program/steps/addressbook/export.inc25
1 files changed, 18 insertions, 7 deletions
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
index 1b2e02944..509be596f 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -30,13 +30,24 @@ header('Content-Type: text/x-vcard; charset='.RCMAIL_CHARSET);
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();
+ // we already have a vcard record
+ if ($row['vcard']) {
+ echo $row['vcard'];
+ }
+ // copy values into vcard object
+ else {
+ $vcard = new rcube_vcard($row['vcard']);
+ $vcard->reset();
+ foreach ($row as $key => $values) {
+ list($field, $section) = explode(':', $key);
+ foreach ((array)$values as $value) {
+ if (is_array($value) || strlen($value))
+ $vcard->set($field, $value, strtoupper($section));
+ }
+ }
+
+ echo $vcard->export();
+ }
}
exit;