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

This commit is contained in:
Jörg Lehrke 2013-02-19 19:53:20 +00:00
parent acd70575c6
commit 3bce17e854
2 changed files with 26 additions and 28 deletions

View File

@ -795,18 +795,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)
@ -832,9 +832,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

@ -45,22 +45,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 +69,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;
@ -692,7 +692,7 @@ class addressbook_vcal extends addressbook_bo
case 'IPHONE':
if ($rowName == 'TEL' || $rowName == 'TEL;CELL')
{
$rowName = 'TEL;IPHONE';
$rowName = 'TEL;CELL;HOME';
}
break;
default:
@ -841,17 +841,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':