no extra charset attributes in iCal for GroupDAV/CalDAV

This commit is contained in:
Ralf Becker 2008-06-07 18:00:29 +00:00
parent 25b1924665
commit c618dad433
2 changed files with 7 additions and 6 deletions

View File

@ -119,9 +119,9 @@ class addressbook_groupdav extends groupdav_handler
); );
if ($address_data) if ($address_data)
{ {
$content = $handler->getVCard($contact,$this->charset); $content = $handler->getVCard($contact,$this->charset,false);
$props[] = HTTP_WebDAV_Server::mkprop('getcontentlength',bytes($content)); $props[] = HTTP_WebDAV_Server::mkprop('getcontentlength',bytes($content));
$props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$content=$handler->getVCard($contact,$this->charset)); $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$content);
} }
else else
{ {

View File

@ -57,9 +57,10 @@ class addressbook_vcal extends addressbook_bo
* *
* @param int/string $_id the id of the contact * @param int/string $_id the id of the contact
* @param string $_charset='utf-8' encoding of the vcard, default utf-8 * @param string $_charset='utf-8' encoding of the vcard, default utf-8
* @param boolean $extra_charset_attribute=true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
* @return string containing the vcard * @return string containing the vcard
*/ */
function getVCard($_id,$_charset='utf-8') function getVCard($_id,$_charset='utf-8',$extra_charset_attribute=true)
{ {
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar/vcard.php'); require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar/vcard.php');
@ -123,11 +124,11 @@ class addressbook_vcal extends addressbook_bo
} }
// fall-through to the normal processing of string values // fall-through to the normal processing of string values
default: default:
if(!empty($value)) if(!empty($value) || in_array($vcardField,array('FN','ORG','N')))
{ {
$value = $GLOBALS['egw']->translation->convert(trim($value), $sysCharSet,$_charset); $value = $GLOBALS['egw']->translation->convert(trim($value), $sysCharSet,$_charset);
if(preg_match('/([\177-\377])/',$valueData)) if(($extra_charset_attribute || $this->productManufacturer == 'kde') && preg_match('/([\177-\377])/',$valueData))
{ {
$options['CHARSET'] = $_charset; $options['CHARSET'] = $_charset;
// KAddressbook requires non-ascii chars to be qprint encoded, other clients eg. nokia phones have trouble with that // KAddressbook requires non-ascii chars to be qprint encoded, other clients eg. nokia phones have trouble with that
@ -153,7 +154,7 @@ class addressbook_vcal extends addressbook_bo
$values[] = $value; $values[] = $value;
} }
if ($hasdata <= 0 && !in_array($vcardField,array('FN','ORG','N'))) if ($hasdata <= 0)
{ {
// don't add the entry if there is no data for this field, // don't add the entry if there is no data for this field,
// except it's a mendatory field // except it's a mendatory field