added user-agent detection for Snow Leopard (OS X 10.6) addressbook, to stop it from messing up categories and photo, Lion (10.7) addressbook works find

This commit is contained in:
Ralf Becker 2012-02-14 15:14:41 +00:00
parent 1624c37dc7
commit 7d2572dca5
2 changed files with 14 additions and 40 deletions

View File

@ -711,6 +711,18 @@ class addressbook_groupdav extends groupdav_handler
unset($supportedFields['TEL;CELL;WORK']);
$supportedFields['TEL;IPHONE'] = array('tel_cell_private');
unset($supportedFields['TEL;CELL;HOME']);
// Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone)
if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520)
{
unset($supportedFields['CLASS']);
unset($supportedFields['CATEGORIES']);
// gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg:
// - JPEG library reports unrecoverable error
// - Passed data is not in 'JPEG' format
// - Couldn't create GD Image Stream out of Data
// FF (10), Safari (5.1.3) and Chrome (17) cant display it either --> ignore images
unset($supportedFields['PHOTO']);
}
}
$handler->setSupportedFields('GroupDAV',$this->agent, isset($supportedFields) ?
$supportedFields : $handler->supportedFields);

View File

@ -525,44 +525,6 @@ class addressbook_vcal extends addressbook_bo
// the horde class does the charset conversion. DO NOT CONVERT HERE.
// be as flexible as possible
$databaseFields = 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'),
'X-CLASS' => array('private'),
'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'),
'REV' => array('modified'),
);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
@ -928,9 +890,9 @@ class addressbook_vcal extends addressbook_bo
foreach ($finalRowNames as $key => $vcardKey)
{
if (isset($databaseFields[$key]))
if (isset($this->supportedFields[$key]))
{
$fieldNames = $databaseFields[$key];
$fieldNames = $this->supportedFields[$key];
foreach ($fieldNames as $fieldKey => $fieldName)
{
if (!empty($fieldName))