summaryrefslogtreecommitdiff
path: root/roundcubemail/program/steps/addressbook/export.inc
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-18 18:00:57 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-18 18:00:57 +0000
commit2a39de413ca7023350a338087976e0481a319d9a (patch)
tree9859e4e615a2663526d85a635edabbdb413557ea /roundcubemail/program/steps/addressbook/export.inc
parentfd40ada993897de4b4779e1847dbaf29339fa087 (diff)
Merge branch devel-addressbook (r4193:4382) back into trunk
git-svn-id: https://svn.roundcube.net/trunk@4424 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/steps/addressbook/export.inc')
-rw-r--r--roundcubemail/program/steps/addressbook/export.inc25
1 files changed, 18 insertions, 7 deletions
diff --git a/roundcubemail/program/steps/addressbook/export.inc b/roundcubemail/program/steps/addressbook/export.inc
index 1b2e02944..509be596f 100644
--- a/roundcubemail/program/steps/addressbook/export.inc
+++ b/roundcubemail/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;