From 654054826fb8ae4ba5c2b9de42973831329f5872 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 5 Jun 2013 17:03:27 +0000 Subject: [PATCH] Implement home-accounts and select-account custom fields sub-placeholder expansions in the correct place, with the rest of them --- etemplate/inc/class.bo_merge.inc.php | 30 ++++++++++++++++++++----- infolog/inc/class.infolog_merge.inc.php | 11 --------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 3d33ba8090..96dc2e6863 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -1246,20 +1246,40 @@ abstract class bo_merge foreach($cf as $index => $field) { - if($cfs[$field] && in_array($cfs[$field]['type'],array_keys($GLOBALS['egw_info']['apps'])) ) + if($cfs[$field]) { + if(in_array($cfs[$field]['type'],array_keys($GLOBALS['egw_info']['apps']))) + { + $field_app = $cfs[$field]['type']; + } + else if ($cfs[$field]['type'] == 'home-accounts' || $cfs[$field]['type'] == 'select-account') + { + // Special case for home-accounts -> contact + $field_app = 'addressbook'; + $account = $GLOBALS['egw']->accounts->read($values['#'.$field]); + $app_replacements[$field] = $this->contact_replacements($account['person_id']); + } + else if ($list = explode('-',$cfs[$field]['type']) && in_array($list[0], array_keys($GLOBALS['egw_info']['apps']))) + { + // Sub-type - use app + $field_app = $list[0]; + } + else + { + continue; + } + // Get replacements for that application - $field_app = $cfs[$field]['type']; - if(!$app_replacements[$field_app]) + if(!$app_replacements[$field]) { $classname = "{$field_app}_merge"; $class = new $classname(); // If we send the real content, it can result in infinite loop of lookups // This means you can't do {{#other_app/#other_app_cf/n_fn}} $content = ''; - $app_replacements[$field_app] = $class->get_replacements($values['#'.$field], $content); + $app_replacements[$field] = $class->get_replacements($values['#'.$field], $content); } - $replacements[$placeholders[$index]] = $app_replacements[$field_app]['$$'.$sub[$index].'$$']; + $replacements[$placeholders[$index]] = $app_replacements[$field]['$$'.$sub[$index].'$$']; } else { diff --git a/infolog/inc/class.infolog_merge.inc.php b/infolog/inc/class.infolog_merge.inc.php index ff9db179cc..bffd6ffb77 100644 --- a/infolog/inc/class.infolog_merge.inc.php +++ b/infolog/inc/class.infolog_merge.inc.php @@ -101,17 +101,6 @@ class infolog_merge extends bo_merge $this->cf_link_to_expand($record->get_record_array(), $content, $info); } - foreach($this->bo->customfields as $name => $field) - { - if ($field['type'] == 'select-account') - { - $record_name = '#'.$name; - $account = $GLOBALS['egw']->accounts->read($record->$record_name); - $info += $this->contact_replacements($account['person_id'], - ($prefix ? $prefix . '/' : '')."#$name" - ); - } - } importexport_export_csv::convert($record, $types, 'infolog', $selects); if($record->info_contact) {