[geeklog-cvs] geeklog: Cleaning up a minor mess I left in everybody's database...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat Mar 26 14:26:46 EDT 2011
changeset 8197:2172d5808386
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/2172d5808386
user: Dirk Haun <dirk at haun-online.de>
date: Sat Mar 26 19:26:38 2011 +0100
description:
Cleaning up a minor mess I left in everybody's database 2 years ago when we already had an XMLSitemap Admin group for a while (unused, but never removed)
diffstat:
plugins/xmlsitemap/sql/mssql_updates.php | 57 ++++++++++++++++++++-----------
plugins/xmlsitemap/sql/mysql_updates.php | 56 ++++++++++++++++++++----------
plugins/xmlsitemap/sql/pgsql_updates.php | 58 ++++++++++++++++++++-----------
3 files changed, 112 insertions(+), 59 deletions(-)
diffs (truncated from 303 to 300 lines):
diff -r 8d1c0831ebd4 -r 2172d5808386 plugins/xmlsitemap/sql/mssql_updates.php
--- a/plugins/xmlsitemap/sql/mssql_updates.php Fri Mar 25 20:38:28 2011 +0100
+++ b/plugins/xmlsitemap/sql/mssql_updates.php Sat Mar 26 19:26:38 2011 +0100
@@ -4,9 +4,9 @@
// +---------------------------------------------------------------------------+
// | XMLSitemap Plugin 1.0 |
// +---------------------------------------------------------------------------+
-// | mysql_install.php |
+// | mssql_updates.php |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors: |
+// | Copyright (C) 2009-2011 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -34,19 +34,16 @@
*/
$_UPDATES = array(
-
+
'1.0.0' => array(
// Set new Tab column to whatever fieldset is
- "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
+ "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
- // Add new Core Admin Group for Configuration
- "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);",
-
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_main', 'Access to configure general XMLSitemap settings', 0)",
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_pri', 'Access to configure XMLSitemap priorities', 0)",
- "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
- )
-
+ "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
+ )
+
);
/**
@@ -56,29 +53,49 @@
function xmlsitemap_update_ConfigSecurity_1_0_0()
{
global $_TABLES;
-
+
// Add in security rights for XMLSitemap Admin
$group_id = DB_getItem($_TABLES['groups'], 'grp_id',
- "grp_name = 'XMLSitemap Admin'");
+ "grp_name = 'XMLSitemap Admin'");
+
+ /*
+ * For some time, from Geeklog 1.6.0 through to 1.7.0, we already had
+ * an XMLSitemap Admin group in the database. It was dropped in 1.7.1
+ * but not removed from the database. This is now coming back to haunt
+ * us ... We also need to remove the unused xmlsitemap.edit permission
+ * while we're at it.
+ */
+
+ if (empty($group_id)) { // cover: null, false, 0, etc. - doesn't exist yet
+ // Add new Core Admin Group for Configuration
+ DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);");
+ $group_id = DB_insertId();
+
+ // Assign XMLSitemap Admin group to Root group
+ DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id, NULL, 1)");
+ } else {
+ // if the XMLSitemap Admin group already exists, then there will
+ // probably also be a xmlsitemap.edit permission - remove it
+ SEC_removeFeatureFromDB('xmlsitemap.edit');
+ }
+
+ // now that we cleaned this up, add the new stuff
if ($group_id > 0) {
- // Assign XMLSitemap Group to Root Group
- DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id,NULL,1)");
-
$ft_names[] = 'config.xmlsitemap.tab_main';
$ft_names[] = 'config.xmlsitemap.tab_pri';
$ft_names[] = 'config.xmlsitemap.tab_freq';
-
+
foreach ($ft_names as $name) {
- $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$name'");
+ $ft_id = DB_getItem($_TABLES['features'], 'ft_id',
+ "ft_name = '$name'");
if ($ft_id > 0) {
$sql = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($ft_id, $group_id)";
DB_query($sql);
}
- }
- }
+ }
+ }
}
?>
-
diff -r 8d1c0831ebd4 -r 2172d5808386 plugins/xmlsitemap/sql/mysql_updates.php
--- a/plugins/xmlsitemap/sql/mysql_updates.php Fri Mar 25 20:38:28 2011 +0100
+++ b/plugins/xmlsitemap/sql/mysql_updates.php Sat Mar 26 19:26:38 2011 +0100
@@ -4,9 +4,9 @@
// +---------------------------------------------------------------------------+
// | XMLSitemap Plugin 1.0 |
// +---------------------------------------------------------------------------+
-// | mysql_install.php |
+// | mysql_updates.php |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors: |
+// | Copyright (C) 2009-2011 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -34,19 +34,16 @@
*/
$_UPDATES = array(
-
+
'1.0.0' => array(
// Set new Tab column to whatever fieldset is
- "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
+ "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
- // Add new Core Admin Group for Configuration
- "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);",
-
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_main', 'Access to configure general XMLSitemap settings', 0)",
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_pri', 'Access to configure XMLSitemap priorities', 0)",
- "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
- )
-
+ "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
+ )
+
);
/**
@@ -56,27 +53,48 @@
function xmlsitemap_update_ConfigSecurity_1_0_0()
{
global $_TABLES;
-
+
// Add in security rights for XMLSitemap Admin
$group_id = DB_getItem($_TABLES['groups'], 'grp_id',
- "grp_name = 'XMLSitemap Admin'");
+ "grp_name = 'XMLSitemap Admin'");
+
+ /*
+ * For some time, from Geeklog 1.6.0 through to 1.7.0, we already had
+ * an XMLSitemap Admin group in the database. It was dropped in 1.7.1
+ * but not removed from the database. This is now coming back to haunt
+ * us ... We also need to remove the unused xmlsitemap.edit permission
+ * while we're at it.
+ */
+
+ if (empty($group_id)) { // cover: null, false, 0, etc. - doesn't exist yet
+ // Add new Core Admin Group for Configuration
+ DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);");
+ $group_id = DB_insertId();
+
+ // Assign XMLSitemap Admin group to Root group
+ DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id, NULL, 1)");
+ } else {
+ // if the XMLSitemap Admin group already exists, then there will
+ // probably also be a xmlsitemap.edit permission - remove it
+ SEC_removeFeatureFromDB('xmlsitemap.edit');
+ }
+
+ // now that we cleaned this up, add the new stuff
if ($group_id > 0) {
- // Assign XMLSitemap Group to Root Group
- DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id,NULL,1)");
-
$ft_names[] = 'config.xmlsitemap.tab_main';
$ft_names[] = 'config.xmlsitemap.tab_pri';
$ft_names[] = 'config.xmlsitemap.tab_freq';
-
+
foreach ($ft_names as $name) {
- $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$name'");
+ $ft_id = DB_getItem($_TABLES['features'], 'ft_id',
+ "ft_name = '$name'");
if ($ft_id > 0) {
$sql = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($ft_id, $group_id)";
DB_query($sql);
}
- }
- }
+ }
+ }
}
diff -r 8d1c0831ebd4 -r 2172d5808386 plugins/xmlsitemap/sql/pgsql_updates.php
--- a/plugins/xmlsitemap/sql/pgsql_updates.php Fri Mar 25 20:38:28 2011 +0100
+++ b/plugins/xmlsitemap/sql/pgsql_updates.php Sat Mar 26 19:26:38 2011 +0100
@@ -4,9 +4,9 @@
// +---------------------------------------------------------------------------+
// | XMLSitemap Plugin 1.0 |
// +---------------------------------------------------------------------------+
-// | mysql_install.php |
+// | pgsql_updates.php |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors: |
+// | Copyright (C) 2009-2011 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -28,25 +28,22 @@
// +---------------------------------------------------------------------------+
/**
-* PG SQL updates
+* PostgreSQL updates
*
* @package XMLsitemap
*/
$_UPDATES = array(
-
+
'1.0.0' => array(
// Set new Tab column to whatever fieldset is
- "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
+ "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'xmlsitemap'",
- // Add new Core Admin Group for Configuration
- "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);",
-
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_main', 'Access to configure general XMLSitemap settings', 0)",
"INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_pri', 'Access to configure XMLSitemap priorities', 0)",
- "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
- )
-
+ "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.xmlsitemap.tab_freq', 'Access to configure XMLSitemap update frequency', 0)"
+ )
+
);
/**
@@ -56,27 +53,48 @@
function xmlsitemap_update_ConfigSecurity_1_0_0()
{
global $_TABLES;
-
+
// Add in security rights for XMLSitemap Admin
$group_id = DB_getItem($_TABLES['groups'], 'grp_id',
- "grp_name = 'XMLSitemap Admin'");
+ "grp_name = 'XMLSitemap Admin'");
+
+ /*
+ * For some time, from Geeklog 1.6.0 through to 1.7.0, we already had
+ * an XMLSitemap Admin group in the database. It was dropped in 1.7.1
+ * but not removed from the database. This is now coming back to haunt
+ * us ... We also need to remove the unused xmlsitemap.edit permission
+ * while we're at it.
+ */
+
+ if (empty($group_id)) { // cover: null, false, 0, etc. - doesn't exist yet
+ // Add new Core Admin Group for Configuration
+ DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);");
+ $group_id = DB_insertId();
+
+ // Assign XMLSitemap Admin group to Root group
+ DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id, NULL, 1)");
+ } else {
+ // if the XMLSitemap Admin group already exists, then there will
+ // probably also be a xmlsitemap.edit permission - remove it
+ SEC_removeFeatureFromDB('xmlsitemap.edit');
+ }
+
+ // now that we cleaned this up, add the new stuff
if ($group_id > 0) {
- // Assign XMLSitemap Group to Root Group
- DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ($group_id,NULL,1)");
-
$ft_names[] = 'config.xmlsitemap.tab_main';
$ft_names[] = 'config.xmlsitemap.tab_pri';
$ft_names[] = 'config.xmlsitemap.tab_freq';
-
+
foreach ($ft_names as $name) {
- $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$name'");
+ $ft_id = DB_getItem($_TABLES['features'], 'ft_id',
+ "ft_name = '$name'");
if ($ft_id > 0) {
$sql = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($ft_id, $group_id)";
DB_query($sql);
}
- }
- }
+ }
+ }
More information about the geeklog-cvs
mailing list