[Fusionforge-commits] r14929 - in branches/Branch_5_1: . src/common/include

Roland Mas lolando at fusionforge.org
Fri Nov 25 11:38:07 CET 2011


Author: lolando
Date: 2011-11-25 11:38:06 +0100 (Fri, 25 Nov 2011)
New Revision: 14929

Modified:
   branches/Branch_5_1/
   branches/Branch_5_1/src/common/include/pre.php
   branches/Branch_5_1/src/common/include/session.php
Log:
Inspired from Evolvis: better handling of timezone settings

Modified: branches/Branch_5_1/src/common/include/pre.php
===================================================================
--- branches/Branch_5_1/src/common/include/pre.php	2011-11-25 08:03:26 UTC (rev 14928)
+++ branches/Branch_5_1/src/common/include/pre.php	2011-11-25 10:38:06 UTC (rev 14929)
@@ -310,12 +310,12 @@
 	// and setup theme
 	if (session_loggedin()) {
 		$LUSER =& session_get_user();
-		putenv ('TZ='. $LUSER->getTimeZone());
 		header ('Cache-Control: private');
 		require_once forge_get_config('themes_root').'/'.$LUSER->setUpTheme().'/Theme.class.php';
 	} else {
 		require_once forge_get_config('themes_root').'/'.forge_get_config('default_theme').'/Theme.class.php';
 	}
+	setup_tz_from_context();
 	$HTML = new Theme () ;
 } else {		     // Script run from cron or a command line
 	require_once $gfcommon.'include/squal_exit.php';

Modified: branches/Branch_5_1/src/common/include/session.php
===================================================================
--- branches/Branch_5_1/src/common/include/session.php	2011-11-25 08:03:26 UTC (rev 14928)
+++ branches/Branch_5_1/src/common/include/session.php	2011-11-25 10:38:06 UTC (rev 14929)
@@ -581,15 +581,26 @@
 	$session_ser = $sessionKey;
 	session_set();
 	setup_gettext_from_context();
+	setup_tz_from_context();
 	$LUSER =& session_get_user();
 	if (!is_object($LUSER) || $LUSER->isError()) {
 		return false;
 	} else {
-		putenv('TZ='. $LUSER->getTimeZone());
 		return true;
 	}
 }
 
+function setup_tz_from_context() {
+	$LUSER =& session_get_user();
+	if (!is_object($LUSER) || $LUSER->isError()) {
+		$tz = forge_get_config('default_timezone');
+	} else {
+		$tz = $LUSER->getTimeZone();
+	}
+	putenv ('TZ='. $tz);
+	date_default_timezone_set($tz);
+}	
+
 /**
  *	session_get_user() - Wrapper function to return the User object for the logged in user.
  *	




More information about the Fusionforge-commits mailing list