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() private function _get_handler()
{ {
$handler = new addressbook_vcal('addressbook','text/vcard'); $handler = new addressbook_vcal('addressbook','text/vcard');
$supportedFields = $handler->supportedFields;
// Apple iOS or OS X addressbook // Apple iOS or OS X addressbook
if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess') if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess')
{ {
$supportedFields = $handler->supportedFields;
$databaseFields = $handler->databaseFields; $databaseFields = $handler->databaseFields;
// use just CELL and IPHONE, CELL;WORK and CELL;HOME are NOT understood // use just CELL and IPHONE, CELL;WORK and CELL;HOME are NOT understood
//'TEL;CELL;WORK' => array('tel_cell'), //'TEL;CELL;WORK' => array('tel_cell'),
//'TEL;CELL;HOME' => array('tel_cell_private'), //'TEL;CELL;HOME' => array('tel_cell_private'),
$supportedFields['TEL;CELL'] = $databaseFields['TEL;CELL'] = array('tel_cell'); $supportedFields['TEL;CELL'] = array('tel_cell');
unset($supportedFields['TEL;CELL;WORK']); unset($databaseFields['TEL;CELL;WORK']); unset($supportedFields['TEL;CELL;WORK']);
$supportedFields['TEL;IPHONE'] = $databaseFields['TEL;IPHONE'] = array('tel_cell_private'); $supportedFields['TEL;IPHONE'] = array('tel_cell_private');
unset($supportedFields['TEL;CELL;HOME']); unset($databaseFields['TEL;CELL;HOME']); unset($supportedFields['TEL;CELL;HOME']);
$databaseFields['X-ABSHOWAS'] = $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) // 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->setDatabaseFields($databaseFields);
} }
$handler->setSupportedFields('GroupDAV',$this->agent, isset($supportedFields) ? $handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields);
$supportedFields : $handler->supportedFields);
return $handler; return $handler;
} }

View File

@ -692,7 +692,7 @@ class addressbook_vcal extends addressbook_bo
case 'IPHONE': case 'IPHONE':
if ($rowName == 'TEL' || $rowName == 'TEL;CELL') if ($rowName == 'TEL' || $rowName == 'TEL;CELL')
{ {
$rowName = 'TEL;IPHONE'; $rowName = 'TEL;CELL;HOME';
} }
break; break;
default: default:
@ -841,17 +841,17 @@ class addressbook_vcal extends addressbook_bo
} }
break; break;
case 'TEL;CELL;X-egw-Ref1': case 'TEL;CELL;X-egw-Ref1':
$supported = isset($this->supportedFields['TEL;CELL']) ? 'TEL;CELL' : 'TEL;CELL;WORK'; if (!in_array('TEL;CELL;WORK', $rowNames)
if (!in_array($supported, $rowNames) && !isset($finalRowNames[$supported])) && !isset($finalRowNames['TEL;CELL;WORK']))
{ {
$finalRowNames[$supported] = $vcardKey; $finalRowNames['TEL;CELL;WORK'] = $vcardKey;
break; break;
} }
case 'TEL;CELL;X-egw-Ref2': case 'TEL;CELL;X-egw-Ref2':
$supported = isset($this->supportedFields['TEL;IPHONE']) ? 'TEL;IPHONE' : 'TEL;CELL;HOME'; if (!in_array('TEL;CELL;HOME', $rowNames)
if (!in_array($supported, $rowNames) && !isset($finalRowNames[$supported])) && !isset($finalRowNames['TEL;CELL;HOME']))
{ {
$finalRowNames[$supported] = $vcardKey; $finalRowNames['TEL;CELL;HOME'] = $vcardKey;
break; break;
} }
case 'TEL;CELL;X-egw-Ref3': case 'TEL;CELL;X-egw-Ref3':