Improve Mac OS Addressbook.App CardDAV support as far as reasonable

This commit is contained in:
Jörg Lehrke 2010-09-25 15:19:48 +00:00
parent ed733eef42
commit 40d786871e
2 changed files with 48 additions and 14 deletions

View File

@ -33,6 +33,42 @@ class addressbook_groupdav extends groupdav_handler
'FN' => 'n_fn', 'FN' => 'n_fn',
); );
var $supportedFields = array(
'ADR;WORK' => array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region',
'adr_one_postalcode','adr_one_countryname'),
'ADR;HOME' => array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region',
'adr_two_postalcode','adr_two_countryname'),
'BDAY' => array('bday'),
//'CLASS' => array('private'),
//'CATEGORIES' => array('cat_id'),
'EMAIL;WORK' => array('email'),
'EMAIL;HOME' => array('email_home'),
'N' => array('n_family','n_given','n_middle',
'n_prefix','n_suffix'),
'FN' => array('n_fn'),
'NOTE' => array('note'),
'ORG' => array('org_name','org_unit','room'),
'TEL;CELL;WORK' => array('tel_cell'),
'TEL;CELL;HOME' => array('tel_cell_private'),
'TEL;CAR' => array('tel_car'),
'TEL;OTHER' => array('tel_other'),
'TEL;VOICE;WORK' => array('tel_work'),
'TEL;FAX;WORK' => array('tel_fax'),
'TEL;HOME;VOICE' => array('tel_home'),
'TEL;FAX;HOME' => array('tel_fax_home'),
'TEL;PAGER' => array('tel_pager'),
'TITLE' => array('title'),
'URL;WORK' => array('url'),
'URL;HOME' => array('url_home'),
'ROLE' => array('role'),
'NICKNAME' => array('label'),
'FBURL' => array('freebusy_uri'),
'PHOTO' => array('jpegphoto'),
'X-ASSISTANT' => array('assistent'),
'X-ASSISTANT-TEL' => array('tel_assistent'),
'UID' => array('uid'),
);
/** /**
* Charset for exporting data, as some clients ignore the headers specifying the charset * Charset for exporting data, as some clients ignore the headers specifying the charset
* *
@ -277,6 +313,11 @@ class addressbook_groupdav extends groupdav_handler
$handler = self::_get_handler(); $handler = self::_get_handler();
$vCard = htmlspecialchars_decode($options['content']); $vCard = htmlspecialchars_decode($options['content']);
if ($this->agent == 'cfnetwork')
{
// Apple Addressbook
$vCard = preg_replace('/item\d\.(ADR|TEL)/', '\1', $vCard);
}
$charset = null; $charset = null;
if (!empty($options['content_type'])) if (!empty($options['content_type']))
{ {
@ -481,8 +522,14 @@ class addressbook_groupdav extends groupdav_handler
*/ */
private function _get_handler() private function _get_handler()
{ {
if ($this->agent != 'cfnetwork' && $this->agent != 'dataaccess')
{
// Apple Addressbook don't support CLASS
$this->supportedFields['CLASS'] = array('private');
$this->supportedFields['CATEGORIES'] = array('cat_id');
}
$handler = new addressbook_vcal('addressbook','text/vcard'); $handler = new addressbook_vcal('addressbook','text/vcard');
$handler->setSupportedFields('GroupDAV',$this->agent); $handler->setSupportedFields('GroupDAV',$this->agent, $this->supportedFields);
return $handler; return $handler;
} }

View File

@ -221,19 +221,6 @@ class groupdav extends HTTP_WebDAV_Server
{ {
if ($this->debug) error_log(__CLASS__."::$method(".array2string($options,true).')'); if ($this->debug) error_log(__CLASS__."::$method(".array2string($options,true).')');
if (groupdav_handler::get_agent() == 'cfnetwork' && // Apple Addressbook
$options['root']['name'] == 'propfind')
{
foreach ($options['props'] as $props)
{
if ($props['name'] == 'current-user-privilege-set')
{
if ($this->debug > 2) error_log(__CLASS__."::$method: current-user-privilege-set not implemented!");
return '501 Not Implemented';
}
}
}
// parse path in form [/account_lid]/app[/more] // parse path in form [/account_lid]/app[/more]
if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user) if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user)
{ {