Fix vCard field mapping during import (cummunity bug #3208)

This commit is contained in:
Jörg Lehrke 2013-02-19 19:37:01 +00:00
parent 64fc5c272d
commit 9bb234eca6
2 changed files with 29 additions and 29 deletions

View File

@ -723,18 +723,18 @@ class addressbook_groupdav extends groupdav_handler
private function _get_handler()
{
$handler = new addressbook_vcal('addressbook','text/vcard');
$supportedFields = $handler->supportedFields;
// Apple iOS or OS X addressbook
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'),
$supportedFields['TEL;CELL'] = $databaseFields['TEL;CELL'] = array('tel_cell');
unset($supportedFields['TEL;CELL;WORK']); unset($databaseFields['TEL;CELL;WORK']);
$supportedFields['TEL;IPHONE'] = $databaseFields['TEL;IPHONE'] = array('tel_cell_private');
unset($supportedFields['TEL;CELL;HOME']); unset($databaseFields['TEL;CELL;HOME']);
$supportedFields['TEL;CELL'] = array('tel_cell');
unset($supportedFields['TEL;CELL;WORK']);
$supportedFields['TEL;IPHONE'] = array('tel_cell_private');
unset($supportedFields['TEL;CELL;HOME']);
$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)
@ -753,9 +753,7 @@ class addressbook_groupdav extends groupdav_handler
}
$handler->setDatabaseFields($databaseFields);
}
$handler->setSupportedFields('GroupDAV',$this->agent, isset($supportedFields) ?
$supportedFields : $handler->supportedFields);
$handler->setSupportedFields('GroupDAV',$this->agent, $supportedFields);
return $handler;
}

View File

@ -34,7 +34,9 @@ class addressbook_vcal extends addressbook_bo
*/
var $productName;
/**
* supported fields for vCard file and groupdav import/export
* database fields for vCard import (and file/groupdav export)
* the import method handles the 'smart' field mapping, so
* don't change the keys.
*
* @var array
*/
@ -45,22 +47,22 @@ class addressbook_vcal extends addressbook_bo
'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',
'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;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;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'),
@ -69,11 +71,11 @@ class addressbook_vcal extends addressbook_bo
'NICKNAME' => array('label'),
'FBURL' => array('freebusy_uri'),
'PHOTO' => array('jpegphoto'),
'X-ASSISTANT' => array('assistent'),
'X-ASSISTANT-TEL' => array('tel_assistent'),
'X-ASSISTANT' => array('assistent'),
'X-ASSISTANT-TEL' => array('tel_assistent'),
'UID' => array('uid'),
'REV' => array('modified'),
//set for Apple: 'X-ABSHOWAS' => array('fileas_type'), // Horde vCard class uses uppercase prop-names!
//set for Apple: 'X-ABSHOWAS' => array('fileas_type'), // Horde vCard class uses uppercase prop-names!
);
var $supportedFields;
@ -687,7 +689,7 @@ class addressbook_vcal extends addressbook_bo
case 'IPHONE':
if ($rowName == 'TEL' || $rowName == 'TEL;CELL')
{
$rowName = 'TEL;IPHONE';
$rowName = 'TEL;CELL;HOME';
}
break;
default:
@ -836,17 +838,17 @@ class addressbook_vcal extends addressbook_bo
}
break;
case 'TEL;CELL;X-egw-Ref1':
$supported = isset($this->supportedFields['TEL;CELL']) ? 'TEL;CELL' : 'TEL;CELL;WORK';
if (!in_array($supported, $rowNames) && !isset($finalRowNames[$supported]))
if (!in_array('TEL;CELL;WORK', $rowNames)
&& !isset($finalRowNames['TEL;CELL;WORK']))
{
$finalRowNames[$supported] = $vcardKey;
$finalRowNames['TEL;CELL;WORK'] = $vcardKey;
break;
}
case 'TEL;CELL;X-egw-Ref2':
$supported = isset($this->supportedFields['TEL;IPHONE']) ? 'TEL;IPHONE' : 'TEL;CELL;HOME';
if (!in_array($supported, $rowNames) && !isset($finalRowNames[$supported]))
if (!in_array('TEL;CELL;HOME', $rowNames)
&& !isset($finalRowNames['TEL;CELL;HOME']))
{
$finalRowNames[$supported] = $vcardKey;
$finalRowNames['TEL;CELL;HOME'] = $vcardKey;
break;
}
case 'TEL;CELL;X-egw-Ref3':