From 40d786871ec3cb8f8cdcbfe45b3a264e415e7a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Sat, 25 Sep 2010 15:19:48 +0000 Subject: [PATCH] Improve Mac OS Addressbook.App CardDAV support as far as reasonable --- .../inc/class.addressbook_groupdav.inc.php | 49 ++++++++++++++++++- phpgwapi/inc/class.groupdav.inc.php | 13 ----- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 8ecde4f5d9..d7a3257ed3 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -33,6 +33,42 @@ class addressbook_groupdav extends groupdav_handler '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 * @@ -277,6 +313,11 @@ class addressbook_groupdav extends groupdav_handler $handler = self::_get_handler(); $vCard = htmlspecialchars_decode($options['content']); + if ($this->agent == 'cfnetwork') + { + // Apple Addressbook + $vCard = preg_replace('/item\d\.(ADR|TEL)/', '\1', $vCard); + } $charset = null; if (!empty($options['content_type'])) { @@ -481,8 +522,14 @@ class addressbook_groupdav extends groupdav_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->setSupportedFields('GroupDAV',$this->agent); + $handler->setSupportedFields('GroupDAV',$this->agent, $this->supportedFields); return $handler; } diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index e01dc6d957..21514eb018 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -221,19 +221,6 @@ class groupdav extends HTTP_WebDAV_Server { 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] if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user) {