[geeklog-cvs] geeklog: Auto-install new plugins during upgrade and migrate
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Fri May 1 10:03:07 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/cb14f78341a2
changeset: 7006:cb14f78341a2
user: Dirk Haun <dirk at haun-online.de>
date: Fri May 01 13:18:23 2009 +0200
description:
Auto-install new plugins during upgrade and migrate
diffstat:
3 files changed, 74 insertions(+)
public_html/admin/install/index.php | 6 ++
public_html/admin/install/lib-upgrade.php | 65 +++++++++++++++++++++++++++++
public_html/admin/install/migrate.php | 3 +
diffs (104 lines):
diff -r fc202669ac90 -r cb14f78341a2 public_html/admin/install/index.php
--- a/public_html/admin/install/index.php Fri May 01 11:23:44 2009 +0200
+++ b/public_html/admin/install/index.php Fri May 01 13:18:23 2009 +0200
@@ -591,6 +591,12 @@
!empty($_GET['install_plugins']))
? true
: false);
+
+ if (! $install_plugins) {
+ // if we don't do the manual selection, install all new plugins now
+ INST_autoinstallNewPlugins();
+ }
+
$next_link = ($install_plugins
? 'install-plugins.php?language=' . $language
: 'success.php?type=' . $install_type
diff -r fc202669ac90 -r cb14f78341a2 public_html/admin/install/lib-upgrade.php
--- a/public_html/admin/install/lib-upgrade.php Fri May 01 11:23:44 2009 +0200
+++ b/public_html/admin/install/lib-upgrade.php Fri May 01 13:18:23 2009 +0200
@@ -867,6 +867,71 @@
}
/**
+* Pick up and install any new plugins
+*
+* Search for plugins that exist in the filesystem but are not registered with
+* Geeklog. If they support auto install, install them now.
+*
+* @return void
+*
+*/
+function INST_autoinstallNewPlugins()
+{
+ global $_CONF, $_TABLES;
+
+ $newplugins = array();
+
+ clearstatcache ();
+ $plugins_dir = $_CONF['path'] . 'plugins/';
+ $fd = opendir($plugins_dir);
+ while (($plugin = @readdir($fd)) == TRUE) {
+
+ if (($plugin <> '.') && ($plugin <> '..') && ($plugin <> 'CVS') &&
+ (substr($plugin, 0, 1) <> '.') &&
+ (substr($plugin, 0, 1) <> '_') &&
+ is_dir($plugins_dir . $plugin)) {
+
+ if (DB_count($_TABLES['plugins'], 'pi_name', $plugin) == 0) {
+
+ // found a new plugin: remember name, keep on searching
+ $newplugins[] = $plugin;
+
+ }
+ }
+ }
+
+ // automatically install all new plugins that come with a autoinstall.php
+ foreach ($newplugins as $pi_name) {
+ $plugin_inst = $_CONF['path'] . 'plugins/' . $pi_name
+ . '/autoinstall.php';
+ if (file_exists($plugin_inst)) {
+
+ require_once $plugin_inst;
+
+ $check_compatible = 'plugin_compatible_with_this_version_'
+ . $pi_name;
+ if (function_exists($check_compatible)) {
+ if (! $check_compatible($pi_name)) {
+ continue; // with next plugin
+ }
+ }
+
+ $auto_install = 'plugin_autoinstall_' . $pi_name;
+ if (! function_exists($auto_install)) {
+ continue; // with next plugin
+ }
+
+ $inst_parms = $auto_install($pi_name);
+ if (($inst_parms === false) || empty($inst_parms)) {
+ continue; // with next plugin
+ }
+
+ INST_pluginAutoinstall($pi_name, $inst_parms);
+ }
+ }
+}
+
+/**
* Make sure optional config options can be disabled
*
* Back when Geeklog used a config.php file, some of the comment options were
diff -r fc202669ac90 -r cb14f78341a2 public_html/admin/install/migrate.php
--- a/public_html/admin/install/migrate.php Fri May 01 11:23:44 2009 +0200
+++ b/public_html/admin/install/migrate.php Fri May 01 13:18:23 2009 +0200
@@ -840,6 +840,9 @@
}
+ // finally, check for any new plugins and install them
+ INST_autoinstallNewPlugins();
+
/**
* Check for other missing files
* e.g. images/articles, images/topics, images/userphotos
More information about the geeklog-cvs
mailing list