diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index 43bdd2ef12..f623fc97de 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -48,6 +48,11 @@ class addressbook_merge extends bo_merge { return false; } + if($content && strpos($content, '$$#') !== 0) + { + $this->cf_link_to_expand($this->contacts->read($id), $content, $replacements,'addressbook'); + } + // Links $replacements += array( '$$links$$' => $this->get_links('addressbook', $id, '!'.egw_link::VFS_APPNAME), diff --git a/calendar/inc/class.calendar_merge.inc.php b/calendar/inc/class.calendar_merge.inc.php index f01a141d7d..2376a065c7 100644 --- a/calendar/inc/class.calendar_merge.inc.php +++ b/calendar/inc/class.calendar_merge.inc.php @@ -104,13 +104,13 @@ class calendar_merge extends bo_merge protected function get_replacements($id,&$content=null) { $prefix = ''; - // List events ? if(is_array($id) && !$id['id'] && !$id[0]['id']) { $events = $this->bo->search($this->query + $id + array( 'offset' => 0, 'order' => 'cal_start', + 'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null )); if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false) { @@ -146,7 +146,7 @@ class calendar_merge extends bo_merge $n = 0; foreach($events as $event) { - $values = $this->calendar_replacements($event,sprintf($prefix,++$n)); + $values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content); if(is_array($id) && $id['start']) { foreach(self::$range_tags as $key => $format) @@ -168,7 +168,7 @@ class calendar_merge extends bo_merge * @param boolean $last_event_too=false also include information about the last event * @return array */ - public function calendar_replacements($id,$prefix = '') + public function calendar_replacements($id,$prefix = '', &$content = '') { $replacements = array(); if(!is_array($id) || !$id['start']) { @@ -203,6 +203,11 @@ class calendar_merge extends bo_merge $duration = ($event['end'] - $event['start'])/60; $replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); + if($content && strpos($content, '$$#') !== 0) + { + $this->cf_link_to_expand($event, $content, $replacements); + } + $custom = config::get_customfields('calendar'); foreach($custom as $name => $field) { @@ -270,7 +275,7 @@ class calendar_merge extends bo_merge $days = array(); $replacements = array(); $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; - foreach($events as $day => $list) + foreach($events as $day => $list) { foreach($list as $key => $event) { @@ -369,7 +374,7 @@ class calendar_merge extends bo_merge $replacements = array(); $days = array(); $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; - foreach($events as $day => $list) + foreach($events as $day => $list) { foreach($list as $key => $event) { diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index d8eabe0470..5a3330e798 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -1121,7 +1121,7 @@ abstract class bo_merge // Custom field placeholders look like {{#name}} // Placeholders that need expanded will look like {{#name/placeholder}} - preg_match_all('/[${]{2}(([\w]+\/)*)#([\w]+)\/(.*?)[$}]{2}/', $content, $matches); + preg_match_all('/\${2}(([^\/#]*?\/)?)#([^$\/]+)\/(.*?)[$}]{2}/', $content, $matches); list($placeholders, $prefixes, $pre, $cf, $sub) = $matches; foreach($cf as $index => $field) diff --git a/timesheet/inc/class.timesheet_merge.inc.php b/timesheet/inc/class.timesheet_merge.inc.php index 5b9ed02a73..08ac4c3361 100644 --- a/timesheet/inc/class.timesheet_merge.inc.php +++ b/timesheet/inc/class.timesheet_merge.inc.php @@ -60,7 +60,7 @@ class timesheet_merge extends bo_merge */ protected function get_replacements($id,&$content=null) { - if (!($replacements = $this->timesheet_replacements($id))) + if (!($replacements = $this->timesheet_replacements($id, '', $content))) { return false; } @@ -87,7 +87,7 @@ class timesheet_merge extends bo_merge * @param string $prefix='' prefix like eg. 'erole' * @return array|boolean */ - public function timesheet_replacements($id,$prefix='') + public function timesheet_replacements($id,$prefix='', &$content = null) { $record = new timesheet_egw_record($id); $info = array(); @@ -110,6 +110,11 @@ class timesheet_merge extends bo_merge { $selects['ts_'.$name] = $value; } + if($content && strpos($content, '#') !== 0) + { + $this->cf_link_to_expand($record->get_record_array(), $content, $info); + } + importexport_export_csv::convert($record, $types, 'timesheet', $selects); $array = $record->get_record_array(); @@ -118,6 +123,7 @@ class timesheet_merge extends bo_merge { $array[$key] = self::number_format($array[$key],2,$this->mimetype); } + // Set any missing custom fields, or the marker will stay foreach($this->bo->customfields as $name => $field) {