Fix import of vCard photos with ENCODING=BASE64

This commit is contained in:
Nathan Gray 2015-09-29 14:43:07 +00:00
parent 6450e343c4
commit 0dd3c78346
3 changed files with 10 additions and 8 deletions

View File

@ -78,8 +78,7 @@ class addressbook_egw_record implements importexport_iface_egw_record
* @return array complete record as associative array
*/
public function get_record_array() {
// do not return binary jpeg, it messes up json data
return array_diff_key($this->contact, array('jpegphoto' => true));
return $this->contact;
}
/**

View File

@ -121,8 +121,8 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
// Failures
$this->errors = array();
// Fix for Apple Addressbook
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
// Fix for Apple Addressbook
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
$contacts = new egw_ical_iterator($vCard, '', $charset, array($this, '_vcard'),array(
// Owner (addressbook)
@ -272,7 +272,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
foreach($this->preview_records as $i => $record)
{
// Convert to human-friendly
importexport_export_csv::convert($record,$record_class::$types,$_definition->application);
importexport_export_csv::convert($record,$record_class::$types,$_definition->application);
$record = $record->get_record_array();
$row = array();
foreach($labels as $field => $label)
@ -282,7 +282,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
// Don't scare users, do something with jpeg
if($field == 'jpegphoto' && $row[$field])
{
$row[$field] = '<span style="white-space: nowrap;">-ENCODED IMAGE-</span>';
$row[$field] = '<img style="max-width:50px;max-height:50px;" src="data:image/jpeg;base64,'.$row[$field].'"/>';
}
unset($record[$field]);
}

View File

@ -953,8 +953,11 @@ class addressbook_vcal extends addressbook_bo
break;
case 'jpegphoto':
$contact[$fieldName] = $vcardValues[$vcardKey]['params']['ENCODING'] == 'b' ?
base64_decode($vcardValues[$vcardKey]['value']): $vcardValues[$vcardKey]['value'];
$contact[$fieldName] = $vcardValues[$vcardKey]['value'];
if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64')))
{
$contact[$fieldName] = base64_decode($contact[$fieldName]);
}
break;
case 'note':