Changeset:
        8f33c1da41a3
        
https://sourceforge.net/p/mrbs/hg-code/ci/8f33c1da41a30ff5864ecb799518b8dbcb81e6e7
Author:
        Campbell Morrison <cimorri...@hg.code.sf.net>
Date:
        Thu Oct 20 16:35:24 2016 +0100
Log message:

Fixed problem with simple header not being output in some circumstances.

diffstat:

 web/Themes/default/header.inc |  11 ++++++++++-
 web/functions.inc             |  40 ++++++++++++++++++++--------------------
 web/functions_error.inc       |  10 ++++------
 3 files changed, 34 insertions(+), 27 deletions(-)

diffs (104 lines):

diff -r fcd809de0c53 -r 8f33c1da41a3 web/Themes/default/header.inc
--- a/web/Themes/default/header.inc     Thu Oct 20 15:45:01 2016 +0100
+++ b/web/Themes/default/header.inc     Thu Oct 20 16:35:24 2016 +0100
@@ -213,7 +213,16 @@
   global $search_str, $locale_warning;
 
   // Need to set the timezone before we can use date()
-  get_area_settings($area);
+  if ($simple)
+  {
+    // We don't really care what timezone is being used
+    mrbs_default_timezone_set();
+  }
+  else
+  {
+    // This will set the correct timezone for the area
+    get_area_settings($area);  
+  }
 
   // If we dont know the right date then make it up 
   if (!$day)
diff -r fcd809de0c53 -r 8f33c1da41a3 web/functions.inc
--- a/web/functions.inc Thu Oct 20 15:45:01 2016 +0100
+++ b/web/functions.inc Thu Oct 20 16:35:24 2016 +0100
@@ -28,35 +28,35 @@
 }
 
 
-// Set the default timezone.   Caters for PHP servers that don't
-// have date_default_timezone_set()
-function mrbs_default_timezone_set($timezone)
+// Set the default timezone.   If $tz is not set, then the default MRBS
+// timezone from the config file is used.
+function mrbs_default_timezone_set($tz=null)
 {
-  global $area_defaults;
+  global $area_defaults, $timezone;
   
-  if (!isset($timezone))
+  if (!isset($tz))
   {
-    // to prevent people running into DST problems
-    $message = 'MRBS configuration error: $timezone has not been set.';
-    trigger_error($message, E_USER_WARNING);
-    fatal_error($message);
-  }
-  else
-  {
-    if (function_exists("date_default_timezone_set"))
+    if (isset($timezone))
     {
-      if (!date_default_timezone_set($timezone))
-      {
-        $message = "MRBS configuration error: invalid timezone '$timezone'";
-        trigger_error($message, E_USER_WARNING);
-        fatal_error($message);
-      }
+      $tz = $timezone;
     }
     else
     {
-      putenv("TZ=$timezone");
+      // We don't just use a default default timezone such as UTC because then
+      // people would start running into DST problems with their bookings.
+      $message = 'MRBS configuration error: $timezone has not been set.';
+      // Use die() rather than fatal_error() because unless we have set the 
timezone
+      // PHP starts complaining bitterly if we try and do anything remotely 
complicated.
+      die($message);
     }
   }
+  
+  if (!date_default_timezone_set($timezone))
+  {
+    $message = "MRBS configuration error: invalid timezone '$timezone'";
+    die($message);  // See comment above about use of die()
+  }
+
 }
 
 
diff -r fcd809de0c53 -r 8f33c1da41a3 web/functions_error.inc
--- a/web/functions_error.inc   Thu Oct 20 15:45:01 2016 +0100
+++ b/web/functions_error.inc   Thu Oct 20 16:35:24 2016 +0100
@@ -31,16 +31,14 @@
 
 function output_error($heading, $body, $show_data=false)
 {
-  static $date_default_timezone_set = false;
+  static $default_timezone_set = false;
   
   // We can't start outputting any error messages unless the default timezone 
has been set,
   // so if we are not sure that it has been set, then set it.
-  if (!$date_default_timezone_set)
+  if (!$default_timezone_set)
   {
-    // For some reason date_default_timezone_get() will produce an error 
message if
-    // date_default_timezone_set() hasn't already been called, so suppress any 
errors.
-    date_default_timezone_set(@date_default_timezone_get());
-    $date_default_timezone_set = true;
+    mrbs_default_timezone_set();
+    $default_timezone_set = true;
   }
   
   if ($show_data)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
Mrbs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to