thomascube
2011-01-18 0501b637a3177cce441166b5fcfe27c9bd9fbe0f
program/steps/addressbook/export.inc
@@ -30,13 +30,24 @@
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;