[geeklog-cvs] geeklog: Third batch of fixes for bug #0001354 (MS SQL only)

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun May 29 13:19:54 EDT 2011


changeset 8296:56c5d725b1ce
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/56c5d725b1ce
user: Dirk Haun <dirk at haun-online.de>
date: Sun May 29 18:52:39 2011 +0200
description:
Third batch of fixes for bug #0001354 (MS SQL only)

diffstat:

 plugins/calendar/sql/mssql_updates.php    |   29 ++-
 plugins/links/sql/mssql_updates.php       |   72 +++++++-
 plugins/polls/sql/mssql_updates.php       |   68 ++++++-
 plugins/staticpages/sql/mssql_updates.php |    6 +
 sql/updates/mssql_1.4.1_to_1.5.0.php      |  294 ------------------------------
 sql/updates/mssql_1.5.1_to_1.5.2.php      |   12 -
 6 files changed, 166 insertions(+), 315 deletions(-)

diffs (truncated from 590 to 300 lines):

diff -r 6dcd3e4fe59a -r 56c5d725b1ce plugins/calendar/sql/mssql_updates.php
--- a/plugins/calendar/sql/mssql_updates.php	Sun May 29 18:00:00 2011 +0200
+++ b/plugins/calendar/sql/mssql_updates.php	Sun May 29 18:52:39 2011 +0200
@@ -6,7 +6,7 @@
 // +---------------------------------------------------------------------------+
 // | Upgrade SQL                                                               |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors:                              |
+// | Copyright (C) 2009-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Dirk Haun        - dirk AT haun-online DOT de                    |
 // +---------------------------------------------------------------------------+
@@ -34,6 +34,12 @@
 
 $_UPDATES = array(
 
+    '1.0.0' => array(
+        "ALTER TABLE {$_TABLES['events']} ALTER COLUMN [state] varchar(40)",
+        "ALTER TABLE {$_TABLES['eventsubmission']} ALTER COLUMN [state] varchar(40)",
+        "ALTER TABLE {$_TABLES['personal_events']} ALTER COLUMN [state] varchar(40)"
+    ),
+
     '1.1.0' => array(
         "ALTER TABLE {$_TABLES['eventsubmission']} ADD [owner_id] [numeric](8, 0) NULL AFTER timeend"
     ),
@@ -49,6 +55,27 @@
 );
 
 /**
+* Replace the old $_STATES array with a free-form text field
+*
+*/
+function calendar_update_move_states()
+{
+    global $_TABLES, $_STATES;
+
+    if (isset($_STATES) && is_array($_STATES)) {
+        $tables = array($_TABLES['events'], $_TABLES['eventsubmission'],
+                        $_TABLES['personal_events']);
+
+        foreach ($_STATES as $key => $state) {
+            foreach ($tables as $table) {
+                DB_change($table, 'state', addslashes($state),
+                                  'state', addslashes($key));
+            }
+        }
+    }
+}
+
+/**
  * Add is new security rights for the Group "Calendar Admin"
  *
  */
diff -r 6dcd3e4fe59a -r 56c5d725b1ce plugins/links/sql/mssql_updates.php
--- a/plugins/links/sql/mssql_updates.php	Sun May 29 18:00:00 2011 +0200
+++ b/plugins/links/sql/mssql_updates.php	Sun May 29 18:52:39 2011 +0200
@@ -2,11 +2,11 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Links Plugin 2.0                                                          |
+// | Links Plugin 2.1                                                          |
 // +---------------------------------------------------------------------------+
 // | Installation SQL                                                          |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2010 by the following authors:                         |
+// | Copyright (C) 2000-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
 // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
@@ -39,6 +39,34 @@
 
 $_UPDATES = array(
 
+    '1.0.1' => array(
+        "CREATE TABLE [dbo].[{$_TABLES['linkcategories']}] (
+          [cid] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+          [pid] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+          [category] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+          [description] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
+          [tid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
+          [created] [datetime] NULL ,
+          [modified] [datetime] NULL ,
+          [owner_id] [numeric](8, 0) NOT NULL ,
+          [group_id] [numeric](8, 0) NOT NULL ,
+          [perm_owner] [tinyint] NOT NULL ,
+          [perm_group] [tinyint] NOT NULL ,
+          [perm_members] [tinyint] NOT NULL ,
+          [perm_anon] [tinyint] NOT NULL
+        ) ON [PRIMARY]",
+        "ALTER TABLE [dbo].[{$_TABLES['linkcategories']}] ADD
+          CONSTRAINT [PK_{$_TABLES['linkcategories']}] PRIMARY KEY  CLUSTERED
+          (
+            [pid]
+          )  ON [PRIMARY]",
+        "ALTER TABLE {$_TABLES['linksubmission']} ADD owner_id INTEGER NOT NULL default '1'",
+        "EXEC sp_rename '{$_TABLES['linksubmission']}.category', 'cid', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['linksubmission']} ALTER COLUMN [cid] varchar(32) NOT NULL",
+        "EXEC sp_rename '{$_TABLES['links']}.category', 'cid', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['links']} ALTER COLUMN [cid] varchar(32) NOT NULL"
+    ),
+
     '2.1.0' => array(
         // Set new Tab column to whatever fieldset is
         "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'links'",   
@@ -52,6 +80,46 @@
 );
 
 /**
+* Add "root" category and fix categories
+*
+*/
+function links_update_set_categories()
+{
+    global $_TABLES, $_LI_CONF;
+
+    if (empty($_LI_CONF['root'])) {
+        $_LI_CONF['root'] = 'site';
+    }
+    $root = addslashes($_LI_CONF['root']);
+
+    DB_query("INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$root}', 'root', 'Root', 'Website root', NULL, NOW(), NOW(), 5, 2, 3, 3, 2, 2)");
+
+    // get Links admin group number
+    $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                           "grp_name = 'Links Admin'");
+
+    // loop through adding to category table, then update links table with cids
+    $result = DB_query("SELECT DISTINCT cid AS category FROM {$_TABLES['links']}");
+    $nrows = DB_numRows($result);
+    for ($i = 0; $i < $nrows; $i++) {
+
+        $A = DB_fetchArray($result);
+        $category = addslashes($A['category']);
+        $cid = $category;
+        $sql = "INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,description,tid,owner_id,group_id,created,modified, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$cid}','{$root}','{$category}','{$category}','all',2,'{$group_id}',NOW(),NOW(), 3, 3, 2, 2)";
+        DB_query($sql,0);
+        if ($cid != $category) { // still experimenting ...
+            $sql = "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$category}'";
+            DB_query($sql,0);
+        }
+        if (DB_error()) {
+            echo "Error inserting categories into linkcategories table";
+            return false;
+        }
+    }
+}
+
+/**
  * Add is new security rights for the Group "Links Admin"
  *
  */
diff -r 6dcd3e4fe59a -r 56c5d725b1ce plugins/polls/sql/mssql_updates.php
--- a/plugins/polls/sql/mssql_updates.php	Sun May 29 18:00:00 2011 +0200
+++ b/plugins/polls/sql/mssql_updates.php	Sun May 29 18:52:39 2011 +0200
@@ -6,7 +6,7 @@
 // +---------------------------------------------------------------------------+
 // | mssql_updates.php                                                         |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2008-2010 by the following authors:                         |
+// | Copyright (C) 2008-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
 // +---------------------------------------------------------------------------+
@@ -34,6 +34,34 @@
 
 $_UPDATES = array(
 
+    '1.1.0' => array(
+        "ALTER TABLE {$_TABLES['pollquestions']} DROP CONSTRAINT [PK_gl_pollquestions];",
+        "EXEC sp_rename '{$_TABLES['pollquestions']}', '{$_TABLES['polltopics']}'",
+        "EXEC sp_rename '{$_TABLES['polltopics']}.question', 'topic', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['polltopics']} ALTER COLUMN [topic] VARCHAR( 255 ) NULL",
+        "EXEC sp_rename '{$_TABLES['polltopics']}.qid', 'pid', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['polltopics']} ADD questions int default '0' NOT NULL",
+        "ALTER TABLE {$_TABLES['polltopics']} ADD is_open tinyint NOT NULL default '1'",
+        "ALTER TABLE {$_TABLES['polltopics']} ADD hideresults tinyint NOT NULL default '0'",
+        "EXEC sp_rename '{$_TABLES['pollanswers']}.qid', 'pid', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['pollanswers']} ADD qid VARCHAR(20) NOT NULL default '0'",
+        "ALTER TABLE {$_TABLES['pollanswers']} DROP CONSTRAINT [PK_gl_pollanswers];",
+        "ALTER TABLE {$_TABLES['pollanswers']} ADD CONSTRAINT [PK_{$_TABLES['pollanswers']}] PRIMARY KEY CLUSTERED ([pid], [qid], [aid]) ON [PRIMARY];",
+        "EXEC sp_rename '{$_TABLES['pollvoters']}.qid', 'pid', 'COLUMN'",
+        "ALTER TABLE {$_TABLES['pollvoters']} ALTER COLUMN [pid] VARCHAR( 20 ) NOT NULL",
+        "CREATE TABLE [dbo].[{$_TABLES['pollquestions']}] (
+          [qid] [int] NOT NULL DEFAULT 0,
+          [pid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+          [question] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
+          CONSTRAINT [PK_{$_TABLES['pollquestions']}] PRIMARY KEY  CLUSTERED
+	      (
+		    [qid]
+	      )  ON [PRIMARY]
+        ) ON [PRIMARY]",
+        // in 1.4.1, "don't display poll" was equivalent to "closed"
+        "UPDATE {$_TABLES['polltopics']} SET is_open = 0 WHERE display = 0"
+    ),
+
     '2.1.0' => array(
         // These pid changes should have happened when upgrading from 2.0.2
         // to 2.1.0 but were previously listed for an upgrade from 2.0.1 and
@@ -53,21 +81,49 @@
 
         "EXEC sp_rename '{$_TABLES['polltopics']}.date', 'created', 'COLUMN'",
         "ALTER TABLE {$_TABLES['polltopics']} ADD modified [datetime] NULL AFTER created",
-        "UPDATE {$_TABLES['polltopics']} SET modified = created"        
+        "UPDATE {$_TABLES['polltopics']} SET modified = created"
     ),
 
     '2.1.2' => array(
         // Set new Tab column to whatever fieldset is
-        "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'polls'",   
+        "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'polls'",
         "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.polls.tab_whatsnew', 'Access to configure polls what\'s new block', 0)",
         "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.polls.tab_main', 'Access to configure general polls settings', 0)",
         "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.polls.tab_permissions', 'Access to configure polls default permissions', 0)",
-        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.polls.tab_autotag_permissions', 'Access to configure polls autotag usage permissions', 0)"        
-    )    
-    
+        "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('config.polls.tab_autotag_permissions', 'Access to configure polls autotag usage permissions', 0)"
+    )
+
 );
 
 /**
+* Hook up pollquestions with polltopics
+*
+*/
+function polls_update_polltopics()
+{
+    global $_TABLES;
+
+    $P_SQL = array();
+
+    $move_sql = "SELECT pid, topic FROM {$_TABLES['polltopics']}";
+    $move_rst = DB_query($move_sql);
+    $count_move = DB_numRows($move_rst);
+    for ($i = 0; $i < $count_move; $i++) {
+        $A = DB_fetchArray($move_rst);
+        $A[1] = str_replace("'", "''", $A[1]);
+        $P_SQL[] = "INSERT INTO {$_TABLES['pollquestions']} (pid, question) VALUES ('{$A[0]}','{$A[1]}');";
+    }
+
+    foreach ($P_SQL as $sql) {
+        $rst = DB_query($sql);
+        if (DB_error()) {
+            echo "There was an error upgrading the polls, SQL: $sql<br>";
+            return false;
+        }
+    }
+}
+
+/**
  * Add is new security rights for the Group "Polls Admin"
  *
  */
diff -r 6dcd3e4fe59a -r 56c5d725b1ce plugins/staticpages/sql/mssql_updates.php
--- a/plugins/staticpages/sql/mssql_updates.php	Sun May 29 18:00:00 2011 +0200
+++ b/plugins/staticpages/sql/mssql_updates.php	Sun May 29 18:52:39 2011 +0200
@@ -34,6 +34,12 @@
 
 $_UPDATES = array(
 
+    '1.4.3' => array(
+        "ALTER TABLE {$_TABLES['staticpage']} ADD [commentcode] TINYINT NOT NULL default '0'",
+        // disable comments on all existing static pages
+        "UPDATE {$_TABLES['staticpage']} SET commentcode = -1"
+    ),
+
     '1.6.0' => array(
         "ALTER TABLE {$_TABLES['staticpage']} ADD meta_description [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL AFTER commentcode, ADD meta_keywords [meta_keywords] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL AFTER meta_description"
     ),
diff -r 6dcd3e4fe59a -r 56c5d725b1ce sql/updates/mssql_1.4.1_to_1.5.0.php
--- a/sql/updates/mssql_1.4.1_to_1.5.0.php	Sun May 29 18:00:00 2011 +0200
+++ b/sql/updates/mssql_1.4.1_to_1.5.0.php	Sun May 29 18:52:39 2011 +0200
@@ -383,300 +383,6 @@
     $c->add('atom_max_stories',     10, 'text',   7, 40, 0, 1860, TRUE);
 }
 
-// Polls plugin updates
-function upgrade_PollsPlugin()
-{
-    global $_CONF, $_TABLES;
-
-    require_once $_CONF['path_system'] . 'classes/config.class.php';
-
-    $plugin_path = $_CONF['path'] . 'plugins/polls/';
-    require_once $plugin_path . 'install_defaults.php';
-
-    if (file_exists($plugin_path . 'config.php')) {
-        global $_DB_table_prefix, $_PO_CONF;
-
-        require_once $plugin_path . 'config.php';
-    }
-
-    if (!plugin_initconfig_polls()) {
-        echo 'There was an error upgrading the Polls plugin';
-        return false;
-    }
-
-    $P_SQL = array();
-    //$P_SQL[] = "ALTER TABLE {$_TABLES['polltopics']} RENAME TO {$_TABLES['pollquestions']};";



More information about the geeklog-cvs mailing list