Revision: 3004
https://sourceforge.net/p/mrbs/code/3004/
Author: cimorrison
Date: 2015-02-25 16:21:23 +0000 (Wed, 25 Feb 2015)
Log Message:
-----------
Got rid of the $maxlength config variable and calculated it automatically
Modified Paths:
--------------
mrbs/trunk/tables.my.sql
mrbs/trunk/tables.pg.sql
mrbs/trunk/web/dbsys.inc
mrbs/trunk/web/edit_entry_handler.php
mrbs/trunk/web/internalconfig.inc.php
mrbs/trunk/web/systemdefaults.inc.php
Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql 2015-02-25 09:34:16 UTC (rev 3003)
+++ mrbs/trunk/tables.my.sql 2015-02-25 16:21:23 UTC (rev 3004)
@@ -9,11 +9,7 @@
# 'CREATE TABLE' and 'INSERT INTO' line below to replace 'mrbs_' with
# your new table prefix.
#
-# (2) If you change the varchar lengths here, then you should check
-# to see whether a corresponding length has been defined in the config file
-# in the array $maxlength.
-#
-# (3) If you add new fields then you should also change the global variable
+# (2) If you add new fields then you should also change the global variable
# $standard_fields. Note that if you are just adding custom fields for
# a single site then this is not necessary.
Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql 2015-02-25 09:34:16 UTC (rev 3003)
+++ mrbs/trunk/tables.pg.sql 2015-02-25 16:21:23 UTC (rev 3004)
@@ -12,11 +12,7 @@
-- 'CREATE TABLE', 'create index' and 'INSERT INTO' line below to replace
-- 'mrbs_' with your new table prefix.
--
--- (3) If you change the varchar lengths here, then you should check
--- to see whether a corresponding length has been defined in the config
file
--- in the array $maxlength.
---
--- (4) If you add new (standard) fields then you should also change the global
variable
+-- (3) If you add new (standard) fields then you should also change the global
variable
-- $standard_fields. Note that if you are just adding custom fields for
-- a single site then this is not necessary.
Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc 2015-02-25 09:34:16 UTC (rev 3003)
+++ mrbs/trunk/web/dbsys.inc 2015-02-25 16:21:23 UTC (rev 3004)
@@ -2,12 +2,10 @@
// $Id$
-global $dbsys;
+global $dbsys, $db_tbl_prefix, $db_schema, $maxlength;
-// These variables specify the names of the tables in the database
-global $db_tbl_prefix, $db_schema;
-
$tables = array('area', 'entry', 'repeat', 'room', 'users', 'variables',
'zoneinfo');
+$table_vars = array();
foreach ($tables as $table)
{
@@ -21,6 +19,7 @@
{
$$var = $db_schema . '.' . $$var;
}
+ $table_vars[$table] = $var;
}
@@ -890,3 +889,22 @@
print_footer(TRUE);
}
+
+
+// Populate the $maxlength global. (We need to do this after any upgrade in
case the
+// upgrade as altered the table structures).
+foreach ($table_vars as $table => $var)
+{
+ // Find the maximum length of the CHAR and VARCHAR fields (we won't
+ // worry about TEXT fields)
+ $field_info = sql_field_info($$var);
+ foreach ($field_info as $field)
+ {
+ if (($field['nature'] == 'character') &&
+ isset($field['length']) &&
+ ($field['length'] < 256))
+ {
+ $maxlength[$table . '.' . $field['name']] = (int) $field['length'];
+ }
+ }
+}
Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php 2015-02-25 09:34:16 UTC (rev
3003)
+++ mrbs/trunk/web/edit_entry_handler.php 2015-02-25 16:21:23 UTC (rev
3004)
@@ -348,7 +348,7 @@
{
$custom_fields[$field] = utf8_substr($custom_fields[$field], 0, $length);
}
- else
+ elseif (isset($$field))
{
$$field = utf8_substr($$field, 0, $length);
}
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2015-02-25 09:34:16 UTC (rev
3003)
+++ mrbs/trunk/web/internalconfig.inc.php 2015-02-25 16:21:23 UTC (rev
3004)
@@ -34,6 +34,7 @@
trigger_error($message, E_USER_WARNING);
$mail_settings['on_change'] = ($mail_settings['admin_all']) ? TRUE : FALSE;
}
+
if (isset($mail_settings['admin_on_delete']))
{
$message = 'Please check your config file. The variable
$mail_settings["admin_on_delete"] ' .
@@ -41,6 +42,7 @@
trigger_error($message, E_USER_WARNING);
$mail_settings['on_delete'] = ($mail_settings['admin_on_delete']) ? TRUE :
FALSE;
}
+
if (!empty($dateformat))
{
$message = 'Please check your config file. The variable $dateformat ' .
@@ -56,12 +58,14 @@
'is no longer used and is redundant.';
trigger_error($message, E_USER_WARNING);
}
+
if (isset($javascript_cursor))
{
$message = 'Please check your config file. The variable $javascript_cursor
' .
'is no longer used and is redundant.';
trigger_error($message, E_USER_WARNING);
}
+
if (isset($mail_charset))
{
$message = 'Please check your config file. The variable $mail_charset ' .
@@ -79,6 +83,7 @@
$min_create_ahead_enabled = ($min_book_ahead_enabled) ? TRUE : FALSE;
$min_delete_ahead_enabled = ($min_book_ahead_enabled) ? TRUE : FALSE;
}
+
if (isset($max_book_ahead_enabled))
{
$message = 'Please check your config file. The variable
$max_book_ahead_enabled ' .
@@ -88,6 +93,7 @@
$max_create_ahead_enabled = ($max_book_ahead_enabled) ? TRUE : FALSE;
// No need to do anything about $max_delete_ahead_enabled as it didn't apply
in the old system
}
+
if (isset($min_book_ahead_secs))
{
$message = 'Please check your config file. The variable
$min_book_ahead_secs ' .
@@ -97,6 +103,7 @@
$min_create_ahead_secs = $min_book_ahead_secs;
$min_delete_ahead_secs = $min_book_ahead_secs;
}
+
if (isset($max_book_ahead_secs))
{
$message = 'Please check your config file. The variable
$max_book_ahead_secs ' .
@@ -107,7 +114,14 @@
$max_delete_ahead_secs = $max_book_ahead_secs;
}
+if (isset($max_length))
+{
+ $message = 'Please check your config file. The variable $maxlength ' .
+ 'is no longer used and maximum field lengths are now calculated
automatically.';
+ trigger_error($message, E_USER_WARNING);
+}
+
/********************************************************
* Checking
********************************************************/
@@ -457,7 +471,16 @@
// Interval types used in booking policies
$interval_types = array('day', 'week', 'month', 'year', 'future');
+/********************************************************
+ * Globals
+ ********************************************************/
+// These global declarations are not necessary, but are just used as a reminder
+// of the rather ugly use of these variables as globals, so that they are not
+// forgotten when MRBS is rewritten.
+
+global $maxlength;
+
/********************************************************
* JavaScript - internal use, do not change
********************************************************/
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2015-02-25 09:34:16 UTC (rev
3003)
+++ mrbs/trunk/web/systemdefaults.inc.php 2015-02-25 16:21:23 UTC (rev
3004)
@@ -83,19 +83,7 @@
// Uncomment this to NOT use PHP persistent (pooled) database connections:
// $db_nopersist = 1;
-// Field lengths in the database tables
-// NOTE: these must be kept in step with the database. If you change the
field
-// lengths in the database then you should change the values here, and vice
versa.
-$maxlength['entry.name'] = 80; // characters (name field in entry
table)
-$maxlength['area.area_name'] = 30; // characters (area_name field in area
table)
-$maxlength['room.room_name'] = 25; // characters (room_name field in room
table)
-$maxlength['room.description'] = 60; // characters (description field in
room table)
-$maxlength['users.name'] = 30; // characters (name field in users
table)
-$maxlength['users.email'] = 75; // characters (email field in users
table)
-// other values for the entry or users table need to follow the
$maxlength['tablename.fieldname']
-// pattern
-
/*********************************
* Site identification information
*********************************/
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits