From e46d060a4ab4b2a901c3dd4a3909490a547284e1 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sun, 10 Nov 2013 07:29:48 -0500
Subject: [PATCH] Fix errors in error page :-)

---
 program/include/rcmail_output_html.php |   19 ++++++++++---------
 program/steps/utils/error.inc          |    1 +
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 8a96067..6db826e 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -310,12 +310,14 @@
      */
     public function reset($all = false)
     {
+        $framed = $this->framed;
         $env = $all ? null : array_intersect_key($this->env, array('extwin'=>1, 'framed'=>1));
 
         parent::reset();
 
         // let some env variables survive
         $this->env = $this->js_env = $env;
+        $this->framed = $framed || $this->env['framed'];
         $this->js_labels    = array();
         $this->js_commands  = array();
         $this->script_files = array();
@@ -323,6 +325,11 @@
         $this->header       = '';
         $this->footer       = '';
         $this->body         = '';
+
+        // load defaults
+        if (!$all) {
+            $this->__construct();
+        }
     }
 
     /**
@@ -1203,8 +1210,6 @@
      */
     public function include_script($file, $position='head')
     {
-        static $sa_files = array();
-
         if (!preg_match('|^https?://|i', $file) && $file[0] != '/') {
             $file = $this->scripts_path . $file;
             if ($fs = @filemtime($file)) {
@@ -1212,17 +1217,13 @@
             }
         }
 
-        if (in_array($file, $sa_files)) {
-            return;
-        }
-
-        $sa_files[] = $file;
-
         if (!is_array($this->script_files[$position])) {
             $this->script_files[$position] = array();
         }
 
-        $this->script_files[$position][] = $file;
+        if (!in_array($file, $this->script_files[$position])) {
+            $this->script_files[$position][] = $file;
+        }
     }
 
     /**
diff --git a/program/steps/utils/error.inc b/program/steps/utils/error.inc
index 9fb71c5..a891d42 100644
--- a/program/steps/utils/error.inc
+++ b/program/steps/utils/error.inc
@@ -110,6 +110,7 @@
 
 if ($rcmail->output && $rcmail->output->template_exists('error')) {
   $rcmail->output->reset();
+  $rcmail->output->set_env('server_error', $ERROR_CODE);
   $rcmail->output->send('error');
 }
 

--
Gitblit v1.9.1