From 81733948a2849efa1d320b52dea9a6292474acf9 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Fri, 16 Aug 2013 13:23:35 -0700 Subject: [PATCH] CRM-13235 ---------------------------------------- * CRM-13235: Custom event name badges cannot be created as extensions http://issues.civicrm.org/jira/browse/CRM-13235 --- CRM/Event/Badge.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/CRM/Event/Badge.php b/CRM/Event/Badge.php index b8fc0004ea..4df60e4cc1 100644 --- a/CRM/Event/Badge.php +++ b/CRM/Event/Badge.php @@ -100,23 +100,19 @@ class CRM_Event_Badge { $img = get_class($this) . "." . $this->imgExtension; } - $config = CRM_Core_Config::singleton(); - $imgFile = $config->customTemplateDir . "/$path/$eventID/$img"; - if (file_exists($imgFile)) { - return $imgFile; - } - $imgFile = $config->customTemplateDir . "/$path/$img"; - if (file_exists($imgFile)) { - return $imgFile; - } - - $imgFile = "$civicrm_root/templates/$path/$eventID/$img"; - if (file_exists($imgFile)) { - return $imgFile; - } - $imgFile = "$civicrm_root/templates/$path/$img"; - if (!file_exists($imgFile) && !$this->debug) { - return FALSE; + // CRM-13235 - leverage the Smarty path to get all templates directories + $template = CRM_Core_Smarty::singleton(); + if (isset($template->template_dir) && $template->template_dir) { + $dirs = is_array( $template->template_dir ) ? $template->template_dir : array($template->template_dir); + foreach ($dirs as $dir) { + foreach (array( "$dir/$path/$eventID/$img", "$dir/$path/$img") as $imgFile) { + if (file_exists($imgFile)) { + return $imgFile; + } + } + } + } else { + $imgFile = 'No template directories defined anywhere??'; } // not sure it exists, but at least will display a meaniful fatal error in debug mode -- 2.25.1