* 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 cb3de8cf91
commit 59483c4b79

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)
@ -1356,7 +1361,6 @@ abstract class Merge
$expand_sub_cfs[$cf[$index]] .= '$$'.$cf_sub . '$$ ';
}
}
$expand_sub_cfs = array_unique($expand_sub_cfs);
foreach($cf as $index => $field)
{
@ -1413,7 +1417,7 @@ abstract class Merge
$replacements = array();
if($app == 'addressbook')
{
return $this->contact_replacements($id, $prefix);
return $this->contact_replacements($id, $prefix, false, $content);
}
try