Revision: 1428
http://mrbs.svn.sourceforge.net/mrbs/?rev=1428&view=rev
Author: cimorrison
Date: 2010-08-31 14:17:39 +0000 (Tue, 31 Aug 2010)
Log Message:
-----------
- Fixed bug whereby the default area settings (eg $provisional_enabled) were
not being picked up properly
- Fixed bug whereby new areas were being created with the incorrect default
privacy settings
Modified Paths:
--------------
mrbs/trunk/web/Themes/default/header.inc
mrbs/trunk/web/add.php
mrbs/trunk/web/defaultincludes.inc
mrbs/trunk/web/internalconfig.inc.php
mrbs/trunk/web/pending.php
Modified: mrbs/trunk/web/Themes/default/header.inc
===================================================================
--- mrbs/trunk/web/Themes/default/header.inc 2010-08-29 08:54:14 UTC (rev
1427)
+++ mrbs/trunk/web/Themes/default/header.inc 2010-08-31 14:17:39 UTC (rev
1428)
@@ -6,7 +6,7 @@
function print_theme_header($day, $month, $year, $area, $room)
{
global $mrbs_company, $mrbs_company_logo, $mrbs_company_url,
$mrbs_company_more_info,
- $search_str, $locale_warning, $provisional_enabled;
+ $search_str, $locale_warning, $area_defaults;
global $tbl_entry, $tbl_room, $tbl_area;
global $PHP_SELF, $view_week_number, $weekstarts;
global $default_language_tokens, $disable_automatic_language_changing,
$override_locale;
@@ -416,7 +416,20 @@
// Provide a link to the list of outstanding provisional bookings
// (if there are any areas where we are using provisional bookings)
$user = getUserName();
- $provisional_somewhere = (sql_query1("SELECT COUNT(*) FROM $tbl_area
WHERE provisional_enabled>0 LIMIT 1") > 0);
+ // Build the SQL condition for evaluating whether provisional booking
is
+ // enabled for an area. It is enabled if the field is set, or if
it's
+ // not set but the default area setting is for it to be enabled.
+ $sql_provisional_enabled = "(provisional_enabled IS NOT NULL AND
provisional_enabled > 0)";
+ if ($area_defaults['provisional_enabled'])
+ {
+ $sql_provisional_enabled = "(" . $sql_provisional_enabled . " OR
(provisional_enabled IS NULL))";
+ }
+
+ $sql = "SELECT COUNT(*)
+ FROM $tbl_area
+ WHERE $sql_provisional_enabled
+ LIMIT 1";
+ $provisional_somewhere = (sql_query1($sql) > 0);
if ($provisional_somewhere && (authGetUserLevel($user) >= 1))
{
$is_admin = (authGetUserLevel($user) >= 2);
@@ -427,7 +440,7 @@
WHERE status=" . STATUS_PROVISIONAL . "
AND E.room_id = R.id
AND R.area_id = A.id
- AND A.provisional_enabled>0";
+ AND $sql_provisional_enabled";
if (!$is_admin)
{
// Ordinary users can only see their own
Modified: mrbs/trunk/web/add.php
===================================================================
--- mrbs/trunk/web/add.php 2010-08-29 08:54:14 UTC (rev 1427)
+++ mrbs/trunk/web/add.php 2010-08-31 14:17:39 UTC (rev 1428)
@@ -33,18 +33,12 @@
{
$error = "invalid_area_name";
}
- // If so, insert the area into the database
+ // If so, insert the area into the database. We just insert the area name
+ // at this stage. The per-area settings will be NULL, which will be
translated
+ // by get_area_settings() into the default values for new areas.
else
{
- // Convert booleans to 1 or 0, as the fields are tinyints/smallints
- $private_enabled = ($private_enabled) ? 1 : 0;
- $private_default = ($private_default) ? 1 : 0;
- $private_mandatory = ($private_mandatory) ? 1 : 0;
- // Need to make sure the private settings are not NULL. We can't specify
a default
- // in the SQL when creating the table because the default is a variable in
the config file
- $sql = "INSERT INTO $tbl_area
- (area_name, private_enabled, private_default, private_mandatory,
private_override)
- VALUES ('$area_name_q', $private_enabled, $private_default,
$private_mandatory, '$private_override')";
+ $sql = "INSERT INTO $tbl_area (area_name) VALUES ('$area_name_q')";
if (sql_command($sql) < 0)
{
fatal_error(1, sql_error());
Modified: mrbs/trunk/web/defaultincludes.inc
===================================================================
--- mrbs/trunk/web/defaultincludes.inc 2010-08-29 08:54:14 UTC (rev 1427)
+++ mrbs/trunk/web/defaultincludes.inc 2010-08-31 14:17:39 UTC (rev 1428)
@@ -4,8 +4,8 @@
require_once "grab_globals.inc.php";
require_once "systemdefaults.inc.php";
+require_once "config.inc.php";
require_once "internalconfig.inc.php";
-require_once "config.inc.php";
require_once "functions.inc";
require_once "dbsys.inc";
require_once "mrbs_auth.inc";
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2010-08-29 08:54:14 UTC (rev
1427)
+++ mrbs/trunk/web/internalconfig.inc.php 2010-08-31 14:17:39 UTC (rev
1428)
@@ -84,6 +84,17 @@
'info_time',
'info_user',
'info_text');
+
+/********************************************************
+ * Miscellaneous
+ ********************************************************/
+ // Save some of the default per-area settings for later use. We
+ // do this because they will get overwritten by the values for
+ // the current area in a moment - in standard_vars.inc by a call to
+ // get_area_settings(). [This isn't a very elegant way of handling
+ // per-area settings and perhaps ought to be revisited at some stage]
+ $area_defaults = array();
+ $area_defaults['provisional_enabled'] = $provisional_enabled;
/********************************************************
* PHP System Configuration - internal use, do not change
Modified: mrbs/trunk/web/pending.php
===================================================================
--- mrbs/trunk/web/pending.php 2010-08-29 08:54:14 UTC (rev 1427)
+++ mrbs/trunk/web/pending.php 2010-08-31 14:17:39 UTC (rev 1428)
@@ -161,6 +161,16 @@
// Get a list of all the provisional bookings
// We are only interested in areas where provisional bookings are enabled
+
+// Build the SQL condition for evaluating whether provisional booking is
+// enabled for an area. It is enabled if the field is set, or if it's
+// not set but the default area setting is for it to be enabled.
+$sql_provisional_enabled = "(provisional_enabled IS NOT NULL AND
provisional_enabled > 0)";
+if ($area_defaults['provisional_enabled'])
+{
+ $sql_provisional_enabled = "(" . $sql_provisional_enabled . " OR
(provisional_enabled IS NULL))";
+}
+
$sql = "SELECT E.id, E.name, E.room_id, E.start_time, E.create_by, " .
sql_syntax_timestamp_to_unix("E.timestamp") . " AS last_updated,
E.reminded, E.repeat_id,
@@ -171,7 +181,7 @@
LEFT JOIN $tbl_repeat AS T ON E.repeat_id=T.id
WHERE E.room_id = M.id
AND M.area_id = A.id
- AND A.provisional_enabled>0
+ AND $sql_provisional_enabled
AND status=" . STATUS_PROVISIONAL;
// Ordinary users can only see their own bookings
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits