Add ability for plugin to indicate that they are not compatible with a particular...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 6 May 2007 03:33:23 +0000 (03:33 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 6 May 2007 03:33:23 +0000 (03:33 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12367 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/plugin.php
src/configtest.php

index 7dbda95f283d85d46e8b26e6ac578fb280695862..dfaefd72901c5e11b81cd678ac50bdb206423750 100644 (file)
@@ -562,8 +562,11 @@ function check_plugin_version($plugin_name,
   *
   * @return mixed NULL is returned if the plugin could not be 
   *               found or does not include the given requirement,
-  *               otherwise the value of the requirement is returned,
-  *               whatever that may be (varies per requirement type).
+  *               the string "INCOMPATIBLE" is returned if the
+  *               given plugin is entirely incompatible with the
+  *               current SquirrelMail version, otherwise the 
+  *               value of the requirement is returned, whatever 
+  *               that may be (varies per requirement type).
   *
   */
 function get_plugin_requirement($plugin_name, $requirement, 
@@ -657,29 +660,33 @@ function get_plugin_requirement($plugin_name, $requirement,
       foreach ($plugin_info['per_version_requirements'] as $version => $requirement_overrides)
       {
 
-          $version_array = explode('.', $version);
-          if (sizeof($version_array) != 3) continue;
-
-          $a = $version_array[0];
-          $b = $version_array[1];
-          $c = $version_array[2];
-
-          if (check_sm_version($a, $b, $c) 
-           && isset($requirement_overrides[$requirement])
-           && !is_null($requirement_overrides[$requirement]))
-          {
-
-             if (empty($highest_version_array)
-              || $highest_version_array[0] < $a
-              || ($highest_version_array[0] == $a
-              && $highest_version_array[1] < $b)
-              || ($highest_version_array[0] == $a 
-              && $highest_version_array[1] == $b 
-              && $highest_version_array[2] < $c))
-             {
-                $highest_version_array = $version_array;
-                $requirement_value_override = $requirement_overrides[$requirement];
-             }
+         $version_array = explode('.', $version);
+         if (sizeof($version_array) != 3) continue;
+
+         $a = $version_array[0];
+         $b = $version_array[1];
+         $c = $version_array[2];
+
+         if (check_sm_version($a, $b, $c) 
+          && ( !empty($requirement_overrides['INCOMPATIBLE']) 
+          || (isset($requirement_overrides[$requirement])
+          && !is_null($requirement_overrides[$requirement]))))
+         {
+
+            if (empty($highest_version_array)
+             || $highest_version_array[0] < $a
+             || ($highest_version_array[0] == $a
+             && $highest_version_array[1] < $b)
+             || ($highest_version_array[0] == $a 
+             && $highest_version_array[1] == $b 
+             && $highest_version_array[2] < $c))
+            {
+               $highest_version_array = $version_array;
+               if (!empty($requirement_overrides['INCOMPATIBLE']))
+                  $requirement_value_override = 'INCOMPATIBLE';
+               else
+                  $requirement_value_override = $requirement_overrides[$requirement];
+            }
 
          }
 
@@ -739,20 +746,23 @@ function get_plugin_requirement($plugin_name, $requirement,
   * @return mixed Boolean FALSE is returned if the plugin
   *               could not be found or does not indicate
   *               whether it has other plugin dependencies, 
+  *               the string "INCOMPATIBLE" is returned if 
+  *               the given plugin is entirely incompatible 
+  *               with the current SquirrelMail version, 
   *               otherwise an array is returned where keys 
-  *               are the names of required plugin dependencies,
-  *               and values are arrays again, where at least
-  *               the following keys (and corresponding values)
-  *               will be available: 'version' - value is the
-  *               minimum version required for that plugin (the
-  *               format of which might vary per the value of
-  *               $do_parse), '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.
+  *               are the names of required plugin 
+  *               dependencies, and values are arrays again, 
+  *               where at least the following keys (and 
+  *               corresponding values) will be available: 
+  *               'version' - value is the minimum version 
+  *               required for that plugin (the format of 
+  *               which might vary per the value of $do_parse), 
+  *               '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, 
@@ -763,6 +773,11 @@ function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE,
                                                  'required_plugins', 
                                                  $force_inclusion);
 
+   // the plugin is simply incompatible, no need to continue here
+   //
+   if ($plugin_dependencies === 'INCOMPATIBLE')
+      return $plugin_dependencies;
+
 
    // not an array of requirements?  wrong format, just return FALSE
    //
@@ -871,6 +886,9 @@ function get_plugin_dependencies($plugin_name, $force_inclusion = FALSE,
   *
   * @return mixed Boolean TRUE if all of the plugin's 
   *               required plugins are correctly installed,
+  *               the string "INCOMPATIBLE" is returned if 
+  *               the given plugin is entirely incompatible 
+  *               with the current SquirrelMail version, 
   *               otherwise an array of the required plugins
   *               that are either not installed or not up to
   *               the minimum required version.  The array is
@@ -890,6 +908,7 @@ function check_plugin_dependencies($plugin_name, $force_inclusion = FALSE)
 
    $dependencies = get_plugin_dependencies($plugin_name, $force_inclusion);
    if (!$dependencies) return TRUE;
+   if ($dependencies === 'INCOMPATIBLE') return $dependencies;
    $missing_or_bad = array();
 
    foreach ($dependencies as $depend_name => $depend_requirements)
index e57374d17b77a7f9cc0ad8825dfdcaaf426f05bd..92afb37578d3d82cf66cbba657ca0d856b8fab03 100644 (file)
@@ -410,7 +410,10 @@ if (isset($plugins[0])) {
         // dependencies and if they are satisfied
         //
         $failed_dependencies = check_plugin_dependencies($name);
-        if (is_array($failed_dependencies)) {
+        if ($failed_dependencies === 'INCOMPATIBLE') {
+            do_err($name . ' is NOT COMPATIBLE with this version of SquirrelMail', FALSE);
+        }
+        else if (is_array($failed_dependencies)) {
             $missing_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') . ')';