commit | author | age
|
0dbac3
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/addressbook/export.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
f5e7b3
|
8 |
| Copyright (C) 2008-2009, The Roundcube Dev Team | |
0dbac3
|
9 |
| Licensed under the GNU GPL | |
T |
10 |
| | |
|
11 |
| PURPOSE: | |
|
12 |
| Export the selected address book as vCard file | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id: $ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
// get contacts for this user |
48c0d4
|
23 |
$CONTACTS->set_page(1); |
40d43b
|
24 |
$CONTACTS->set_pagesize(99999); |
A |
25 |
$result = $CONTACTS->list_records(null, 0, true); |
0dbac3
|
26 |
|
T |
27 |
// send downlaod headers |
|
28 |
send_nocacheing_headers(); |
ecb9fb
|
29 |
header('Content-Type: text/x-vcard; charset='.RCMAIL_CHARSET); |
0dbac3
|
30 |
header('Content-Disposition: attachment; filename="rcube_contacts.vcf"'); |
T |
31 |
|
|
32 |
while ($result && ($row = $result->next())) { |
0501b6
|
33 |
// we already have a vcard record |
T |
34 |
if ($row['vcard']) { |
569f83
|
35 |
echo rcube_vcard::rfc2425_fold($row['vcard']) . "\n"; |
0501b6
|
36 |
} |
T |
37 |
// copy values into vcard object |
|
38 |
else { |
|
39 |
$vcard = new rcube_vcard($row['vcard']); |
|
40 |
$vcard->reset(); |
|
41 |
foreach ($row as $key => $values) { |
|
42 |
list($field, $section) = explode(':', $key); |
|
43 |
foreach ((array)$values as $value) { |
|
44 |
if (is_array($value) || strlen($value)) |
|
45 |
$vcard->set($field, $value, strtoupper($section)); |
|
46 |
} |
|
47 |
} |
cbf891
|
48 |
|
569f83
|
49 |
echo $vcard->export(true) . "\n"; |
0501b6
|
50 |
} |
0dbac3
|
51 |
} |
T |
52 |
|
|
53 |
exit; |
|
54 |
|