[geeklog-cvs] geeklog: Fixed Spam-X upgrade problems dealing with adding confi...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Wed Mar 7 12:35:10 EST 2012


changeset 8510:0b0cce8f8c25
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0b0cce8f8c25
user: Tom <websitemaster at cogeco.net>
date: Wed Mar 07 12:29:15 2012 -0500
description:
Fixed Spam-X upgrade problems dealing with adding configuration options. Fixed missing security for new modules tab.

diffstat:

 plugins/spamx/autoinstall.php       |   6 +++-
 plugins/spamx/functions.inc         |  43 ++++++++++++++++++++++++------------
 plugins/spamx/install_updates.php   |   3 +-
 plugins/spamx/sql/mssql_updates.php |  36 ++++++++++++++++++++++++++----
 plugins/spamx/sql/mysql_updates.php |  36 ++++++++++++++++++++++++++----
 plugins/spamx/sql/pgsql_updates.php |  36 ++++++++++++++++++++++++++----
 6 files changed, 127 insertions(+), 33 deletions(-)

diffs (257 lines):

diff -r 245755bb01df -r 0b0cce8f8c25 plugins/spamx/autoinstall.php
--- a/plugins/spamx/autoinstall.php	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/autoinstall.php	Wed Mar 07 12:29:15 2012 -0500
@@ -64,12 +64,14 @@
     $features = array(
         $pi_name . '.admin'                 => 'Full access to ' . $pi_display_name . ' plugin',
         $pi_name . '.skip'                  =>  'Skip checking posts for Spam', 
-        'config.' . $pi_name . '.tab_main'  => 'Access to configure Spam-x main settings'
+        'config.' . $pi_name . '.tab_main'  => 'Access to configure Spam-x main settings',
+        'config.' . $pi_name . '.tab_modules'  => 'Access to configure Spam-x modules'
     );
 
     $mappings = array(
         $pi_name . '.admin'                 => array($pi_admin),
-        'config.' . $pi_name . '.tab_main'  => array($pi_admin)
+        'config.' . $pi_name . '.tab_main'  => array($pi_admin),
+        'config.' . $pi_name . '.tab_modules'  => array($pi_admin)
     );
 
     $tables = array(
diff -r 245755bb01df -r 0b0cce8f8c25 plugins/spamx/functions.inc
--- a/plugins/spamx/functions.inc	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/functions.inc	Wed Mar 07 12:29:15 2012 -0500
@@ -235,20 +235,22 @@
                 }
             }            
 
-            // Remove admin override since not needed anymore
-            $c = config::get_instance();
-            $c->del('admin_override', 'spamx');
-
-            // late fix: ensure 'notification_email' option can be disabled
-            $result = DB_query("SELECT value, default_value FROM {$_TABLES['conf_values']} WHERE name = 'notification_email' AND group_name = 'spamx'");
-            list($value, $default_value) = DB_fetchArray($result);
-            if ($value != 'unset') {
-                if (substr($default_value, 0, 6) != 'unset:') {
-                    $unset = addslashes('unset:' . $default_value);
-                    DB_query("UPDATE {$_TABLES['conf_values']} SET default_value = '$unset' WHERE name = 'notification_email' AND group_name = 'spamx'");
+            if (! $current_config) {
+                // Remove admin override since not needed anymore
+                $c = config::get_instance();
+                $c->del('admin_override', 'spamx');
+    
+                // late fix: ensure 'notification_email' option can be disabled
+                $result = DB_query("SELECT value, default_value FROM {$_TABLES['conf_values']} WHERE name = 'notification_email' AND group_name = 'spamx'");
+                list($value, $default_value) = DB_fetchArray($result);
+                if ($value != 'unset') {
+                    if (substr($default_value, 0, 6) != 'unset:') {
+                        $unset = addslashes('unset:' . $default_value);
+                        DB_query("UPDATE {$_TABLES['conf_values']} SET default_value = '$unset' WHERE name = 'notification_email' AND group_name = 'spamx'");
+                    }
                 }
             }
-
+            
             $current_version = '1.2.1';
             break;
 
@@ -262,9 +264,9 @@
 
             if (! $current_config) {
                 spamx_update_ConfValues_1_2_1();  
-
-                spamx_update_ConfigSecurity_1_2_1();
             }
+            
+            spamx_update_ConfigSecurity_1_2_1();
 
             $current_version = '1.2.2';
             break;
@@ -278,8 +280,19 @@
             }            
 
             if (! $current_config) {
-                spamx_update_ConfValues_1_2_2();  
+                // Update to Config Tables must be performed here and not in regualar SQL update array since if config is current then they shouldn't be run   
+                // Set new Tab column to whatever fieldset is
+                $sql = "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'spamx'";
+                DB_query($sql);
+                
+                // Rename the action config option since it is causes JavaScript issues in the config and IE 8
+                $sql = "UPDATE {$_TABLES['conf_values']} SET name = 'spamx_name' WHERE name = 'action'";
+                DB_query($sql);   
+                
+                spamx_update_ConfValues_1_2_2();
             }
+            
+            spamx_update_ConfigSecurity_1_2_2();
 
             $current_version = '1.3.0';
             break;            
diff -r 245755bb01df -r 0b0cce8f8c25 plugins/spamx/install_updates.php
--- a/plugins/spamx/install_updates.php	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/install_updates.php	Wed Mar 07 12:29:15 2012 -0500
@@ -17,7 +17,8 @@
 function spamx_update_ConfValues_1_2_2()
 {
     global $_CONF, $_SPX_DEFAULT;
-
+    
+    // Now add in new Config options
     require_once $_CONF['path_system'] . 'classes/config.class.php';
     
     $c = config::get_instance();
diff -r 245755bb01df -r 0b0cce8f8c25 plugins/spamx/sql/mssql_updates.php
--- a/plugins/spamx/sql/mssql_updates.php	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/sql/mssql_updates.php	Wed Mar 07 12:29:15 2012 -0500
@@ -40,11 +40,11 @@
     ),
     
     '1.2.1' => array(
-        // Set new Tab column to whatever fieldset is
-        "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'spamx'",   
-        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)", 
-        // Rename the action config option since it is causes JavaScript issues in the config and IE 8
-        "UPDATE {$_TABLES['conf_values']} SET name = 'spamx_name' WHERE name = 'action'"        
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)" 
+    ),
+
+    '1.2.2' => array(
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_modules', 'Access to configure Spam-x modules', 0)" 
     )    
     
 );
@@ -75,4 +75,30 @@
 
 }
 
+/**
+ * Add in new security rights for the Group "Spamx Admin"
+ *
+ */
+function spamx_update_ConfigSecurity_1_2_2()
+{
+    global $_TABLES;
+    
+    // Add in security rights for Spam-x Admin
+    $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                            "grp_name = 'Spamx Admin'");
+
+    if ($group_id > 0) {
+        $ft_names[] = 'config.spamx.tab_modules';
+        
+        foreach ($ft_names as $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 245755bb01df -r 0b0cce8f8c25 plugins/spamx/sql/mysql_updates.php
--- a/plugins/spamx/sql/mysql_updates.php	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/sql/mysql_updates.php	Wed Mar 07 12:29:15 2012 -0500
@@ -40,11 +40,11 @@
     ),
     
     '1.2.1' => array(
-        // Set new Tab column to whatever fieldset is
-        "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'spamx'",   
-        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)",
-        // Rename the action config option since it is causes JavaScript issues in the config and IE 8
-        "UPDATE {$_TABLES['conf_values']} SET name = 'spamx_name' WHERE name = 'action'"
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)"
+    ),
+
+    '1.2.2' => array(
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_modules', 'Access to configure Spam-x modules', 0)" 
     )    
     
 );
@@ -75,4 +75,30 @@
 
 }
 
+/**
+ * Add in new security rights for the Group "Spamx Admin"
+ *
+ */
+function spamx_update_ConfigSecurity_1_2_2()
+{
+    global $_TABLES;
+    
+    // Add in security rights for Spam-x Admin
+    $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                            "grp_name = 'Spamx Admin'");
+
+    if ($group_id > 0) {
+        $ft_names[] = 'config.spamx.tab_modules';
+        
+        foreach ($ft_names as $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 245755bb01df -r 0b0cce8f8c25 plugins/spamx/sql/pgsql_updates.php
--- a/plugins/spamx/sql/pgsql_updates.php	Fri Mar 02 22:45:43 2012 +0100
+++ b/plugins/spamx/sql/pgsql_updates.php	Wed Mar 07 12:29:15 2012 -0500
@@ -35,11 +35,11 @@
 $_UPDATES = array(
     
     '1.2.1' => array(
-        // Set new Tab column to whatever fieldset is
-        "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'spamx'",   
-        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)", 
-        // Rename the action config option since it is causes JavaScript issues in the config and IE 8
-        "UPDATE {$_TABLES['conf_values']} SET name = 'spamx_name' WHERE name = 'action'"        
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_main', 'Access to configure Spam-x main settings', 0)" 
+    ),
+
+    '1.2.2' => array(
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.spamx.tab_modules', 'Access to configure Spam-x modules', 0)" 
     )    
     
 );
@@ -70,4 +70,30 @@
 
 }
 
+/**
+ * Add in new security rights for the Group "Spamx Admin"
+ *
+ */
+function spamx_update_ConfigSecurity_1_2_2()
+{
+    global $_TABLES;
+    
+    // Add in security rights for Spam-x Admin
+    $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                            "grp_name = 'Spamx Admin'");
+
+    if ($group_id > 0) {
+        $ft_names[] = 'config.spamx.tab_modules';
+        
+        foreach ($ft_names as $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