summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-09-05 07:28:32 +0000
committerthomascube <thomas@roundcube.net>2011-09-05 07:28:32 +0000
commit31e00cb7e94188b5d8f4c1d9a113b13be9dc91a7 (patch)
tree5d53935d30d55936012fadb6ae9c6fd0977b24da
parentdbb0c2a10988690cf86c1fe17f7927b67bdc38b3 (diff)
Fix vCard WORKFAX issue (#1488046)
-rw-r--r--CHANGELOG1
-rw-r--r--program/include/rcube_vcard.php30
2 files changed, 27 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 26a67ce80..da20a2d1d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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)
diff --git a/program/include/rcube_vcard.php b/program/include/rcube_vcard.php
index c7dfe537b..ec3ad9c87 100644
--- a/program/include/rcube_vcard.php
+++ b/program/include/rcube_vcard.php
@@ -50,8 +50,8 @@ class rcube_vcard
'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 @@ class rcube_vcard
$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 @@ class rcube_vcard
$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,6 +712,27 @@ class rcube_vcard
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)