From ca18a90b1af9312b936e909c3e8c14e0e1571935 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 12 Apr 2011 05:16:01 -0400
Subject: [PATCH] - Fix bug where template name without plugin prefix was used in render_page hook (the same fix for deprecated_templates)

---
 CHANGELOG                          |    1 +
 program/include/rcube_template.php |   26 +++++++++++++++-----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6a0f335..626b3fc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix bug where template name without plugin prefix was used in render_page hook
 - Fix handling of debug_level=4 in ajax requests (#1487831)
 - Support 'abort' and 'result' response in 'preferences_save' hook, add error handling
 - Fix bug where some content would cause hang on html2text conversion (#1487863)
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 6bd7295..f66b290 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -368,16 +368,19 @@
     private function parse($name = 'main', $exit = true)
     {
         $skin_path = $this->config['skin_path'];
-        $plugin = false;
+        $plugin    = false;
+        $realname  = $name;
+        $temp      = explode('.', $name, 2);
         $this->plugin_skin_path = null;
 
-        $temp = explode(".", $name, 2);
         if (count($temp) > 1) {
-            $plugin = $temp[0];
-            $name = $temp[1];
-            $skin_dir = $plugin . '/skins/' . $this->config['skin'];
+            $plugin    = $temp[0];
+            $name      = $temp[1];
+            $skin_dir  = $plugin . '/skins/' . $this->config['skin'];
             $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
-            if (!is_dir($skin_path)) {  // fallback to default skin
+
+            // fallback to default skin
+            if (!is_dir($skin_path)) {
                 $skin_dir = $plugin . '/skins/default';
                 $skin_path = $this->plugin_skin_path = $this->app->plugins->dir . $skin_dir;
             }
@@ -385,12 +388,13 @@
 
         $path = "$skin_path/templates/$name.html";
 
-        if (!is_readable($path) && $this->deprecated_templates[$name]) {
-            $path = "$skin_path/templates/".$this->deprecated_templates[$name].".html";
+        if (!is_readable($path) && $this->deprecated_templates[$realname]) {
+            $path = "$skin_path/templates/".$this->deprecated_templates[$realname].".html";
             if (is_readable($path))
                 raise_error(array('code' => 502, 'type' => 'php',
                     'file' => __FILE__, 'line' => __LINE__,
-                    'message' => "Using deprecated template '".$this->deprecated_templates[$name]."' in ".$this->config['skin_path']."/templates. Please rename to '".$name."'"),
+                    'message' => "Using deprecated template '".$this->deprecated_templates[$realname]
+                        ."' in ".$this->config['skin_path']."/templates. Please rename to '".$realname."'"),
                 true, false);
         }
 
@@ -401,7 +405,7 @@
                 'type' => 'php',
                 'line' => __LINE__,
                 'file' => __FILE__,
-                'message' => 'Error loading template for '.$name
+                'message' => 'Error loading template for '.$realname
                 ), true, true);
             return false;
         }
@@ -417,7 +421,7 @@
         $output = $this->parse_xml($output);
 
         // trigger generic hook where plugins can put additional content to the page
-        $hook = $this->app->plugins->exec_hook("render_page", array('template' => $name, 'content' => $output));
+        $hook = $this->app->plugins->exec_hook("render_page", array('template' => $realname, 'content' => $output));
 
         // add debug console
         if ($this->config['debug_level'] & 8) {

--
Gitblit v1.9.1