[geeklog-cvs] geeklog: Extended length of poll IDs to 40 characters (feature r...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Nov 16 07:18:41 EST 2008


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/035dfc00117c
changeset: 6471:035dfc00117c
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Nov 16 13:12:09 2008 +0100
description:
Extended length of poll IDs to 40 characters (feature request #0000754)

diffstat:

8 files changed, 75 insertions(+), 13 deletions(-)
plugins/polls/sql/mssql_install.php            |    8 ++++----
plugins/polls/sql/mysql_install.php            |   14 +++++++-------
plugins/polls/templates/admin/polleditor.thtml |    2 +-
public_html/admin/install/index.php            |    8 ++++++++
public_html/docs/history                       |    1 +
public_html/docs/theme.html                    |   12 +++++++++++-
sql/updates/mssql_1.5.1_to_1.5.2.php           |   21 +++++++++++++++++++++
sql/updates/mysql_1.5.1_to_1.5.2.php           |   22 ++++++++++++++++++++++

diffs (203 lines):

diff -r 1ffedc7146eb -r 035dfc00117c plugins/polls/sql/mssql_install.php
--- a/plugins/polls/sql/mssql_install.php	Sun Nov 16 10:30:00 2008 +0100
+++ b/plugins/polls/sql/mssql_install.php	Sun Nov 16 13:12:09 2008 +0100
@@ -35,7 +35,7 @@
 
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['pollanswers']}] (
-    [pid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+    [pid] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [qid] [int] NOT NULL ,
     [aid] [tinyint] NOT NULL ,
     [answer] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
@@ -47,14 +47,14 @@
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['pollquestions']}] (
     [qid] [int] NOT NULL ,
-    [pid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+    [pid] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [question] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
 ) ON [PRIMARY]
 ";
 
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['polltopics']}] (
-    [pid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+    [pid] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [topic] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     [voters] [numeric](8, 0) NULL ,
     [questions] [int] NOT NULL ,
@@ -76,7 +76,7 @@
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['pollvoters']}] (
     [id] [numeric](10, 0) IDENTITY (1, 1) NOT NULL ,
-    [pid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+    [pid] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [ipaddress] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [date] [numeric](10, 0) NULL
 ) ON [PRIMARY]
diff -r 1ffedc7146eb -r 035dfc00117c plugins/polls/sql/mysql_install.php
--- a/plugins/polls/sql/mysql_install.php	Sun Nov 16 10:30:00 2008 +0100
+++ b/plugins/polls/sql/mysql_install.php	Sun Nov 16 13:12:09 2008 +0100
@@ -34,7 +34,7 @@
 
 $_SQL[] = "
 CREATE TABLE {$_TABLES['pollanswers']} (
-  pid varchar(20) NOT NULL default '',
+  pid varchar(40) NOT NULL default '',
   qid mediumint(9) NOT NULL default 0,
   aid tinyint(3) unsigned NOT NULL default '0',
   answer varchar(255) default NULL,
@@ -46,16 +46,16 @@
 
 $_SQL[] = "
 CREATE TABLE {$_TABLES['pollquestions']} (
-    qid mediumint(9) NOT NULL DEFAULT '0',
-    pid varchar(20) NOT NULL,
-    question varchar(255) NOT NULL,
-    PRIMARY KEY (qid, pid)
+  qid mediumint(9) NOT NULL DEFAULT '0',
+  pid varchar(40) NOT NULL default '',
+  question varchar(255) NOT NULL,
+  PRIMARY KEY (qid, pid)
 ) TYPE=MyISAM
 ";
 
 $_SQL[] = "
 CREATE TABLE {$_TABLES['polltopics']} (
-  pid varchar(20) NOT NULL,
+  pid varchar(40) NOT NULL default '',
   topic varchar(255) default NULL,
   voters mediumint(8) unsigned default NULL,
   questions int(11) NOT NULL default '0',
@@ -83,7 +83,7 @@
 $_SQL[] = "
 CREATE TABLE {$_TABLES['pollvoters']} (
   id int(10) unsigned NOT NULL auto_increment,
-  pid varchar(20) NOT NULL default '',
+  pid varchar(20) NOT NULL,
   ipaddress varchar(15) NOT NULL default '',
   date int(10) unsigned default NULL,
   PRIMARY KEY  (id)
diff -r 1ffedc7146eb -r 035dfc00117c plugins/polls/templates/admin/polleditor.thtml
--- a/plugins/polls/templates/admin/polleditor.thtml	Sun Nov 16 10:30:00 2008 +0100
+++ b/plugins/polls/templates/admin/polleditor.thtml	Sun Nov 16 13:12:09 2008 +0100
@@ -4,7 +4,7 @@
                                     <table cellspacing="0" cellpadding="2" width="100%">
                                         <tr>
                                             <td align="right">{lang_pollid}:</td>
-                                            <td><input type="text" dir="ltr" name="pid" value="{poll_id}" size="20" maxlength="20"{xhtml}> {lang_donotusespaces}</td>
+                                            <td><input type="text" dir="ltr" name="pid" value="{poll_id}" size="40" maxlength="40"{xhtml}> {lang_donotusespaces}</td>
                                         </tr>
                                         <tr>
                                             <td align="right">{lang_topic}:</td>
diff -r 1ffedc7146eb -r 035dfc00117c public_html/admin/install/index.php
--- a/public_html/admin/install/index.php	Sun Nov 16 10:30:00 2008 +0100
+++ b/public_html/admin/install/index.php	Sun Nov 16 13:12:09 2008 +0100
@@ -1373,6 +1373,14 @@
 
             update_ConfValues();
 
+            if (INST_pluginExists('polls')) {
+                $check = upgrade_PollsPluginId();
+                if (!$check) {
+                    echo "Error updating the polls";
+                    return false;
+                }
+            }
+
             $current_gl_version = '1.5.2';
             $_SQL = '';
             break;
diff -r 1ffedc7146eb -r 035dfc00117c public_html/docs/history
--- a/public_html/docs/history	Sun Nov 16 10:30:00 2008 +0100
+++ b/public_html/docs/history	Sun Nov 16 13:12:09 2008 +0100
@@ -59,6 +59,7 @@
 
 Polls plugin
 ------------
+- Extended length of poll IDs to 40 characters (feature request #0000754) [Dirk]
 - Fixed SQL error when poll questions contained single quotes (bug #0000756)
   [Dirk]
 - Fixed handling of poll IDs in Polls editor (bug #0000753) [Dirk]
diff -r 1ffedc7146eb -r 035dfc00117c public_html/docs/theme.html
--- a/public_html/docs/theme.html	Sun Nov 16 10:30:00 2008 +0100
+++ b/public_html/docs/theme.html	Sun Nov 16 13:12:09 2008 +0100
@@ -195,7 +195,17 @@
 </ol>
 
 
-<h2><a name="changes">Theme changes in Geeklog 1.5.1</a></h2>
+<h2><a name="changes">Theme changes in Geeklog 1.5.2</a></h2>
+
+<h3>Plugins</h3>
+
+<ul>
+<li>The template file for the Polls editor has been changed to allow up to 40
+    characters for the poll id (pid):
+    <tt>plugins/polls/templates/admin/polleditor.thtml</tt></li>
+</ul>
+
+<h2><a name="changes151">Theme changes in Geeklog 1.5.1</a></h2>
 
 <p>Note: Themes made for Geeklog 1.5.0 are mostly compatible with Geeklog 1.5.1. We only made one mandatory change (for the Configuration admin panel) - all the other changes listed below are optional or adjustments for special setups (e.g. multi-language sites, right-to-left languages). See details below.</p>
 
diff -r 1ffedc7146eb -r 035dfc00117c sql/updates/mssql_1.5.1_to_1.5.2.php
--- a/sql/updates/mssql_1.5.1_to_1.5.2.php	Sun Nov 16 10:30:00 2008 +0100
+++ b/sql/updates/mssql_1.5.1_to_1.5.2.php	Sun Nov 16 13:12:09 2008 +0100
@@ -14,4 +14,25 @@
     return true;
 }
 
+function upgrade_PollsPluginId()
+{
+    global $_TABLES;
+
+    $P_SQL = array();
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollanswers']} ALTER COLUMN [pid] VARCHARS(40)";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollquestions']} ALTER COLUMN [pid] VARCHARS(40)";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['polltopics']} ALTER COLUMN [pid] VARCHARS(40)";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollvoters']} ALTER COLUMN [pid] VARCHARS(40)";
+
+    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;
+        }
+    }
+
+    return true;
+}
+
 ?>
diff -r 1ffedc7146eb -r 035dfc00117c sql/updates/mysql_1.5.1_to_1.5.2.php
--- a/sql/updates/mysql_1.5.1_to_1.5.2.php	Sun Nov 16 10:30:00 2008 +0100
+++ b/sql/updates/mysql_1.5.1_to_1.5.2.php	Sun Nov 16 13:12:09 2008 +0100
@@ -14,4 +14,26 @@
     return true;
 }
 
+function upgrade_PollsPluginId()
+{
+    global $_TABLES;
+
+    $P_SQL = array();
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollanswers']} CHANGE pid pid varchar(40) NOT NULL default ''";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollquestions']} CHANGE pid pid varchar(40) NOT NULL default ''";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['polltopics']} CHANGE pid pid varchar(40) NOT NULL default ''";
+    $P_SQL[] = "ALTER TABLE {$_TABLES['pollvoters']} CHANGE pid pid varchar(40) NOT NULL default ''";
+
+    $P_SQL = INST_checkInnodbUpgrade($P_SQL);
+    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;
+        }
+    }
+
+    return true;
+}
+
 ?>



More information about the geeklog-cvs mailing list