Revision: 1540
http://mrbs.svn.sourceforge.net/mrbs/?rev=1540&view=rev
Author: cimorrison
Date: 2010-10-23 12:25:13 +0000 (Sat, 23 Oct 2010)
Log Message:
-----------
Changed Add Area so that it writes the default area settings to the database
rather than NULL. This is the first part of a fix to a bug which caused
Search and Report not to find all the results that they should have done if you
were not logged in as an admin. (Second part will be to update existing rows
in the area table replacing NULLs with the area defaults).
Modified Paths:
--------------
mrbs/trunk/web/add.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/internalconfig.inc.php
Modified: mrbs/trunk/web/add.php
===================================================================
--- mrbs/trunk/web/add.php 2010-10-22 19:25:22 UTC (rev 1539)
+++ mrbs/trunk/web/add.php 2010-10-23 12:25:13 UTC (rev 1540)
@@ -38,12 +38,46 @@
{
$error = "invalid_area_name";
}
- // 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.
+ // If so, insert the area into the database. We insert the area name that
+ // we have been given, together with the default values for the per-area
settings
else
{
- $sql = "INSERT INTO $tbl_area (area_name) VALUES ('$area_name_q')";
+ // Build arrays of data to be inserted into the table
+ $sql_col = array();
+ $sql_val = array();
+ // Get the information about the fields in the room table
+ $fields = sql_field_info($tbl_area);
+ // Loop through the fields and build up the arrays
+ foreach ($fields as $field)
+ {
+ $key = $field['name'];
+ switch ($key)
+ {
+ case 'area_name':
+ $sql_col[] = $key;
+ $sql_val[] = "'$area_name_q'";
+ break;
+ default:
+ if (array_key_exists($key, $area_defaults))
+ {
+ $sql_col[] = $key;
+ if (in_array($key, $boolean_fields['area']))
+ {
+ $sql_val[] = ($area_defaults[$key]) ? 1 : 0;
+ }
+ elseif ($field['nature'] == 'integer')
+ {
+ $sql_val[] = $area_defaults[$key];
+ }
+ else
+ {
+ $sql_val[] = "'" . addslashes($area_defaults[$key]) . "'";
+ }
+ }
+ break;
+ }
+ }
+ $sql = "INSERT INTO $tbl_area (" . implode(', ',$sql_col) . ") VALUES (" .
implode(', ',$sql_val) . ")";
if (sql_command($sql) < 0)
{
fatal_error(1, sql_error());
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2010-10-22 19:25:22 UTC (rev 1539)
+++ mrbs/trunk/web/functions.inc 2010-10-23 12:25:13 UTC (rev 1540)
@@ -547,11 +547,8 @@
global $resolution, $default_duration, $morningstarts,
$morningstarts_minutes, $eveningends, $eveningends_minutes;
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 $provisional_enabled, $reminders_enabled;
+ global $provisional_enabled, $reminders_enabled, $boolean_fields;
- $booleans = array('private_enabled', 'private_default', 'private_mandatory',
- 'min_book_ahead_enabled', 'max_book_ahead_enabled',
- 'provisional_enabled', 'reminders_enabled');
// Get all the "per area" config settings
$sql = "SELECT resolution, default_duration, morningstarts,
morningstarts_minutes,
eveningends, eveningends_minutes,
@@ -581,7 +578,7 @@
$$field = (isset($row[$field])) ? $value : $$field;
}
// Cast those fields which are booleans into booleans
- if (in_array($field, $booleans))
+ if (in_array($field, $boolean_fields['area']))
{
$$field = (bool) $$field;
}
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2010-10-22 19:25:22 UTC (rev
1539)
+++ mrbs/trunk/web/internalconfig.inc.php 2010-10-23 12:25:13 UTC (rev
1540)
@@ -89,6 +89,15 @@
'info_time',
'info_user',
'info_text');
+
+// Boolean fields. These are fields which are treated as booleans
+$boolean_fields['area'] = array('private_enabled',
+ 'private_default',
+ 'private_mandatory',
+ 'min_book_ahead_enabled',
+ 'max_book_ahead_enabled',
+ 'provisional_enabled',
+ 'reminders_enabled');
/********************************************************
* Miscellaneous
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits