[geeklog-cvs] geeklog: Implemented Spam-X autoinstall and upgrade
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:26 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/35e3270f5456
changeset: 6600:35e3270f5456
user: Dirk Haun <dirk at haun-online.de>
date: Sun Dec 28 00:39:41 2008 +0100
description:
Implemented Spam-X autoinstall and upgrade
diffstat:
5 files changed, 143 insertions(+), 364 deletions(-)
plugins/spamx/autoinstall.php | 109 ++++++++
plugins/spamx/functions.inc | 37 ++
plugins/spamx/sql/mssql_install.php | 8
plugins/spamx/sql/mysql_install.php | 8
public_html/admin/plugins/spamx/install.php | 345 ---------------------------
diffs (truncated from 601 to 300 lines):
diff -r 1f6f00948537 -r 35e3270f5456 plugins/spamx/autoinstall.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/spamx/autoinstall.php Sun Dec 28 00:39:41 2008 +0100
@@ -0,0 +1,109 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Spam-X Plugin 1.2 |
+// +---------------------------------------------------------------------------+
+// | 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_spamx($pi_name)
+{
+ $pi_name = 'spamx';
+ $pi_display_name = 'Spam-X';
+ $pi_admin = $pi_name . ' Admin';
+
+ $info = array(
+ 'pi_name' => $pi_name,
+ 'pi_display_name' => $pi_display_name,
+ 'pi_version' => '1.2.0',
+ 'pi_gl_version' => '1.6.0',
+ 'pi_homepage' => 'http://www.pigstye.net/gplugs/staticpages/index.php/spamx'
+ );
+
+ $groups = array(
+ $pi_admin => 'Users in this group can administer the '
+ . $pi_display_name . ' plugin'
+ );
+
+ $features = array(
+ $pi_name . '.admint' => 'Full access to ' . $pi_display_name
+ .' plugin'
+ );
+
+ $mappings = array(
+ $pi_name . '.admin' => array($pi_admin)
+ );
+
+ $tables = array(
+ 'spamx'
+ );
+
+ $inst_parms = array(
+ 'info' => $info,
+ 'groups' => $groups,
+ 'features' => $features,
+ 'mappings' => $mappings,
+ 'tables' => $tables
+ );
+
+ return $inst_parms;
+}
+
+function plugin_load_configuration_spamx($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_spamx();
+}
+
+function plugin_postinstall_spamx($pi_name)
+{
+ return true;
+}
+
+function plugin_compatible_with_this_version_spamx($pi_name)
+{
+ if (! function_exists('PLG_spamAction')) {
+ return false;
+ }
+
+ if (! function_exists('SEC_createToken')) {
+ return false;
+ }
+
+ if (! function_exists('COM_showMessageText')) {
+ return false;
+ }
+
+ return true;
+}
+
+?>
diff -r 1f6f00948537 -r 35e3270f5456 plugins/spamx/functions.inc
--- a/plugins/spamx/functions.inc Sat Dec 27 22:22:41 2008 +0100
+++ b/plugins/spamx/functions.inc Sun Dec 28 00:39:41 2008 +0100
@@ -10,7 +10,6 @@
*
* Licensed under GNU General Public License
*
- * $Id: functions.inc,v 1.37 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.inc') !== false) {
@@ -39,7 +38,6 @@
$_SPX_CONF = $spx_config->get_config('spamx');
}
-$_SPX_CONF['version'] = '1.1.1';
// +---------------------------------------------------------------------------+
// | Geeklog Plugin API Implementations |
@@ -146,11 +144,15 @@
*
* @return string plugin version
*/
-function plugin_chkVersion_spamx ()
+function plugin_chkVersion_spamx()
{
- global $_SPX_CONF;
+ global $_CONF;
- return $_SPX_CONF['version'];
+ require_once $_CONF['path'] . 'plugins/spamx/autoinstall.php';
+
+ $inst_parms = plugin_autoinstall_spamx('spamx');
+
+ return $inst_parms['info']['pi_version'];
}
/**
@@ -161,15 +163,28 @@
*/
function plugin_upgrade_spamx()
{
- // 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 = 'spamx'");
+ $code_version = plugin_chkVersion_spamx();
+ if ($installed_version == $code_version) {
+ // nothing to do
+ return true;
+ }
+
+ require_once $_CONF['path'] . 'plugins/spamx/autoinstall.php';
+
+ if (! plugin_compatible_with_this_version_spamx('spamx')) {
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_spamx('spamx');
+ $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 = 'spamx'");
+
+ return true;
}
/**
diff -r 1f6f00948537 -r 35e3270f5456 plugins/spamx/sql/mssql_install.php
--- a/plugins/spamx/sql/mssql_install.php Sat Dec 27 22:22:41 2008 +0100
+++ b/plugins/spamx/sql/mssql_install.php Sun Dec 28 00:39:41 2008 +0100
@@ -2,11 +2,11 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Spam-X Plugin 1.1 |
+// | Spam-X Plugin 1.2 |
// +---------------------------------------------------------------------------+
// | Installation SQL |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2004-2006 by the following authors: |
+// | Copyright (C) 2004-2008 by the following authors: |
// | |
// | Authors: Tom Willett - tomw AT pigstye DOT net |
// | Randy Kolenko - randy AT nextide DOT ca |
@@ -26,8 +26,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: mssql_install.php,v 1.1 2006/08/28 18:42:25 dhaun Exp $
$_SQL[] = "
CREATE TABLE [dbo].[{$_TABLES['spamx']}] (
@@ -36,4 +34,6 @@
) ON [PRIMARY]
";
+$DEFVALUES[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('spamx.counter', '0')";
+
?>
diff -r 1f6f00948537 -r 35e3270f5456 plugins/spamx/sql/mysql_install.php
--- a/plugins/spamx/sql/mysql_install.php Sat Dec 27 22:22:41 2008 +0100
+++ b/plugins/spamx/sql/mysql_install.php Sun Dec 28 00:39:41 2008 +0100
@@ -2,11 +2,11 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Spam-X Plugin 1.1 |
+// | Spam-X Plugin 1.2 |
// +---------------------------------------------------------------------------+
// | Installation SQL |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2004-2006 by the following authors: |
+// | Copyright (C) 2004-2008 by the following authors: |
// | |
// | Authors: Tom Willett - tomw AT pigstye DOT net |
// +---------------------------------------------------------------------------+
@@ -25,8 +25,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: mysql_install.php,v 1.1 2006/08/20 16:27:52 dhaun Exp $
$_SQL[] = "
CREATE TABLE {$_TABLES['spamx']} (
@@ -36,4 +34,6 @@
) TYPE=MyISAM
";
+$DEFVALUES[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('spamx.counter', '0')";
+
?>
diff -r 1f6f00948537 -r 35e3270f5456 public_html/admin/plugins/spamx/install.php
--- a/public_html/admin/plugins/spamx/install.php Sat Dec 27 22:22:41 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +0,0 @@
-<?php
-
-/* Reminder: always indent with 4 spaces (no tabs). */
-// +---------------------------------------------------------------------------+
-// | Spam-X plugin 1.1 |
-// +---------------------------------------------------------------------------+
-// | install.php |
-// | |
-// | This file installs and removes the data structures for the |
-// | Spam-X plugin for Geeklog. |
-// +---------------------------------------------------------------------------+
-// | Based on the Universal Plugin and prior work by the following authors: |
-// | |
-// | 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.26 2008/05/23 13:36:12 dhaun Exp $
-
-require_once '../../../lib-common.php';
-
-// Plugin information
-//
More information about the geeklog-cvs
mailing list