From 69288160ae7d5978acc106cc7acd829701a38c13 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 2 Nov 2011 13:41:41 +0000 Subject: [PATCH] fixed not working proxy display in iCal, if resource-name contains a german umlaut: names get now transliterated to ascii (they are unique anyway, as prefixed by resource-id) --- .../inc/class.groupdav_principals.inc.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.groupdav_principals.inc.php b/phpgwapi/inc/class.groupdav_principals.inc.php index f4a8813a7b..d7cf315794 100644 --- a/phpgwapi/inc/class.groupdav_principals.inc.php +++ b/phpgwapi/inc/class.groupdav_principals.inc.php @@ -991,9 +991,31 @@ class groupdav_principals extends groupdav_handler $displayname = translation::convert($resource['name'], translation::charset(), 'utf-8'); - return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'.str_replace(array(' ','/',':','#','?'),'-',$displayname); + return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'. + preg_replace('/[^a-z0-9]+/i','-', self::to_ascii($resource['name'])); } + /** + * Transliterate utf-8 filename to ascii, eg. 'Äpfel' --> 'Aepfel' + * + * @param string $str + * @return string + */ + protected function to_ascii($str) + { + static $extra = array( + 'ß' => 'ss', + ); + $str = htmlentities($str,ENT_QUOTES,translation::charset()); + $str = str_replace(array_keys($extra),array_values($extra),$str); + $str = preg_replace('/&([aAuUoO])uml;/','\\1e',$str); // replace german umlauts with the letter plus one 'e' + $str = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1',$str); // remove all types of acents + $str = preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','',$str); // remove all other entities + + return $str; + } + + /** * Check if resource is a location *