* Fix Funambol vCard issues (community bug #1999)

This commit is contained in:
Jörg Lehrke 2012-06-17 12:28:16 +00:00
parent 3418c5284e
commit 358252b4a1
2 changed files with 17 additions and 5 deletions

View File

@ -726,6 +726,7 @@ class addressbook_groupdav extends groupdav_handler
if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess')
{
$supportedFields = $handler->supportedFields;
$databaseFields = $handler->databaseFields;
// use just CELL and IPHONE, CELL;WORK and CELL;HOME are NOT understood
//'TEL;CELL;WORK' => array('tel_cell'),
//'TEL;CELL;HOME' => array('tel_cell_private'),
@ -733,19 +734,23 @@ class addressbook_groupdav extends groupdav_handler
unset($supportedFields['TEL;CELL;WORK']);
$supportedFields['TEL;IPHONE'] = array('tel_cell_private');
unset($supportedFields['TEL;CELL;HOME']);
$supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names!
$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names!
// 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($databaseFields['CLASS']);
unset($supportedFields['CATEGORIES']);
unset($databaseFields['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']);
unset($databaseFields['PHOTO']);
}
$handler->setDatabaseFields($databaseFields);
}
$handler->setSupportedFields('GroupDAV',$this->agent, isset($supportedFields) ?
$supportedFields : $handler->supportedFields);

View File

@ -38,7 +38,7 @@ class addressbook_vcal extends addressbook_bo
*
* @var array
*/
var $supportedFields = array( // all entries e.g. for groupdav
var $databaseFields = array( // all entries e.g. for groupdav
'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',
@ -75,6 +75,8 @@ class addressbook_vcal extends addressbook_bo
'REV' => array('modified'),
//set for Apple: 'X-ABSHOWAS' => array('fileas_type'), // Horde vCard class uses uppercase prop-names!
);
var $supportedFields;
/**
* VCard version
@ -122,6 +124,7 @@ class addressbook_vcal extends addressbook_bo
break;
}
$this->clientProperties = $_clientProperties;
$this->supportedFields = $this->databaseFields;
}
/**
* import a vard into addressbook
@ -517,12 +520,16 @@ class addressbook_vcal extends addressbook_bo
function setSupportedFields($_productManufacturer='file', $_productName='', $_supportedFields = null)
{
$this->productManufacturer = strtolower($_productManufacturer);
$this->productName = strtolower($_productName);
if (is_array($_supportedFields)) $this->supportedFields = $_supportedFields;
}
function setDatabaseFields($_databaseFields)
{
if (is_array($_databaseFields)) $this->databaseFields = $_databaseFields;
}
/**
* Parses a string containing vCard data.
@ -913,9 +920,9 @@ class addressbook_vcal extends addressbook_bo
foreach ($finalRowNames as $key => $vcardKey)
{
if (isset($this->supportedFields[$key]))
if (isset($this->databaseFields[$key]))
{
$fieldNames = $this->supportedFields[$key];
$fieldNames = $this->databaseFields[$key];
foreach ($fieldNames as $fieldKey => $fieldName)
{
if (!empty($fieldName))