Revision: 1140
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1140&view=rev
Author:   cimorrison
Date:     2009-06-29 11:39:08 +0000 (Mon, 29 Jun 2009)

Log Message:
-----------
Fixed an existing problem where the default value fr the level column is set to 
1 instead of 0 in the case that the users table already exists.

Modified Paths:
--------------
    mrbs/trunk/web/upgrade/6/post.inc

Modified: mrbs/trunk/web/upgrade/6/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/6/post.inc   2009-06-29 10:58:53 UTC (rev 1139)
+++ mrbs/trunk/web/upgrade/6/post.inc   2009-06-29 11:39:08 UTC (rev 1140)
@@ -13,9 +13,9 @@
 // then create it and populate it with existing admins defined in the config 
file
 if ($r == 0)
 {
-  // Default is '1' because we will assume all existing entries in the 
database are ordinary
-  // users.   In a moment we will go through the admins and upgrade them.
-  $r = sql_command("ALTER TABLE $tbl_users ADD COLUMN level smallint DEFAULT 
'1' NOT NULL ".sql_syntax_addcolumn_after("id"), $admin_handle);
+  // Default is '0' because we want to play safe and give no rights.
+  // In a moment we will go through the table and add users and admins.
+  $r = sql_command("ALTER TABLE $tbl_users ADD COLUMN level smallint DEFAULT 
'0' NOT NULL ".sql_syntax_addcolumn_after("id"), $admin_handle);
   if ($r == -1)
   {
     // No need to localize this: Only the admin running this for the first 
time would see it.
@@ -24,6 +24,14 @@
     exit();
   }
   
+  // Assuming that all existing entries in the users table are at least users, 
+  // make them all Level 1
+  $sql = "UPDATE $tbl_users SET level=1";
+  if (sql_command($sql) < 0)
+  {
+    fatal_error(0, "Error adding users. " . sql_error());
+  }
+  
   // Now populate the table with the existing admins
   foreach ($auth['admin'] as $admin_name)
   {


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

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to