From 5983ee0f183d8d8b13cb757aff16402fa71420fd Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 07 Nov 2013 14:12:16 -0500
Subject: [PATCH] Fix categories/groups import from csv

---
 program/lib/Roundcube/rcube_vcard.php     |    2 +-
 program/lib/Roundcube/rcube_csv2vcard.php |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php
index 00e6d4e..aa385dc 100644
--- a/program/lib/Roundcube/rcube_csv2vcard.php
+++ b/program/lib/Roundcube/rcube_csv2vcard.php
@@ -47,7 +47,7 @@
         //'business_street_2'     => '',
         //'business_street_3'     => '',
         'car_phone'             => 'phone:car',
-        'categories'            => 'categories',
+        'categories'            => 'groups',
         //'children'              => '',
         'company'               => 'organization',
         //'company_main_phone'    => '',
@@ -146,6 +146,9 @@
         'work_title'            => 'jobtitle',
         'work_zip'              => 'zipcode:work',
         'group'                 => 'groups',
+
+        // GMail
+        'groups'                => 'groups',
     );
 
     /**
@@ -427,6 +430,11 @@
             $contact['birthday'] = $contact['birthday-y'] .'-' .$contact['birthday-m'] . '-' . $contact['birthday-d'];
         }
 
+        // categories/groups separator in vCard is ',' not ';'
+        if (!empty($contact['groups'])) {
+            $contact['groups'] = str_replace(';', ',', $contact['groups']);
+        }
+
         // Empty dates, e.g. "0/0/00", "0000-00-00 00:00:00"
         foreach (array('birthday', 'anniversary') as $key) {
             if (!empty($contact[$key])) {
diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php
index 5f74ccb..a54ee7e 100644
--- a/program/lib/Roundcube/rcube_vcard.php
+++ b/program/lib/Roundcube/rcube_vcard.php
@@ -378,7 +378,7 @@
         default:
             if ($field == 'phone' && $this->phonetypemap[$type_uc]) {
                 $type = $this->phonetypemap[$type_uc];
-             }
+            }
 
             if (($tag = self::$fieldmap[$field]) && (is_array($value) || strlen($value))) {
                 $index = count($this->raw[$tag]);

--
Gitblit v1.9.1