[geeklog-cvs] geeklog: Implemented Static Pages autoinstall and upgrade

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


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/5216b7b7a5ae
changeset: 6601:5216b7b7a5ae
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Dec 28 10:11:54 2008 +0100
description:
Implemented Static Pages autoinstall and upgrade

diffstat:

3 files changed, 142 insertions(+), 367 deletions(-)
plugins/staticpages/autoinstall.php               |  116 ++++++
plugins/staticpages/functions.inc                 |   36 +-
public_html/admin/plugins/staticpages/install.php |  357 ---------------------

diffs (truncated from 552 to 300 lines):

diff -r 35e3270f5456 -r 5216b7b7a5ae plugins/staticpages/autoinstall.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/staticpages/autoinstall.php	Sun Dec 28 10:11:54 2008 +0100
@@ -0,0 +1,116 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Static Pages Plugin 1.6                                                   |
+// +---------------------------------------------------------------------------+
+// | autoinstall.php                                                           |
+// |                                                                           |
+// | This file provides helper functions for the automatic plugin install.     |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2008 by the following authors:                              |
+// |                                                                           |
+// | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
+// +---------------------------------------------------------------------------+
+// |                                                                           |
+// | This program is free software; you can redistribute it and/or             |
+// | modify it 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.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+function plugin_autoinstall_staticpages($pi_name)
+{
+    $pi_name         = 'staticpages';
+    $pi_display_name = 'Static Pages';
+    $pi_admin        = $pi_display_name . ' Admin';
+
+    $info = array(
+        'pi_name'         => $pi_name,
+        'pi_display_name' => $pi_display_name,
+        'pi_version'      => '1.6.0',
+        'pi_gl_version'   => '1.6.0',
+        'pi_homepage'     => 'http://www.geeklog.net/'
+    );
+
+    $groups = array(
+        $pi_admin => 'Users in this group can administer the '
+                     . $pi_display_name . ' plugin'
+    );
+
+    $features = array(
+        $pi_name . '.edit'      => 'Access to ' . $pi_display_name . ' editor',
+        $pi_name . '.delete'    => 'Ability to delete static pages',
+        $pi_name . '.PHP'       => 'Ability to use PHP in static pages'
+    );
+
+    $mappings = array(
+        $pi_name . '.edit'      => array($pi_admin),
+        $pi_name . '.delete'    => array($pi_admin)
+        // Note: 'staticpages.PHP' is not assigned to any group by default
+    );
+
+    $tables = array(
+        'staticpage'
+    );
+
+    $inst_parms = array(
+        'info'      => $info,
+        'groups'    => $groups,
+        'features'  => $features,
+        'mappings'  => $mappings,
+        'tables'    => $tables
+    );
+
+    return $inst_parms;
+}
+
+function plugin_load_configuration_staticpages($pi_name)
+{
+    global $_CONF;
+
+    $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
+
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+    require_once $base_path . 'install_defaults.php';
+
+    return plugin_initconfig_staticpages();
+}
+
+function plugin_postinstall_staticpages($pi_name)
+{
+    return true;
+}
+
+function plugin_compatible_with_this_version_staticpages($pi_name)
+{
+    if (! function_exists('SEC_getGroupDropdown')) {
+        return false;
+    }
+
+    if (! function_exists('SEC_createToken')) {
+        return false;
+    }
+
+    if (! function_exists('COM_showMessageText')) {
+        return false;
+    }
+
+    if (! function_exists('COM_setLangIdAndAttribute')) {
+        return false;
+    }
+
+    return true;
+}
+
+?>
diff -r 35e3270f5456 -r 5216b7b7a5ae plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Sun Dec 28 00:39:41 2008 +0100
+++ b/plugins/staticpages/functions.inc	Sun Dec 28 10:11:54 2008 +0100
@@ -2,7 +2,7 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Static Pages Plugin 1.5                                                   |
+// | Static Pages Plugin 1.6                                                   |
 // +---------------------------------------------------------------------------+
 // | functions.inc                                                             |
 // |                                                                           |
@@ -57,7 +57,6 @@
     $_SP_CONF = $sp_config->get_config('staticpages');
 }
 
-$_SP_CONF['version'] = '1.5.0';
 
 // +---------------------------------------------------------------------------+
 // | Plugin API - Services                                                     |
@@ -986,9 +985,13 @@
 */
 function plugin_chkVersion_staticpages()
 {
-    global $_SP_CONF;
+    global $_CONF;
 
-    return $_SP_CONF['version'];
+    require_once $_CONF['path'] . 'plugins/staticpages/autoinstall.php';
+ 
+    $inst_parms = plugin_autoinstall_staticpages('staticpages');
+ 
+    return $inst_parms['info']['pi_version'];
 }
 
 /**
@@ -1053,15 +1056,28 @@
 */
 function plugin_upgrade_staticpages()
 {
-    // the plugin needs these function so complain when they don't exist
-    if (!function_exists('PLG_uninstall') ||
-            !function_exists('COM_createLink')) {
+    global $_CONF, $_TABLES;
+
+    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
+                                    "pi_name = 'staticpages'");
+    $code_version = plugin_chkVersion_staticpages();
+    if ($installed_version == $code_version) {
+        // nothing to do
+        return true;
+    }
+
+    require_once $_CONF['path'] . 'plugins/staticpages/autoinstall.php';
+    
+    if (! plugin_compatible_with_this_version_staticpages('staticpages')) {
         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_staticpages('staticpages');
+    $pi_gl_version = $inst_parms['info']['pi_gl_version'];
+
+    DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'staticpages'");
+
+    return true;
 }
 
 
diff -r 35e3270f5456 -r 5216b7b7a5ae public_html/admin/plugins/staticpages/install.php
--- a/public_html/admin/plugins/staticpages/install.php	Sun Dec 28 00:39:41 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-<?php
-
-/* Reminder: always indent with 4 spaces (no tabs). */
-// +---------------------------------------------------------------------------+
-// | Static Pages Plugin 1.5                                                   |
-// +---------------------------------------------------------------------------+
-// | install.php                                                               |
-// |                                                                           |
-// | This file installs and removes the data structures for the                |
-// | Static pages plugin for Geeklog.                                          |
-// +---------------------------------------------------------------------------+
-// | Based on the Universal Plugin and prior work by the following authors:    |
-// | Upgraded for GL version 1.5 online config manager                         |
-// |                                                                           |
-// | Copyright (C) 2002-2008 by the following authors:                         |
-// |                                                                           |
-// | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
-// |          Tom Willett       - tom AT pigstye DOT net                       |
-// |          Blaine Lang       - blaine AT portalparts DOT com                |
-// |          Dirk Haun         - dirk AT haun-online DOT de                   |
-// |          Vincent Furia     - vinny01 AT users DOT sourceforge DOT net     |
-// +---------------------------------------------------------------------------+
-// |                                                                           |
-// | This program is free software; you can redistribute it and/or             |
-// | modify it 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.           |
-// |                                                                           |
-// +---------------------------------------------------------------------------+
-//
-// $Id: install.php,v 1.33 2008/05/23 13:36:12 dhaun Exp $
-
-require_once '../../../lib-common.php';
-
-// Plugin information
-//
-// ----------------------------------------------------------------------------
-//
-$pi_display_name = 'Static Page';
-$pi_name         = 'staticpages';
-$pi_version      = '1.5.0';
-$gl_version      = '1.5.0';
-$pi_url          = 'http://www.geeklog.net/';
-
-$base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
-
-// name of the Admin group
-$pi_admin        = $pi_display_name . ' Admin';
-
-// the plugin's groups - assumes first group to be the Admin group
-$GROUPS = array();
-$GROUPS[$pi_admin] = 'Users in this group can administer the Static Pages plugin';
-
-$FEATURES = array();
-$FEATURES['staticpages.edit']    = 'Access to Static Pages editor';
-$FEATURES['staticpages.delete']  = 'Ability to delete static pages';
-$FEATURES['staticpages.PHP']     = 'Ability use PHP in static pages';
-
-$MAPPINGS = array();
-$MAPPINGS['staticpages.edit']       = array ($pi_admin);
-$MAPPINGS['staticpages.delete']     = array ($pi_admin);
-// Note: 'staticpages.PHP' is not assigned to any group by default
-
-// (optional) data to pre-populate tables with
-// Insert table name and sql to insert default data for your plugin.
-// Note: '#group#' will be replaced with the id of the plugin's admin group.
-$DEFVALUES = array();
-// no default data
-
-/**
-* Checks the requirements for this plugin and if it is compatible with this
-* version of Geeklog.
-*
-* @return   boolean     true = proceed with install, false = not compatible
-*
-*/
-function plugin_compatible_with_this_geeklog_version()
-{
-    if (!function_exists('SEC_getGroupDropdown')) {
-        return false;
-    }
-
-    if (!function_exists('SEC_createToken')) {
-        return false;
-    }
-
-    if (!function_exists('COM_showMessageText')) {
-        return false;
-    }
-
-    if (!function_exists('COM_setLangIdAndAttribute')) {
-        return false;
-    }
-
-    return true;
-}



More information about the geeklog-cvs mailing list