[Svn] r5159 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Mon Sep 5 09:28:32 CEST 2011


Author: thomasb
Date: 2011-09-05 02:28:32 -0500 (Mon, 05 Sep 2011)
New Revision: 5159

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_vcard.php
Log:
Fix vCard WORKFAX issue (#1488046)

Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2011-09-04 07:50:20 UTC (rev 5158)
+++ trunk/roundcubemail/CHANGELOG	2011-09-05 07:28:32 UTC (rev 5159)
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fixed vCard WORKFAX issue (#1488046)
 - Add vCard's Profile URL support (#1488062)
 - jQuery 1.6.3
 - Fix imap_cache setting to values other than 'db' (#1488060)

Modified: trunk/roundcubemail/program/include/rcube_vcard.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_vcard.php	2011-09-04 07:50:20 UTC (rev 5158)
+++ trunk/roundcubemail/program/include/rcube_vcard.php	2011-09-05 07:28:32 UTC (rev 5159)
@@ -50,8 +50,8 @@
     'spouse'      => 'X-SPOUSE',
     'edit'        => 'X-AB-EDIT',
   );
-  private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile');
-  private $phonetypemap = array('HOME1' => 'HOME', 'BUSINESS1' => 'WORK', 'BUSINESS2' => 'WORK2', 'BUSINESSFAX' => 'WORKFAX');
+  private $typemap = array('iPhone' => 'mobile', 'CELL' => 'mobile', 'WORK,FAX' => 'workfax');
+  private $phonetypemap = array('HOME1' => 'HOME', 'BUSINESS1' => 'WORK', 'BUSINESS2' => 'WORK2', 'BUSINESSFAX' => 'WORK,FAX', 'WORKFAX' => 'WORK,FAX');
   private $addresstypemap = array('BUSINESS' => 'WORK');
   private $immap = array('X-JABBER' => 'jabber', 'X-ICQ' => 'icq', 'X-MSN' => 'msn', 'X-AIM' => 'aim', 'X-YAHOO' => 'yahoo', 'X-SKYPE' => 'skype', 'X-SKYPE-USERNAME' => 'skype');
 
@@ -158,7 +158,8 @@
           $subtype = '';
 
           if (!empty($raw['type'])) {
-            $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]);
+            $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true));
+            $subtype = $typemap[$combined] ? $typemap[$combined] : ($typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]));
             while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref'))
               $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]);
           }
@@ -334,7 +335,7 @@
           $index = count($this->raw[$tag]);
           $this->raw[$tag][$index] = (array)$value;
           if ($type)
-            $this->raw[$tag][$index]['type'] = array(($typemap[$type] ? $typemap[$type] : $type));
+            $this->raw[$tag][$index]['type'] = explode(',', ($typemap[$type] ? $typemap[$type] : $type));
         }
         break;
     }
@@ -711,7 +712,28 @@
     return true;
   }
 
+  /**
+   * Extract array values by a filter
+   *
+   * @param array Array to filter
+   * @param keys Array or comma separated list of values to keep
+   * @param boolean Invert key selection: remove the listed values
+   * @return array The filtered array
+   */
+  private static function array_filter($arr, $values, $inverse = false)
+  {
+    if (!is_array($values))
+      $values = explode(',', $values);
 
+    $result = array();
+    $keep = array_flip((array)$values);
+    foreach ($arr as $key => $val)
+      if ($inverse != isset($keep[strtolower($val)]))
+        $result[$key] = $val;
+
+    return $result;
+  }
+
   /**
    * Returns UNICODE type based on BOM (Byte Order Mark)
    *

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list