Aleksander Machniak
2015-02-16 ae73c26f29aa230ba5ae3d86ef6d0c7886b7e657
program/steps/addressbook/export.inc
@@ -103,7 +103,9 @@
header('Content-Disposition: attachment; filename="contacts.vcf"');
while ($result && ($row = $result->next())) {
    prepare_for_export($row, $CONTACTS);
    if ($CONTACTS) {
        prepare_for_export($row, $CONTACTS);
    }
    // fix folding and end-of-line chars
    $row['vcard'] = preg_replace('/\r|\n\s+/', '', $row['vcard']);
@@ -131,8 +133,14 @@
        foreach ($record as $key => $values) {
            list($field, $section) = explode(':', $key);
            foreach ((array)$values as $value) {
                if (is_array($value) || @strlen($value)) {
            // avoid unwanted casting of DateTime objects to an array
            // (same as in rcube_contacts::convert_save_data())
            if (is_object($values) && is_a($values, 'DateTime')) {
                $values = array($values);
            }
            foreach ((array) $values as $value) {
                if (is_array($value) || is_a($value, 'DateTime') || @strlen($value)) {
                    $vcard->set($field, $value, strtoupper($section));
                }
            }