Revision: 1830
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1830&view=rev
Author:   cimorrison
Date:     2011-05-26 09:05:58 +0000 (Thu, 26 May 2011)

Log Message:
-----------
Fixed bug preventing a room name being changed when only the case of letters in 
the name was being changed.

Modified Paths:
--------------
    mrbs/trunk/web/dbsys.inc
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/mysql.inc
    mrbs/trunk/web/mysqli.inc
    mrbs/trunk/web/pgsql.inc

Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc    2011-05-21 16:35:19 UTC (rev 1829)
+++ mrbs/trunk/web/dbsys.inc    2011-05-26 09:05:58 UTC (rev 1830)
@@ -386,6 +386,29 @@
 }
 
 
+// Returns the syntax for a case sensitive string "equals" function
+// (By default MySQL is case insensitive, whereas PostgreSQL is not)
+function sql_syntax_casesensitive_equals($fieldname, $s)
+{
+  if (func_num_args() > 2)
+  {
+    $handle = func_get_arg(2);
+    $db_sys = $handle['system'];
+    $db_conn = $handle['connection'];
+  }
+  else
+  {
+    global $dbsys;
+
+    $db_sys = $dbsys;
+    $db_conn = null;
+  }
+
+  $f = "sql_${db_sys}_syntax_casesensitive_equals";
+  return $f($fieldname, $s, $db_conn);
+}
+
+
 // Returns the syntax for a caseless "contains" function
 function sql_syntax_caseless_contains($fieldname, $s)
 {

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2011-05-21 16:35:19 UTC (rev 1829)
+++ mrbs/trunk/web/edit_area_room.php   2011-05-26 09:05:58 UTC (rev 1830)
@@ -193,8 +193,13 @@
       // (only do this if you're changing the room name or the area - if you're
       // just editing the other details for an existing room we don't want to 
reject
       // the edit because the room already exists!)
+      // [SQL escaping done by sql_syntax_casesensitive_equals()]
       elseif ( (($new_area != $old_area) || ($room_name != $old_room_name))
-              && sql_query1("SELECT COUNT(*) FROM $tbl_room WHERE room_name='" 
. addslashes($room_name) . "' AND area_id=$new_area LIMIT 1") > 0)
+              && sql_query1("SELECT COUNT(*)
+                               FROM $tbl_room
+                              WHERE" . 
sql_syntax_casesensitive_equals("room_name", $room_name) . "
+                                AND area_id=$new_area
+                              LIMIT 1") > 0)
       {
         $valid_room_name = FALSE;
       }

Modified: mrbs/trunk/web/mysql.inc
===================================================================
--- mrbs/trunk/web/mysql.inc    2011-05-21 16:35:19 UTC (rev 1829)
+++ mrbs/trunk/web/mysql.inc    2011-05-26 09:05:58 UTC (rev 1830)
@@ -254,6 +254,15 @@
 }
 
 
+// Returns the syntax for a case sensitive string "equals" function
+// (By default MySQL is case insensitive, so we force a binary comparison)
+function sql_mysql_syntax_casesensitive_equals($fieldname, $s, $db_conn = null)
+{
+  sql_mysql_ensure_handle($db_conn);
+
+  return " BINARY `$fieldname`='" . addslashes($s) . "'";
+}
+
 // Generate non-standard SQL to match a string anywhere in a field's value
 // in a case insensitive manner. $s is the un-escaped/un-slashed string.
 // In MySQL, REGEXP seems to be case sensitive, so use LIKE instead. But this

Modified: mrbs/trunk/web/mysqli.inc
===================================================================
--- mrbs/trunk/web/mysqli.inc   2011-05-21 16:35:19 UTC (rev 1829)
+++ mrbs/trunk/web/mysqli.inc   2011-05-26 09:05:58 UTC (rev 1830)
@@ -262,6 +262,15 @@
 }
 
 
+// Returns the syntax for a case sensitive string "equals" function
+// (By default MySQL is case insensitive, so we force a binary comparison)
+function sql_mysqli_syntax_casesensitive_equals($fieldname, $s, $db_conn = 
null)
+{
+  sql_mysqli_ensure_handle($db_conn);
+
+  return " BINARY `$fieldname`='" . addslashes($s) . "'";
+}
+
 // Generate non-standard SQL to match a string anywhere in a field's value
 // in a case insensitive manner. $s is the un-escaped/un-slashed string.
 // In MySQL, REGEXP seems to be case sensitive, so use LIKE instead. But this

Modified: mrbs/trunk/web/pgsql.inc
===================================================================
--- mrbs/trunk/web/pgsql.inc    2011-05-21 16:35:19 UTC (rev 1829)
+++ mrbs/trunk/web/pgsql.inc    2011-05-26 09:05:58 UTC (rev 1830)
@@ -279,6 +279,15 @@
 }
 
 
+// Returns the syntax for a case sensitive string "equals" function
+function sql_pgsql_syntax_casesensitive_equals($fieldname, $s, $db_conn = null)
+{
+  sql_pgsql_ensure_handle($db_conn);
+
+  return " \"$fieldname\"='" . addslashes($s) . "'";
+}
+
+
 // Generate non-standard SQL to match a string anywhere in a field's value
 // in a case insensitive manner. $s is the un-escaped/un-slashed string.
 // In PostgreSQL, we can do case insensitive regexp with ~*, but not case


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to