| | |
| | | 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']); |
| | |
| | | |
| | | 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)); |
| | | } |
| | | } |