Revision: 2211
http://mrbs.svn.sourceforge.net/mrbs/?rev=2211&view=rev
Author: cimorrison
Date: 2011-12-24 09:27:00 +0000 (Sat, 24 Dec 2011)
Log Message:
-----------
Made $timezone a per-area setting. Based on input from Chris Thompson.
Modified Paths:
--------------
mrbs/trunk/tables.my.pre41.sql
mrbs/trunk/tables.my.sql
mrbs/trunk/tables.pg.pre73.sql
mrbs/trunk/tables.pg.sql
mrbs/trunk/web/config.inc.php
mrbs/trunk/web/dbsys.inc
mrbs/trunk/web/edit_area_room.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/functions_ical.inc
mrbs/trunk/web/internalconfig.inc.php
mrbs/trunk/web/systemdefaults.inc.php
Added Paths:
-----------
mrbs/trunk/web/upgrade/29/
mrbs/trunk/web/upgrade/29/mysql.sql
mrbs/trunk/web/upgrade/29/pgsql.sql
Modified: mrbs/trunk/tables.my.pre41.sql
===================================================================
--- mrbs/trunk/tables.my.pre41.sql 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/tables.my.pre41.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -22,6 +22,7 @@
id int NOT NULL auto_increment,
disabled tinyint(1) DEFAULT 0 NOT NULL,
area_name varchar(30),
+ timezone varchar(50),
area_admin_email text,
resolution int,
default_duration int,
@@ -150,6 +151,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '28');
+ VALUES ( 'db_version', '29');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/tables.my.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -22,6 +22,7 @@
id int NOT NULL auto_increment,
disabled tinyint(1) DEFAULT 0 NOT NULL,
area_name varchar(30) CHARACTER SET utf8 COLLATE
utf8_general_ci,
+ timezone varchar(50) CHARACTER SET utf8 COLLATE
utf8_general_ci,
area_admin_email text CHARACTER SET utf8 COLLATE utf8_general_ci,
resolution int,
default_duration int,
@@ -150,6 +151,6 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '28');
+ VALUES ( 'db_version', '29');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
Modified: mrbs/trunk/tables.pg.pre73.sql
===================================================================
--- mrbs/trunk/tables.pg.pre73.sql 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/tables.pg.pre73.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -25,6 +25,7 @@
id serial primary key,
disabled smallint DEFAULT 0 NOT NULL,
area_name varchar(30),
+ timezone varchar(50),
area_admin_email text,
resolution int,
default_duration int,
@@ -139,6 +140,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '28');
+ VALUES ('db_version', '29');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/tables.pg.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -38,6 +38,7 @@
id serial primary key,
disabled smallint DEFAULT 0 NOT NULL,
area_name varchar(30),
+ timezone varchar(50),
area_admin_email text,
resolution int,
default_duration int,
@@ -152,6 +153,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '28');
+ VALUES ('db_version', '29');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
Modified: mrbs/trunk/web/config.inc.php
===================================================================
--- mrbs/trunk/web/config.inc.php 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/web/config.inc.php 2011-12-24 09:27:00 UTC (rev 2211)
@@ -20,6 +20,10 @@
// if you don't, meetings in a different DST than you are currently
// in are offset by the DST offset incorrectly.
//
+// Note that timezones can be set on a per-area basis, so strictly speaking
this
+// setting should be in areadefaults.inc.php, but as it is so important to set
+// the right timezone it is included here.
+//
// When upgrading an existing installation, this should be set to the
// timezone the web server runs in. See the INSTALL document for more
information.
//
Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/web/dbsys.inc 2011-12-24 09:27:00 UTC (rev 2211)
@@ -16,7 +16,7 @@
$tbl_zoneinfo = $db_tbl_prefix . "zoneinfo";
-$db_schema_version = 28;
+$db_schema_version = 29;
$local_db_schema_version = 1;
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/web/edit_area_room.php 2011-12-24 09:27:00 UTC (rev 2211)
@@ -45,6 +45,73 @@
require_once "defaultincludes.inc";
require_once "mrbs_sql.inc";
+
+function create_field_entry_timezone()
+{
+ global $timezone;
+
+ $special_group = "Others";
+
+ echo "<div>\n";
+ echo "<label for=\"area_timezone\">" . get_vocab("timezone") . ":</label>\n";
+
+ // If possible we'll present a list of timezones that this server supports.
+ // Otherwise we'll just have to let the user type in a timezone, which
introduces
+ // the possibility of an invalid timezone.
+ if (function_exists('timezone_identifiers_list'))
+ {
+ $timezones = array();
+ $timezone_identifiers = timezone_identifiers_list();
+ foreach ($timezone_identifiers as $value)
+ {
+ // Note: timezone identifiers can have three components, eg
+ // America/Argentina/Tucuman. To keep things simple we will
+ // treat anything after the first '/' as a single city and
+ // limit the explosion to two
+ list($continent, $city) = explode('/', $value, 2);
+ // There are some timezone identifiers (eg 'UTC') on some operating
+ // systems that don't fit the Continent/City model. We'll put them
+ // into the special group
+ if (!isset($city))
+ {
+ $city = $continent;
+ $continent = $special_group;
+ }
+ $timezones[$continent][] = $city;
+ }
+
+ echo "<select id=\"area_timezone\" name=\"area_timezone\">\n";
+ foreach ($timezones as $continent => $cities)
+ {
+ echo "<optgroup label=\"" . htmlspecialchars($continent) . "\">\n";
+ foreach ($cities as $city)
+ {
+ if ($continent == $special_group)
+ {
+ $timezone_identifier = $city;
+ }
+ else
+ {
+ $timezone_identifier = "$continent/$city";
+ }
+ echo "<option value=\"" . htmlspecialchars($timezone_identifier) .
"\"" .
+ (($timezone_identifier == $timezone) ? " selected=\"selected\"" :
"") .
+ ">" . htmlspecialchars($city) . "</option>\n";
+ }
+ echo "</optgroup>\n";
+ }
+ echo "</select>\n";
+ }
+ // There is no timezone_identifiers_list() function so we'll just let the
+ // user type in a timezone
+ else
+ {
+ echo "<input id=\"area_timezone\" name=\"area_timezone\" value=\"" .
htmlspecialchars($timezone) . "\">\n";
+ }
+
+ echo "</div>\n";
+}
+
// Get non-standard form variables
$phase = get_form_var('phase', 'int');
$new_area = get_form_var('new_area', 'int');
@@ -58,6 +125,7 @@
$capacity = get_form_var('capacity', 'int');
$room_admin_email = get_form_var('room_admin_email', 'string');
$area_disabled = get_form_var('area_disabled', 'string');
+$area_timezone = get_form_var('area_timezone', 'string');
$area_admin_email = get_form_var('area_admin_email', 'string');
$area_morningstarts = get_form_var('area_morningstarts', 'int');
$area_morningstarts_minutes = get_form_var('area_morningstarts_minutes',
'int');
@@ -399,6 +467,7 @@
$assign_array = array();
$assign_array[] = "area_name='" . addslashes($area_name) . "'";
$assign_array[] = "disabled=" . $area_disabled;
+ $assign_array[] = "timezone='" . addslashes($area_timezone) . "'";
$assign_array[] = "area_admin_email='" . addslashes($area_admin_email) .
"'";
$assign_array[] = "custom_html='" . addslashes($custom_html) . "'";
if (!$area_enable_periods)
@@ -736,6 +805,9 @@
echo get_vocab("disabled") . "</label>\n";
echo "</div>\n";
echo "</div>\n";
+
+ // Timezone
+ create_field_entry_timezone();
?>
<div>
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/web/functions.inc 2011-12-24 09:27:00 UTC (rev 2211)
@@ -2,27 +2,51 @@
// $Id$
-/////////////////////////////////////////
-// Set timezone, if one has been provided
-global $timezone;
-
-if (isset($timezone))
+// Set the default timezone. Caters for PHP servers that don't
+// have date_default_timezone_set()
+function mrbs_default_timezone_set($timezone)
{
- if (function_exists("date_default_timezone_set"))
+ global $area_defaults;
+
+ if (!isset($timezone))
{
- date_default_timezone_set($timezone) or die("Configuration error: invalid
timezone.");
+ // to prevent people running into DST problems
+ $message = 'Configuration error: $timezone has not been set.';
+ trigger_error($message, E_USER_WARNING);
+ fatal_error(TRUE, $message);
}
else
{
- putenv("TZ=$timezone");
+ if (function_exists("date_default_timezone_set"))
+ {
+ // We try and set the timezone to $timezone, which is the timezone
setting
+ // for the area. If that fails we try the default for new areas. And
if
+ // that fails we try the server timezone.
+ if (!date_default_timezone_set($timezone))
+ {
+ $fallback_timezone = $area_defaults['timezone'];
+ if (!date_default_timezone_set($fallback_timezone))
+ {
+ // date_default_timezone_get() was introduced at the same time as
+ // date_default_timezone_set(), so it will exist
+ $fallback_timezone = date_default_timezone_get();
+ if (!date_default_timezone_set($fallback_timezone))
+ {
+ $message = "Could not set any timezone";
+ trigger_error($message, E_USER_WARNING);
+ fatal_error(TRUE, $message);
+ }
+ }
+ trigger_error("Could not set timezone to '$timezone'; using
'$fallback_timezone' instead", E_USER_WARNING);
+ }
+ }
+ else
+ {
+ putenv("TZ=$timezone");
+ }
}
}
-else
-{
- // to prevent people running into DST problems
- die('Configuration error: $timezone has not been set.');
-}
// Deal with $private_xxxx overrides. Simplifies
// logic related to private bookings.
@@ -707,11 +731,11 @@
global $private_enabled, $private_default, $private_mandatory,
$private_override;
global $min_book_ahead_enabled, $max_book_ahead_enabled,
$min_book_ahead_secs, $max_book_ahead_secs;
global $approval_enabled, $reminders_enabled, $enable_periods,
$boolean_fields;
- global $confirmation_enabled, $confirmed_default;
+ global $confirmation_enabled, $confirmed_default, $timezone;
global $private_override_options;
// Get all the "per area" config settings
- $sql = "SELECT resolution, default_duration, default_duration_all_day,
+ $sql = "SELECT timezone, resolution, default_duration,
default_duration_all_day,
morningstarts, morningstarts_minutes,
eveningends, eveningends_minutes,
private_enabled, private_default, private_mandatory,
private_override,
@@ -754,6 +778,9 @@
$message = "Invalid value for 'private_override' in the area table. Using
'private'.";
trigger_error($message, E_USER_WARNING);
}
+
+ // Set the timezone
+ mrbs_default_timezone_set($timezone);
}
// generate the predicate for use in an SQL query to test whether
Modified: mrbs/trunk/web/functions_ical.inc
===================================================================
--- mrbs/trunk/web/functions_ical.inc 2011-12-21 22:44:17 UTC (rev 2210)
+++ mrbs/trunk/web/functions_ical.inc 2011-12-24 09:27:00 UTC (rev 2211)
@@ -164,7 +164,7 @@
}
// There's nothing in the database, so try and get a VTIMEZONE component
// from the filesystem.
- else
+ elseif (file_exists($tz_file))
{
$vcalendar = file_get_contents($tz_file);
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2011-12-21 22:44:17 UTC (rev
2210)
+++ mrbs/trunk/web/internalconfig.inc.php 2011-12-24 09:27:00 UTC (rev
2211)
@@ -235,6 +235,7 @@
// per-area settings and perhaps ought to be revisited at some stage]
$area_defaults = array();
+$area_defaults['timezone'] = $timezone;
$area_defaults['resolution'] = $resolution;
$area_defaults['default_duration'] = $default_duration;
$area_defaults['default_duration_all_day'] = $default_duration_all_day;
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2011-12-21 22:44:17 UTC (rev
2210)
+++ mrbs/trunk/web/systemdefaults.inc.php 2011-12-24 09:27:00 UTC (rev
2211)
@@ -15,12 +15,16 @@
/**********
* Timezone
**********/
-
+
// The timezone your meeting rooms run in. It is especially important
// to set this if you're using PHP 5 on Linux. In this configuration
// if you don't, meetings in a different DST than you are currently
// in are offset by the DST offset incorrectly.
//
+// Note that timezones can be set on a per-area basis, so strictly speaking
this
+// setting should be in areadefaults.inc.php, but as it is so important to set
+// the right timezone it is included here.
+//
// When upgrading an existing installation, this should be set to the
// timezone the web server runs in. See the INSTALL document for more
information.
//
Property changes on: mrbs/trunk/web/upgrade/29
___________________________________________________________________
Added: bugtraq:number
+ true
Added: mrbs/trunk/web/upgrade/29/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/29/mysql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/29/mysql.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -0,0 +1,6 @@
+# $Id$
+
+# Add a column to record the area's timezone
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ADD COLUMN timezone varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci;
Property changes on: mrbs/trunk/web/upgrade/29/mysql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/29/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/29/pgsql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/29/pgsql.sql 2011-12-24 09:27:00 UTC (rev 2211)
@@ -0,0 +1,7 @@
+-- $Id$
+
+-- Add a column to record the area's timezone
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ADD COLUMN timezone varchar(50);
+
Property changes on: mrbs/trunk/web/upgrade/29/pgsql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits