Compatibility plugin for SquirrelMail
=====================================
Ver 2.0, 2005/06/15

Original author: Paul Lesneiwski <pdontthink@angrynerds.com>
Original idea: Bruce Richardson <itsbruce@uklinux.net>



Description
===========

This plugin allows any other plugin access to the functions
and special variables needed to make it backward (and forward) 
compatible with most versions of SM in wide use.  This eliminates 
the need for duplication of certain functions throughout many plugins.

It also provides functionality that helps check that plugins 
have been installed and set up correctly.



Usage (Plugin Authors' Guide)
=============================

As of version 2.0 of this plugin, no special action is required
on the part of plugin developers to make their plugin backward
compatible via the Compatibility Plugin except in one case.  That
one special case is when a plugin includes its own custom options
page(s), this code should be placed at the top of any such files:


   define('SM_PATH', '../../');


   include_once(SM_PATH . 'plugins/compatibility/functions.php');


   if (compatibility_check_sm_version(1, 3))
   {
      include_once (SM_PATH . 'include/validate.php');
// only if needed      include_once (SM_PATH . 'include/load_prefs.php');
   }
   else
   {
      include_once ('../src/validate.php');
// only if needed      include_once ('../src/load_prefs.php');
   }


Otherwise, developers should use the most up-to-date SquirrelMail 
API and expect that their plugins will in most cases work with most
versions of SquirrelMail as long as users of older versions have 
downloaded this plugin and added its patch.  If a function is found 
that a certain plugin uses that is not included in the Compatibility 
Plugin, please ask to have it added.  

Authors who want to avoid getting support requests for simple setup
problems (such as when the person installing the plugin neglects to 
create a configuration file) can use this functionality:

   compatibility_check_plugin_setup('my_plugin', array('config.php'));

This function checks for the existence of any files you tell it to.
The first parameter is the name of the plugin as it is known to SquirrelMail
(the plugin's directory name).  The second parameter is an array of any
number of files, relative to the plugin's directory.  Any number of files
may be included here.  Another example: 

   compatibility_check_plugin_setup('my_plugin', array('data/config.php', 'data/admins.php'));

Note that this code is best placed somewhere where it will not run 
frequently, since it is only really needed once.  You may turn off this
function by changing the $disable_config_check at the top of the 
functions.php file in the Compatibility Plugin.  This functionality
is subject to (possibly radical) change in the future.



TODO
====

  * Add broader functionality to help plugins diagnose 
    other setup/install issues?  such as what?  checking
    certain variables in the config files?...

  * Add functionality to auto-define SM_PATH?  I have
    run into real sticky issues with this and prefer to
    leave it out of this plugin... too many variables...
    but would be nice to remove this responsibilty from
    plugin authors
    Possible algorightm: 
       - globalize and check if $compatibility_sm_path is already available
       - if so, use it, define SM_PATH with it if not done already
       - iterate through getcwd contents, taking off chunks until one
         of the known SM directories is found (plugins, src, functions, include, 
         class, etc)
       - define SM_PATH and $compatibility_sm_path
       - chdir to plugins or SM_PATH dir??? (see below)
    Come to think of it, why doesn't validate.php just take 
    care of this?  Not sure it is appropriate there, but 
    maybe a plugin config file would be good (that's almost
    what this is becoming... which is handy but not sure if
    all the extra work and abstraction is worth it, at least
    from a performance angle - all we gain is allowing plugin
    authors to be dumber.  and are they that dumb?!?  ;>

  * Add functionality to auto-chdir if needed?  we are
    trying to avoid this altogether (and in fact in SM
    1.3 and up we have, unless a plugin is really whacked)
    so this is only useful for 1.2... hmmm... thing is 
    that I ran into some weird situations with plugins
    clashing with one another (address_add was one 
    very problematic one) unless some chdir'ing was done.
    again, it'd be nice to pull all this out of plugin
    author hands so it'll actually work, but it could be
    a little messy, and might need to be version dependent
    code (esp 1.2?)
    The address_add thing is a good example of how messy
    things can be... it is called by code executing somewhere
    in the src directory, so chdir'ing at that time can be
    disasterous

  * Checking for config files and whatnot should be
    moved to the configuration-time code in new SquirrelMail
    versions; it is pointless to do this every time the
    plugin is used



Change Log
==========


  v2.0 2005/06/16
    * Reorganized code so that plugin authors do not need
      to specifically use "compatibility_" functions.
 
  1.3 - Paul Lesneiwski <pdontthink@angrynersd.com>
   * Added compatibility_check_plugin_setup() that helps verify that
     a plugin has been installed and set up correctly
   * Added new $compatibility_sm_path variable for easier plugin coding...
   * Updated for compatibility (!) with new version reporting API

  1.2 - Paul Lesneiwski <pdontthink@angrynersd.com>
   * Fix for theme problem with plugins under SM 1.4

  1.1 - Paul Lesneiwski <pdontthink@angrynersd.com>
   * Some applications of this plugin were experiencing
     unusual include order, so added includes of the
     global.php and strings.php files to be safe.
   * Even though older versions of SquirrelMail have
     some of the functions that this plugin duplicates,
     because they have session issues, the compatibility
     version of those functions now takes precedence over
     older SquirrelMail core code.

  1.0 - Paul Lesneiwski <pdontthink@angrynersd.com>
   * Initial release
