Aleksander Machniak
2013-01-07 acf851f823fba5354c2227e48c3097a524312268
Fix address fields import from CSV (#1488900)
3 files modified
12 ■■■■■ changed files
program/lib/Roundcube/rcube_csv2vcard.php 9 ●●●●● patch | view | raw | blame | history
tests/Framework/Csv2vcard.php 1 ●●●● patch | view | raw | blame | history
tests/src/Csv2vcard/tb_plain.vcf 2 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_csv2vcard.php
@@ -390,6 +390,15 @@
            }
        }
        // Convert address(es) to rcube_vcard data
        foreach ($contact as $idx => $value) {
            $name = explode(':', $idx);
            if (in_array($name[0], array('street', 'locality', 'region', 'zipcode', 'country'))) {
                $contact['address:'.$name[1]][$name[0]] = $value;
                unset($contact[$idx]);
            }
        }
        // Create vcard object
        $vcard = new rcube_vcard();
        foreach ($contact as $name => $value) {
tests/Framework/Csv2vcard.php
@@ -31,6 +31,7 @@
        $vcf_text = trim(str_replace("\r\n", "\n", $vcf_text));
        $vcard    = trim(str_replace("\r\n", "\n", $vcard));
echo $vcard;
        $this->assertEquals($vcf_text, $vcard);
    }
tests/src/Csv2vcard/tb_plain.vcf
@@ -15,4 +15,6 @@
URL;TYPE=homepage:http://page.com
URL;TYPE=other:http://webpage.tld
BDAY;VALUE=date:1970-11-15
ADR;TYPE=home:;;Priv address;City;region;xx-xxx;USA
ADR;TYPE=work:;;Addr work;;;33-333;Poland
END:VCARD