From ec0412169219208b7fe4d704a5feacd9fd0dd419 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 7 Feb 2019 09:59:38 -0700 Subject: [PATCH] Fix addressbook HTML customfields were stripped of their tags when merging --- api/src/Contacts/Merge.php | 2 +- api/src/Storage/Merge.php | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/src/Contacts/Merge.php b/api/src/Contacts/Merge.php index 47930ae094..c1240cbfee 100644 --- a/api/src/Contacts/Merge.php +++ b/api/src/Contacts/Merge.php @@ -57,7 +57,7 @@ class Merge extends Api\Storage\Merge */ protected function get_replacements($id,&$content=null,$ignore_acl=false) { - if (!($replacements = $this->contact_replacements($id,'',$ignore_acl))) + if (!($replacements = $this->contact_replacements($id,'',$ignore_acl, $content))) { return false; } diff --git a/api/src/Storage/Merge.php b/api/src/Storage/Merge.php index ee36030cc0..65900ba1cb 100644 --- a/api/src/Storage/Merge.php +++ b/api/src/Storage/Merge.php @@ -293,9 +293,21 @@ abstract class Merge foreach($ignore_acl ? Customfields::get('addressbook', true) : $this->contacts->customfields as $name => $field) { $name = '#'.$name; + if(!$contact[$name]) + { + $replacements['$$'.($prefix ? $prefix.'/':'').$name] = ''; + continue; + } + // Format date cfs per user Api\Preferences + if($this->mimetype !== 'application/x-yaml' && $contact[$name] && + ($field['type'] == 'date' || $field['type'] == 'date-time')) + { + $this->date_fields[] = '#'.$name; + $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = Api\DateTime::to($contact[$name], $field['type'] == 'date' ? true : ''); + } $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = // use raw data for yaml, no user-preference specific formatting - $this->mimetype == 'application/x-yaml' ? (string)$contact[$name] : + $this->mimetype == 'application/x-yaml' || $field['type'] == 'htmlarea' ? (string)$contact[$name] : Customfields::format($field, (string)$contact[$name]); } @@ -895,7 +907,7 @@ abstract class Merge // some general replacements: current user, date and time if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))) { - $replacements += $this->contact_replacements($user,'user'); + $replacements += $this->contact_replacements($user,'user', false, $content); $replacements['$$user/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'account_primary_group')); } $replacements['$$date$$'] = Api\DateTime::to('now',true);