Revision: 1134
http://mrbs.svn.sourceforge.net/mrbs/?rev=1134&view=rev
Author: jberanek
Date: 2009-06-26 14:08:28 +0000 (Fri, 26 Jun 2009)
Log Message:
-----------
* Moved code to add the 'level' column into the mrbs_users table
out of edit_users.php and into DB schema version 6 upgrade code.
* Fixed the name of the PostgreSQL upgrade SQL file for schema version 5.
Modified Paths:
--------------
mrbs/trunk/tables.my.sql
mrbs/trunk/tables.pg.73and_above.sql
mrbs/trunk/tables.pg.sql
mrbs/trunk/web/dbsys.inc
mrbs/trunk/web/edit_users.php
Added Paths:
-----------
mrbs/trunk/web/upgrade/5/pgsql.sql
mrbs/trunk/web/upgrade/6/
mrbs/trunk/web/upgrade/6/mysql.sql
mrbs/trunk/web/upgrade/6/pgsql.sql
mrbs/trunk/web/upgrade/6/post.inc
Removed Paths:
-------------
mrbs/trunk/web/upgrade/5/pgsql.inc
Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql 2009-06-25 22:52:56 UTC (rev 1133)
+++ mrbs/trunk/tables.my.sql 2009-06-26 14:08:28 UTC (rev 1134)
@@ -105,6 +105,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '5');
+ VALUES ( 'db_version', '6');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
Modified: mrbs/trunk/tables.pg.73and_above.sql
===================================================================
--- mrbs/trunk/tables.pg.73and_above.sql 2009-06-25 22:52:56 UTC (rev
1133)
+++ mrbs/trunk/tables.pg.73and_above.sql 2009-06-26 14:08:28 UTC (rev
1134)
@@ -111,6 +111,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '5');
+ VALUES ('db_version', '6');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql 2009-06-25 22:52:56 UTC (rev 1133)
+++ mrbs/trunk/tables.pg.sql 2009-06-26 14:08:28 UTC (rev 1134)
@@ -99,6 +99,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '5');
+ VALUES ('db_version', '6');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc 2009-06-25 22:52:56 UTC (rev 1133)
+++ mrbs/trunk/web/dbsys.inc 2009-06-26 14:08:28 UTC (rev 1134)
@@ -15,7 +15,7 @@
$tbl_variables = $db_tbl_prefix . "variables";
-$db_schema_version = 5;
+$db_schema_version = 6;
$local_db_schema_version = 1;
Modified: mrbs/trunk/web/edit_users.php
===================================================================
--- mrbs/trunk/web/edit_users.php 2009-06-25 22:52:56 UTC (rev 1133)
+++ mrbs/trunk/web/edit_users.php 2009-06-26 14:08:28 UTC (rev 1134)
@@ -88,33 +88,6 @@
// Get the list of fields in the table
get_fields();
-// If the 'level' field does not exist (as it won't if it was created pre-MRBS
1.4.2),
-// then create it and populate it with existing admins defined in the config
file
-if (!in_array('level', $fields))
-{
- // 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"));
- if ($r == -1)
- {
- // No need to localize this: Only the admin running this for the first
time would see it.
- print "<p class=\"error\">Error adding the 'level' column.</p>\n";
- print "<p class=\"error\">" . sql_error() . "</p>\n";
- exit();
- }
- get_fields();
-
- // Now populate the table with the existing admins
- foreach ($auth['admin'] as $admin_name)
- {
- $sql = "UPDATE $tbl_users SET level=2 WHERE
name='".addslashes($admin_name)."'";
- if (sql_command($sql) < 0)
- {
- fatal_error(0, "Error adding existing admins. " . sql_error());
- }
- }
-}
-
/* Get localized field name */
function get_loc_field_name($name)
{
Deleted: mrbs/trunk/web/upgrade/5/pgsql.inc
===================================================================
--- mrbs/trunk/web/upgrade/5/pgsql.inc 2009-06-25 22:52:56 UTC (rev 1133)
+++ mrbs/trunk/web/upgrade/5/pgsql.inc 2009-06-26 14:08:28 UTC (rev 1134)
@@ -1 +0,0 @@
--- $Id$
Copied: mrbs/trunk/web/upgrade/5/pgsql.sql (from rev 1131,
mrbs/trunk/web/upgrade/5/pgsql.inc)
===================================================================
--- mrbs/trunk/web/upgrade/5/pgsql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/5/pgsql.sql 2009-06-26 14:08:28 UTC (rev 1134)
@@ -0,0 +1 @@
+-- $Id$
Property changes on: mrbs/trunk/web/upgrade/5/pgsql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/6/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/6/mysql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/6/mysql.sql 2009-06-26 14:08:28 UTC (rev 1134)
@@ -0,0 +1 @@
+# $Id$
Property changes on: mrbs/trunk/web/upgrade/6/mysql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/6/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/6/pgsql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/6/pgsql.sql 2009-06-26 14:08:28 UTC (rev 1134)
@@ -0,0 +1 @@
+-- $Id$
Property changes on: mrbs/trunk/web/upgrade/6/pgsql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/6/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/6/post.inc (rev 0)
+++ mrbs/trunk/web/upgrade/6/post.inc 2009-06-26 14:08:28 UTC (rev 1134)
@@ -0,0 +1,42 @@
+<?php
+
+// $Id$
+
+global $admin_handle;
+global $tbl_users;
+global $auth;
+
+$r = sql_query("SELECT level FROM $tbl_users ".
+ sql_mysql_syntax_limit(0,1,$admin_handle));
+
+// If the 'level' field does not exist (as it won't if it was created pre-MRBS
1.4.2),
+// 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);
+ if ($r == -1)
+ {
+ // No need to localize this: Only the admin running this for the first
time would see it.
+ print "<p class=\"error\">Error adding the 'level' column.</p>\n";
+ print "<p class=\"error\">" . sql_error($admin_handle) . "</p>\n";
+ exit();
+ }
+
+ // Now populate the table with the existing admins
+ foreach ($auth['admin'] as $admin_name)
+ {
+ $sql = "UPDATE $tbl_users SET level=2 WHERE
name='".addslashes($admin_name)."'";
+ if (sql_command($sql) < 0)
+ {
+ fatal_error(0, "Error adding existing admins. " . sql_error());
+ }
+ }
+}
+else
+{
+ sql_free($r, $admin_handle);
+}
+
+?>
Property changes on: mrbs/trunk/web/upgrade/6/post.inc
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
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