diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index 5150633e60..72d0cefd86 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -57,15 +57,7 @@ class addressbook_merge extends bo_merge } // Links - $replacements += array( - '$$links$$' => $this->get_links('addressbook', $id, '!'.egw_link::VFS_APPNAME), - '$$attachments$$' => $this->get_links('addressbook', $id, egw_link::VFS_APPNAME), - '$$links_attachments$$' => $this->get_links('addressbook', $id) - ); - foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $app) - { - $replacements['$$links/'.$app.'$$'] = $this->get_links('addressbook',$id, $app); - } + $replacements += $this->get_all_links('addressbook', $id, $prefix, $content); if (!(strpos($content,'$$calendar/') === false)) { $replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false)); diff --git a/calendar/inc/class.calendar_merge.inc.php b/calendar/inc/class.calendar_merge.inc.php index 8ea0d01ee7..16ad123e1c 100644 --- a/calendar/inc/class.calendar_merge.inc.php +++ b/calendar/inc/class.calendar_merge.inc.php @@ -216,13 +216,7 @@ class calendar_merge extends bo_merge } // Links - $replacements['$$'.($prefix?$prefix.'/':'').'links$$'] = $this->get_links('calendar', $event['id'], '!'.egw_link::VFS_APPNAME); - $replacements['$$'.($prefix?$prefix.'/':'').'attachments$$'] = $this->get_links('calendar', $event['id'], egw_link::VFS_APPNAME); - $replacements['$$'.($prefix?$prefix.'/':'').'links_attachments$$'] = $this->get_links('calendar', $event['id']); - foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $app) - { - $replacements["$$".($prefix?$prefix.'/':'')."links/{$app}$$"] = $this->get_links('calendar',$event['id'], $app); - } + $replacements += $this->get_all_links('calendar', $event['id'], $prefix, $content); return $replacements; } diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 26c235449d..5b0f8a8c63 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -343,7 +343,7 @@ abstract class bo_merge * @param id String ID of record * @param content String document content */ - protected function get_all_links($app, $id, &$content) + protected function get_all_links($app, $id, $prefix, &$content) { $array = array(); $pattern = '@\$(links|attachments|links_attachments)\/?(title|href|link)?\/?([a-z]*)\$@'; @@ -361,18 +361,23 @@ abstract class bo_merge switch($matches[1][$i]) { case 'links': - $array[$placeholder] = $this->get_links($app, $id, '!'.egw_link::VFS_APPNAME, array(),$matches[2][$i]); + $array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, '!'.egw_link::VFS_APPNAME, array(),$matches[2][$i]); break; case 'attachments': - $array[$placeholder] = $this->get_links($app, $id, egw_link::VFS_APPNAME,array(),$matches[2][$i]); + $array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, egw_link::VFS_APPNAME,array(),$matches[2][$i]); break; default: - $array[$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]); + $array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]); break; } $link_cache[$id][$placeholder] = $array[$placeholder]; } } + // Need to set each app, to make sure placeholders are removed + foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $_app) + { + $array[($prefix?$prefix.'/':'')."links/$app"] = $this->get_links($app,$id,$_app); + } return $array; } diff --git a/infolog/inc/class.infolog_merge.inc.php b/infolog/inc/class.infolog_merge.inc.php index a410444b09..18068f9eb8 100644 --- a/infolog/inc/class.infolog_merge.inc.php +++ b/infolog/inc/class.infolog_merge.inc.php @@ -125,9 +125,7 @@ class infolog_merge extends bo_merge } // Links - $array['links'] = $this->get_links('infolog', $id, '!'.egw_link::VFS_APPNAME, array($array['info_link']['id'])); - $array['attachments'] = $this->get_links('infolog', $id, egw_link::VFS_APPNAME); - $array['links_attachments'] = $this->get_links('infolog', $id, '', array($array['info_link']['id'])); + $array += $this->get_all_links('infolog', $id, $content); // Need to set each app, to make sure placeholders are removed foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $app) { diff --git a/timesheet/inc/class.timesheet_merge.inc.php b/timesheet/inc/class.timesheet_merge.inc.php index 684834b9f1..3f19425ace 100644 --- a/timesheet/inc/class.timesheet_merge.inc.php +++ b/timesheet/inc/class.timesheet_merge.inc.php @@ -136,13 +136,7 @@ class timesheet_merge extends bo_merge } // Links - $array['links'] = $this->get_links('timesheet', $id, '!'.egw_link::VFS_APPNAME); - $array['attachments'] = $this->get_links('timesheet', $id, egw_link::VFS_APPNAME); - $array['links_attachments'] = $this->get_links('timesheet', $id); - foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $app) - { - $array["links/{$app}"] = $this->get_links('timesheet',$id, $app); - } + $array += $this->get_all_links('timesheet', $id, $prefix, $content); // Add markers foreach($array as $key => &$value)