source: subversion/branches/devel-addressbook/program/steps/addressbook/export.inc @ 4297

Last change on this file since 4297 was 4297, checked in by thomasb, 3 years ago

Render contact data groups as fieldsets w. legend; show vcard photos in UI (not yet editable)

File size: 1.8 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/export.inc                                  |
6 |                                                                       |
7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2008-2009, Roundcube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
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
23$CONTACTS->set_page(1);
24$CONTACTS->set_pagesize(99999);
25$result = $CONTACTS->list_records(null, 0, true);
26
27// send downlaod headers
28send_nocacheing_headers();
29header('Content-Type: text/x-vcard; charset='.RCMAIL_CHARSET);
30header('Content-Disposition: attachment; filename="rcube_contacts.vcf"');
31
32while ($result && ($row = $result->next())) {
33  // we already have a vcard record
34  if ($row['vcard']) {
35    echo $row['vcard'];
36  }
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    }
48   
49    echo $vcard->export();
50  }
51}
52
53exit;
54
Note: See TracBrowser for help on using the repository browser.