Revision: 1646
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1646&view=rev
Author:   cimorrison
Date:     2010-11-25 07:39:09 +0000 (Thu, 25 Nov 2010)

Log Message:
-----------
Better fix for Rev 1642 (bug causing approval of entries not to work when using 
PostgreSQL)

Revision Links:
--------------
    http://mrbs.svn.sourceforge.net/mrbs/?rev=1642&view=rev

Modified Paths:
--------------
    mrbs/trunk/web/dbsys.inc
    mrbs/trunk/web/mrbs_sql.inc
    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    2010-11-25 04:49:43 UTC (rev 1645)
+++ mrbs/trunk/web/dbsys.inc    2010-11-25 07:39:09 UTC (rev 1646)
@@ -460,6 +460,28 @@
 }
 
 
+// Returns the syntax for a bitwise XOR operator
+function sql_syntax_bitwise_xor()
+{
+  if (func_num_args() > 0)
+  {
+    $handle = func_get_arg(0);
+    $db_sys = $handle['system'];
+    $db_conn = $handle['connection'];
+  }
+  else
+  {
+    global $dbsys;
+
+    $db_sys = $dbsys;
+    $db_conn = null;
+  }
+
+  $f = "sql_${db_sys}_syntax_bitwise_xor";
+  return $f($db_conn);
+}
+
+
 // Return the name of a column in a result object
 function sql_field_name($result, $index)
 {

Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2010-11-25 04:49:43 UTC (rev 1645)
+++ mrbs/trunk/web/mrbs_sql.inc 2010-11-25 07:39:09 UTC (rev 1646)
@@ -698,14 +698,16 @@
   {
     // First update the repeat table
     $sql = "UPDATE $tbl_repeat 
-               SET status=status&(". ~STATUS_AWAITING_APPROVAL . ")
-             WHERE id=$id";
+               SET status=status" . sql_syntax_bitwise_xor() . 
STATUS_AWAITING_APPROVAL . "
+             WHERE id=$id
+               AND status&" . STATUS_AWAITING_APPROVAL . ">0";
     if (sql_command($sql) > 0)  // We expect there to be one row affected
     {
       // Then update the entry table
       $sql = "UPDATE $tbl_entry 
-                 SET status=status&(". ~STATUS_AWAITING_APPROVAL . ")
-               WHERE repeat_id=$id";
+                 SET status=status" . sql_syntax_bitwise_xor() . 
STATUS_AWAITING_APPROVAL . "
+               WHERE repeat_id=$id
+                 AND status&" . STATUS_AWAITING_APPROVAL . ">0";
       // It's possible that there will be no rows affected if all the
       // entries have previously been individually approved
       return (sql_command($sql) >= 0);
@@ -718,8 +720,9 @@
   else
   {
     $sql = "UPDATE $tbl_entry 
-               SET status=status&(". ~STATUS_AWAITING_APPROVAL . ")
-             WHERE id=$id";
+               SET status=status" . sql_syntax_bitwise_xor() . 
STATUS_AWAITING_APPROVAL . "
+             WHERE id=$id
+               AND status&" . STATUS_AWAITING_APPROVAL . ">0";
     return (sql_command($sql) > 0);  // We expect there to be one row affected
   }
 }

Modified: mrbs/trunk/web/mysql.inc
===================================================================
--- mrbs/trunk/web/mysql.inc    2010-11-25 04:49:43 UTC (rev 1645)
+++ mrbs/trunk/web/mysql.inc    2010-11-25 07:39:09 UTC (rev 1646)
@@ -290,6 +290,15 @@
 }
 
 
+// Returns the syntax for a bitwise XOR operator
+function sql_mysql_syntax_bitwise_xor($db_conn = null)
+{
+  sql_mysql_ensure_handle($db_conn);
+
+  return "^";
+}
+
+
 // Returns the name of a field.
 function sql_mysql_field_name($result, $index, $db_conn = null)
 {

Modified: mrbs/trunk/web/mysqli.inc
===================================================================
--- mrbs/trunk/web/mysqli.inc   2010-11-25 04:49:43 UTC (rev 1645)
+++ mrbs/trunk/web/mysqli.inc   2010-11-25 07:39:09 UTC (rev 1646)
@@ -297,6 +297,16 @@
   return "int NOT NULL auto_increment";
 }
 
+
+// Returns the syntax for a bitwise XOR operator
+function sql_mysqli_syntax_bitwise_xor($db_conn = null)
+{
+  sql_mysqli_ensure_handle($db_conn);
+
+  return "^";
+}
+
+
 // Returns the name of a field.
 function sql_mysqli_field_name($result, $index, $db_conn = null)
 {

Modified: mrbs/trunk/web/pgsql.inc
===================================================================
--- mrbs/trunk/web/pgsql.inc    2010-11-25 04:49:43 UTC (rev 1645)
+++ mrbs/trunk/web/pgsql.inc    2010-11-25 07:39:09 UTC (rev 1646)
@@ -304,6 +304,15 @@
 }
 
 
+// Returns the syntax for a bitwise XOR operator
+function sql_pgsql_syntax_bitwise_xor($db_conn = null)
+{
+  sql_pgsql_ensure_handle($db_conn);
+
+  return "#";
+}
+
+
 // Returns the name of a field.
 function sql_pgsql_field_name($result, $index, $db_conn = null)
 {


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

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to