Aleksander Machniak
2014-11-26 25fb9732a008d4fb35e4afdefea552f36835fa43
Fix so all unknown email addresses from Google csv format are imported (#1490159)
4 files modified
29 ■■■■ changed files
INSTALL 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_csv2vcard.php 25 ●●●● patch | view | raw | blame | history
tests/src/Csv2vcard/gmail.csv patch | view | raw | blame | history
tests/src/Csv2vcard/gmail.vcf 2 ●●●●● patch | view | raw | blame | history
INSTALL
@@ -12,7 +12,7 @@
* The Apache, Lighttpd, Cherokee or Hiawatha web server
* .htaccess support allowing overrides for DirectoryIndex
* PHP Version 5.3.7 or greater including
   - PCRE, DOM, JSON, XML, Session, Sockets (required)
   - PCRE, DOM, JSON, Session, Sockets (required)
   - PHP Data Objects (PDO) with driver for either MySQL, PostgreSQL or SQLite (required)
   - Libiconv, Zip (recommended)
   - OpenSSL, Fileinfo, Mcrypt, mbstring (optional)
program/lib/Roundcube/rcube_csv2vcard.php
@@ -302,6 +302,7 @@
            'Value' => array(
                'home' => 'email:home',
                'work' => 'email:work',
                '*'    => 'email:other',
            ),
        ),
        'Phone' => array(
@@ -567,8 +568,19 @@
            foreach ($item as $item_key => $item_idx) {
                $value = $data[$item_idx];
                if ($value !== null && $value !== '' && ($data_idx = $this->gmail_label_map[$key][$item_key][$type])) {
                    $contact[$data_idx] = $value;
                if ($value !== null && $value !== '') {
                    foreach (array($type, '*') as $_type) {
                        if ($data_idx = $this->gmail_label_map[$key][$item_key][$_type]) {
                            if (!empty($contact[$data_idx])) {
                                $contact[$data_idx]   = (array) $contact[$data_idx];
                                $contact[$data_idx][] = $value;
                            }
                            else {
                                $contact[$data_idx] = $value;
                            }
                            break;
                        }
                    }
                }
            }
        }
@@ -624,7 +636,14 @@
        $vcard = new rcube_vcard();
        foreach ($contact as $name => $value) {
            $name = explode(':', $name);
            $vcard->set($name[0], $value, $name[1]);
            if (is_array($value) && $name[0] != 'address') {
                foreach ((array) $value as $val) {
                    $vcard->set($name[0], $val, $name[1]);
                }
            }
            else {
                $vcard->set($name[0], $value, $name[1]);
            }
        }
        // add to the list
tests/src/Csv2vcard/gmail.csv
Binary files differ
tests/src/Csv2vcard/gmail.vcf
@@ -8,6 +8,8 @@
CATEGORIES:My Contacts,Test
EMAIL;TYPE=INTERNET;TYPE=HOME:home@aaa.pl
EMAIL;TYPE=INTERNET;TYPE=WORK:work@email.pl
EMAIL;TYPE=INTERNET;TYPE=OTHER:unknown@email.com
EMAIL;TYPE=INTERNET;TYPE=OTHER:other@email.com
TEL;TYPE=pager:pager
TEL;TYPE=pref:mainphone
TEL;TYPE=home:homephone