From e1a125cdd9aafec0ac3048b72405fd3cba0378d3 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 4 Jul 2008 08:41:31 +0000 Subject: [PATCH 1/1] Allow plugins to specify that other plugins are incompatible with it in the info() function - in the required_plugins array therein, the incompatible plugin name as array key and value of SQ_INCOMPATIBLE. See upcoming release of the add_address plugin for an example. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13214 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/plugin.php | 41 +++++++++++++++++++++++++++++------------ src/configtest.php | 10 ++++++++-- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/functions/plugin.php b/functions/plugin.php index 7dc3f4b0..0697a283 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -759,13 +759,15 @@ function get_plugin_requirement($plugin_name, $requirement, * which might vary per the value of $do_parse * as well as if the plugin requires a SquirrelMail * core plugin, in which case it is "CORE" or - * "CORE:1.5.2" or similar), 'activate' - value is - * boolean: TRUE indicates that the plugin must - * also be activated, FALSE means that it only - * needs to be present, but does not need to be - * activated. Note that the return value might - * be an empty array, indicating that the plugin - * has no dependencies. + * "CORE:1.5.2" or similar, or, if the plugin is + * actually incompatible (not required) with this + * one, the constant SQ_INCOMPATIBLE will be found + * here), 'activate' - value is boolean: TRUE + * indicates that the plugin must also be activated, + * FALSE means that it only needs to be present, + * but does not need to be activated. Note that + * the return value might be an empty array, + * indicating that the plugin has no dependencies. * */ function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE, @@ -817,7 +819,7 @@ function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE, // parse version into something we understand? // - if ($do_parse) + if ($do_parse && $plugin_requirements['version'] != SQ_INCOMPATIBLE) { // massage version number into something we understand @@ -911,10 +913,12 @@ function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE, * corresponding values) will be available: * 'version' - value is the minimum version * required for that plugin (in printable, non- - * parsed format), 'activate' - value is boolean: - * TRUE indicates that the plugin must also be - * activated, FALSE means that it only needs to - * be present, but does not need to be activated. + * parsed format) or the constant SQ_INCOMPATIBLE, + * which indicates that the plugin is actually + * incompatible (not required), 'activate' - value + * is boolean: TRUE indicates that the plugin must + * also be activated, FALSE means that it only needs + * to be present, but does not need to be activated. * */ function check_plugin_dependencies($plugin_name, $force_inclusion = FALSE) @@ -965,6 +969,19 @@ function check_plugin_dependencies($plugin_name, $force_inclusion = FALSE) } + // if the plugin is actually incompatible; check that it + // is not activated + // + if ($depend_requirements['version'] == SQ_INCOMPATIBLE) + { + + if (is_plugin_enabled($depend_name)) + $missing_or_bad[$depend_name] = $depend_requirements; + + continue; + + } + // check for normal plugins // $version = explode('.', $depend_requirements['version'], 3); diff --git a/src/configtest.php b/src/configtest.php index 55c7314f..306dbe4a 100644 --- a/src/configtest.php +++ b/src/configtest.php @@ -490,10 +490,16 @@ if (isset($plugins[0])) { } else if (is_array($failed_dependencies)) { $missing_plugins = ''; + $incompatible_plugins = ''; foreach ($failed_dependencies as $depend_name => $depend_requirements) { - $missing_plugins .= ', ' . $depend_name . ' (version ' . $depend_requirements['version'] . ', ' . ($depend_requirements['activate'] ? 'must be activated' : 'need not be activated') . ')'; + if ($depend_requirements['version'] == SQ_INCOMPATIBLE) + $incompatible_plugins .= ', ' . $depend_name; + else + $missing_plugins .= ', ' . $depend_name . ' (version ' . $depend_requirements['version'] . ', ' . ($depend_requirements['activate'] ? 'must be activated' : 'need not be activated') . ')'; } - do_err($name . ' is missing some dependencies: ' . trim($missing_plugins, ', '), FALSE); + $error_string = (!empty($incompatible_plugins) ? $name . ' cannot be activated at the same time as the following plugins: ' . trim($incompatible_plugins, ', ') : '') + . (!empty($missing_plugins) ? (!empty($incompatible_plugins) ? '. ' . $name . ' is also ' : $name . ' is ') . 'missing some dependencies: ' . trim($missing_plugins, ', ') : ''); + do_err($error_string, FALSE); } } -- 2.25.1