[geeklog-cvs] geeklog: Implemented Polls upgrade
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:32 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/9a4f84840886
changeset: 6604:9a4f84840886
user: Dirk Haun <dirk at haun-online.de>
date: Sun Dec 28 20:00:25 2008 +0100
description:
Implemented Polls upgrade
diffstat:
6 files changed, 121 insertions(+), 57 deletions(-)
plugins/polls/functions.inc | 47 +++++++++++++++++++++++++++++-----
plugins/polls/sql/mssql_updates.php | 40 ++++++++++++++++++++++++++++
plugins/polls/sql/mysql_updates.php | 40 ++++++++++++++++++++++++++++
public_html/admin/install/index.php | 8 -----
sql/updates/mssql_1.5.1_to_1.6.0.php | 21 ---------------
sql/updates/mysql_1.5.1_to_1.6.0.php | 22 ---------------
diffs (225 lines):
diff -r 6bf615c55b68 -r 9a4f84840886 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc Sun Dec 28 10:59:04 2008 +0100
+++ b/plugins/polls/functions.inc Sun Dec 28 20:00:25 2008 +0100
@@ -1111,15 +1111,50 @@
*/
function plugin_upgrade_polls()
{
- // the plugin needs these function so complain when they don't exist
- if (!function_exists('PLG_uninstall') ||
- !function_exists('COM_createLink')) {
+ global $_CONF, $_TABLES, $_DB_dbms;
+
+ $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
+ "pi_name = 'polls'");
+ $code_version = plugin_chkVersion_polls();
+ if ($installed_version == $code_version) {
+ // nothing to do
+ return true;
+ }
+
+ require_once $_CONF['path'] . 'plugins/polls/autoinstall.php';
+
+ if (! plugin_compatible_with_this_version_polls('polls')) {
return 3002;
}
- // upgrades are done by the install script - return a generic error
- COM_errorLog("Plugin upgrade function not implemented");
- return 3001;
+ $inst_parms = plugin_autoinstall_polls('polls');
+ $pi_gl_version = $inst_parms['info']['pi_gl_version'];
+
+ require_once $_CONF['path'] . 'plugins/polls/sql/'
+ . $_DB_dbms . '_updates.php';
+
+ $current_version = $installed_version;
+ $done = false;
+ while (! $done) {
+ switch ($current_version) {
+ case '2.0.1':
+ if (isset($_UPDATES[$current_version])) {
+ $_SQL = $_UPDATES[$current_version];
+ foreach ($_SQL as $sql) {
+ DB_query($sql);
+ }
+ }
+ $current_version = '2.1.0';
+ break;
+
+ default:
+ $done = true;
+ }
+ }
+
+ DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'polls'");
+
+ return true;
}
/**
diff -r 6bf615c55b68 -r 9a4f84840886 plugins/polls/sql/mssql_updates.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/polls/sql/mssql_updates.php Sun Dec 28 20:00:25 2008 +0100
@@ -0,0 +1,40 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Polls Plugin 2.1 |
+// +---------------------------------------------------------------------------+
+// | mssql_updates.php |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2008 by the following authors: |
+// | |
+// | Authors: Dirk Haun - dirk AT haun-online DOT de |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is licensed under the terms of the GNU General Public License|
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+// | See the GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+$_UPDATES = array(
+
+ '2.0.1' => array(
+ "ALTER TABLE {$_TABLES['pollanswers']} ALTER COLUMN [pid] VARCHARS(40)",
+ "ALTER TABLE {$_TABLES['pollquestions']} ALTER COLUMN [pid] VARCHARS(40)",
+ "ALTER TABLE {$_TABLES['polltopics']} ALTER COLUMN [pid] VARCHARS(40)",
+ "ALTER TABLE {$_TABLES['pollvoters']} ALTER COLUMN [pid] VARCHARS(40)"
+ )
+
+);
+
+?>
diff -r 6bf615c55b68 -r 9a4f84840886 plugins/polls/sql/mysql_updates.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/polls/sql/mysql_updates.php Sun Dec 28 20:00:25 2008 +0100
@@ -0,0 +1,40 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Polls Plugin 2.1 |
+// +---------------------------------------------------------------------------+
+// | mysql_updates.php |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2008 by the following authors: |
+// | |
+// | Authors: Dirk Haun - dirk AT haun-online DOT de |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is licensed under the terms of the GNU General Public License|
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+// | See the GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+$_UPDATES = array(
+
+ '2.0.1' => array(
+ "ALTER TABLE {$_TABLES['pollanswers']} CHANGE pid pid varchar(40) NOT NULL default ''",
+ "ALTER TABLE {$_TABLES['pollquestions']} CHANGE pid pid varchar(40) NOT NULL default ''",
+ "ALTER TABLE {$_TABLES['polltopics']} CHANGE pid pid varchar(40) NOT NULL default ''",
+ "ALTER TABLE {$_TABLES['pollvoters']} CHANGE pid pid varchar(40) NOT NULL default ''"
+ )
+
+);
+
+?>
diff -r 6bf615c55b68 -r 9a4f84840886 public_html/admin/install/index.php
--- a/public_html/admin/install/index.php Sun Dec 28 10:59:04 2008 +0100
+++ b/public_html/admin/install/index.php Sun Dec 28 20:00:25 2008 +0100
@@ -1409,14 +1409,6 @@
update_ConfValues();
- if (INST_pluginExists('polls')) {
- $check = upgrade_PollsPluginId();
- if (!$check) {
- echo "Error updating the polls";
- return false;
- }
- }
-
$current_gl_version = '1.6.0';
$_SQL = '';
break;
diff -r 6bf615c55b68 -r 9a4f84840886 sql/updates/mssql_1.5.1_to_1.6.0.php
--- a/sql/updates/mssql_1.5.1_to_1.6.0.php Sun Dec 28 10:59:04 2008 +0100
+++ b/sql/updates/mssql_1.5.1_to_1.6.0.php Sun Dec 28 20:00:25 2008 +0100
@@ -14,25 +14,4 @@
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 6bf615c55b68 -r 9a4f84840886 sql/updates/mysql_1.5.1_to_1.6.0.php
--- a/sql/updates/mysql_1.5.1_to_1.6.0.php Sun Dec 28 10:59:04 2008 +0100
+++ b/sql/updates/mysql_1.5.1_to_1.6.0.php Sun Dec 28 20:00:25 2008 +0100
@@ -14,26 +14,4 @@
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