* Api - Fix references to sub-fields of custom field entries only merged for the first entry of each type

This commit is contained in:
nathangray 2018-04-03 15:26:48 -06:00
parent 2e04407ed7
commit 1cb13a1f13

View File

@ -211,7 +211,7 @@ abstract class Merge
* @param boolean $ignore_acl =false true: no acl check
* @return array
*/
public function contact_replacements($contact,$prefix='',$ignore_acl=false)
public function contact_replacements($contact,$prefix='',$ignore_acl=false, &$content = '')
{
if (!is_array($contact))
{
@ -287,6 +287,11 @@ abstract class Merge
Customfields::format($field, (string)$contact[$name]);
}
if($content && strpos($content, '$$#') !== FALSE)
{
$this->cf_link_to_expand($contact, $content, $replacements, 'addressbook');
}
// Add in extra cat field
$cats = array();
foreach(is_array($contact['cat_id']) ? $contact['cat_id'] : explode(',',$contact['cat_id']) as $cat_id)
@ -1357,7 +1362,6 @@ abstract class Merge
$expand_sub_cfs[$cf[$index]] .= '$$'.$cf_sub . '$$ ';
}
}
$expand_sub_cfs = array_unique($expand_sub_cfs);
foreach($cf as $index => $field)
{
@ -1414,7 +1418,7 @@ abstract class Merge
$replacements = array();
if($app == 'addressbook')
{
return $this->contact_replacements($id, $prefix);
return $this->contact_replacements($id, $prefix, false, $content);
}
try