[geeklog-cvs] geeklog: Implemented Calendar upgrade

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:17 EST 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/a0f2b65c1957
changeset: 6595:a0f2b65c1957
user:      Dirk Haun <dirk at haun-online.de>
date:      Fri Dec 26 19:31:15 2008 +0100
description:
Implemented Calendar upgrade

diffstat:

6 files changed, 131 insertions(+), 26 deletions(-)
plugins/calendar/autoinstall.php       |   10 +++--
plugins/calendar/functions.inc         |   57 ++++++++++++++++++++++++--------
plugins/calendar/sql/mssql_install.php |    9 ++---
plugins/calendar/sql/mssql_updates.php |   37 ++++++++++++++++++++
plugins/calendar/sql/mysql_install.php |    7 +--
plugins/calendar/sql/mysql_updates.php |   37 ++++++++++++++++++++

diffs (276 lines):

diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/autoinstall.php
--- a/plugins/calendar/autoinstall.php	Fri Dec 26 15:58:22 2008 +0100
+++ b/plugins/calendar/autoinstall.php	Fri Dec 26 19:31:15 2008 +0100
@@ -2,7 +2,7 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Calendar plugin 1.1 for Geeklog                                           |
+// | Calendar Plugin 1.1                                                       |
 // +---------------------------------------------------------------------------+
 // | autoinstall.php                                                           |
 // |                                                                           |
@@ -100,12 +100,16 @@
         // plugin on Geeklog 1.4.0 or older - sorry, but that won't work
         return false;
     }   
-    
+
     if (!function_exists('MBYTE_strpos')) {
         // the plugin requires the multi-byte functions
         return false; 
     }   
-    
+
+    if (!function_exists('COM_createLink')) {
+        return false;
+    }
+
     if (!function_exists('SEC_createToken')) {
         return false;
     }
diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc	Fri Dec 26 15:58:22 2008 +0100
+++ b/plugins/calendar/functions.inc	Fri Dec 26 19:31:15 2008 +0100
@@ -2,7 +2,7 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Calendar Plugin 1.0                                                       |
+// | Calendar Plugin 1.1                                                       |
 // +---------------------------------------------------------------------------+
 // | functions.inc                                                             |
 // |                                                                           |
@@ -57,7 +57,6 @@
     $_CA_CONF = $ca_config->get_config('calendar');
 }
 
-$_CA_CONF['version'] = '1.1.0';
 
 // +---------------------------------------------------------------------------+
 // | Geeklog Plugin API Implementations                                        |
@@ -1419,9 +1418,13 @@
 */
 function plugin_chkVersion_calendar()
 {
-    global $_CA_CONF;
+    global $_CONF;
 
-    return $_CA_CONF['version'];
+    require_once $_CONF['path'] . 'plugins/calendar/autoinstall.php';
+
+    $inst_parms = plugin_autoinstall_calendar('calendar');
+
+    return $inst_parms['info']['pi_version'];
 }
 
 /**
@@ -1432,24 +1435,50 @@
 */
 function plugin_upgrade_calendar()
 {
-    global $_TABLES, $_CA_CONF;
+    global $_CONF, $_TABLES, $_DB_dbms;
 
-    $version = DB_getItem($_TABLES['plugins'], 'pi_version',
-                          "pi_name = 'calendar'");
-    if ($version == $_CA_CONF['version']) {
+    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
+                                    "pi_name = 'calendar'");
+    $code_version = plugin_chkVersion_calendar();
+    if ($installed_version == $code_version) {
         // nothing to do
         return true;
     }
 
-    // the plugin needs these function so complain when they don't exist
-    if (!function_exists('PLG_uninstall') ||
-            !function_exists('COM_createLink')) {
+    require_once $_CONF['path'] . 'plugins/calendar/autoinstall.php';
+
+    if (! plugin_compatible_with_this_version_calendar('calendar')) {
         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_calendar('calendar');
+    $pi_gl_version = $inst_parms['info']['pi_gl_version'];
+
+    require_once $_CONF['path'] . 'plugins/calendar/sql/'
+                                . $_DB_dbms . '_updates.php';
+
+    $current_version = $installed_version;
+    $done = false;
+    while (! $done) {
+        switch ($current_version) {
+        case '1.0.2':
+            if (isset($_UPDATES[$current_version])) {
+                $_SQL = $_UPDATES[$current_version];
+                foreach ($_SQL as $sql) {
+                    DB_query($sql);
+                }
+            }
+            $current_version = '1.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 = 'calendar'");
+
+    return true;
 }
 
 /**
diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/sql/mssql_install.php
--- a/plugins/calendar/sql/mssql_install.php	Fri Dec 26 15:58:22 2008 +0100
+++ b/plugins/calendar/sql/mssql_install.php	Fri Dec 26 19:31:15 2008 +0100
@@ -2,9 +2,9 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Calendar Plugin 1.0                                                       |
+// | Calendar Plugin 1.1                                                       |
 // +---------------------------------------------------------------------------+
-// | Installation SQL                                                          |
+// | mssql_install.php                                                         |
 // +---------------------------------------------------------------------------+
 // | Copyright (C) 2000-2008 by the following authors:                         |
 // |                                                                           |
@@ -30,8 +30,6 @@
 // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
 // |                                                                           |
 // +---------------------------------------------------------------------------+
-//
-// $Id: mssql_install.php,v 1.6 2008/08/12 18:13:33 mjervis Exp $
 
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['events']}] (
@@ -58,7 +56,8 @@
     [event_type] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     [location] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     [timestart] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
-    [timeend] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
+    [timeend] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
+    [in_transit] [tinyint] NULL
 ) ON [PRIMARY]
 ";
 
diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/sql/mssql_updates.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/calendar/sql/mssql_updates.php	Fri Dec 26 19:31:15 2008 +0100
@@ -0,0 +1,37 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Calendar Plugin 1.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(
+
+    '1.0.2' => array(
+        "ALTER TABLE {$_TABLES['events']} ADD in_transit tinyint NULL"
+    )
+
+);
+
+?>
diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/sql/mysql_install.php
--- a/plugins/calendar/sql/mysql_install.php	Fri Dec 26 15:58:22 2008 +0100
+++ b/plugins/calendar/sql/mysql_install.php	Fri Dec 26 19:31:15 2008 +0100
@@ -2,9 +2,9 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Calendar Plugin 1.0                                                       |
+// | Calendar Plugin 1.1                                                       |
 // +---------------------------------------------------------------------------+
-// | Installation SQL                                                          |
+// | mysql_install.php                                                         |
 // +---------------------------------------------------------------------------+
 // | Copyright (C) 2000-2008 by the following authors:                         |
 // |                                                                           |
@@ -29,8 +29,6 @@
 // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
 // |                                                                           |
 // +---------------------------------------------------------------------------+
-//
-// $Id: mysql_install.php,v 1.3 2008/05/02 12:08:07 dhaun Exp $
 
 $_SQL[] = "
 CREATE TABLE {$_TABLES['events']} (
@@ -58,6 +56,7 @@
   location varchar(128) default NULL,
   timestart time default NULL,
   timeend time default NULL,
+  in_transit tinyint(1) unsigned default '0',
   INDEX events_eid(eid),
   INDEX events_event_type(event_type),
   INDEX events_datestart(datestart),
diff -r 7fd9bfe6d53f -r a0f2b65c1957 plugins/calendar/sql/mysql_updates.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/calendar/sql/mysql_updates.php	Fri Dec 26 19:31:15 2008 +0100
@@ -0,0 +1,37 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Calendar Plugin 1.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(
+
+    '1.0.2' => array(
+        "ALTER TABLE {$_TABLES['events']} ADD in_transit tinyint(1) unsigned default '0' AFTER timeend"
+    )
+
+);
+
+?>



More information about the geeklog-cvs mailing list