disable regexp compilation error
[squirrelmail.git] / doc / Development / plugin.txt
index fedaec7c2da6a36c3fa3503e5a85007d21de4266..3fa3834456e8666b56d9b4c1ca6120f774dc5c59 100644 (file)
@@ -5,9 +5,9 @@ development FAQ for more information.  Also, help writing plugins
 is easily obtained by posting to the squirrelmail-plugins mailing
 list.  (See details about mailing lists on the website)
 
-FAQ -> http://www.squirrelmail.org/wiki/wiki.php?DeveloperFAQ
+FAQ -> http://www.squirrelmail.org/wiki/DeveloperFAQ
 Plugin Development ->
-       http://www.squirrelmail.org/wiki/wiki.php?DevelopingPlugins
+       http://www.squirrelmail.org/wiki/DevelopingPlugins
 
 
 A FEW NOTES ON THE PLUGIN ARCHITECTURE
@@ -163,36 +163,59 @@ version is not listed, files are included from v.1.3.2.):
       1.7. class/mime/Language.class.php
       1.8. class/mime/ContentType.class.php
    2. functions/global.php
+      * fixes differences between php 4.0.x and 4.1+ globals (only in 1.4.x).  
+      * undoes magic_quotes_gpc=on sanitizing
+      * sets $PHP_SELF (since 1.5.1)
+      * starts session
    3. functions/strings.php
+      3.1. functions/global.php
+      3.2. plugins/compatibility/functions.php (compatibility v.2.0.4+, requires
+           code patching)
+      * sets squirrelmail version variable and constant.
+      * sets $PHP_SELF (before 1.5.1)
    4. config/config.php
       4.1. config/config_local.php (from 1.4.0rc1)
    5. functions/i18n.php
       5.1. functions/global.php (from 1.4.0)
+      * reads 'squirrelmail_language' cookie
+      * loads $languages (since 1.5.1 $languages array is built from
+        locale/*/setup.php files)
+      * loads own gettext functions, if php gettext is unavailable
    6. functions/auth.php
    7. include/load_prefs.php
       7.1. include/validate.php
       7.2. functions/prefs.php
+         7.2.1. functions/global.php (sqgetGlobalVar() function)
+         7.2.2. functions/plugin.php (do_hook_function() function,, 
+                since 1.4.4 and 1.5.1, see 7.3)
+         7.2.3. $prefs_backend (only in 1.4.3 and 1.5.0)
+                do_hook_function('prefs_backend') (since 1.4.4 and 1.5.1)
+                functions/db_prefs.php
+                functions/file_prefs.php
+           7.2.3.1. functions/display_messages.php
+                    (loaded only by file_prefs.php)
+           7.2.3.2. files loaded by plugin that uses 'prefs_backend' hook
       7.3. functions/plugin.php
          7.3.1. functions/global.php (from 1.4.0 and 1.5.0)
          7.3.2. functions/prefs.php (from 1.5.1)
+         7.3.3. plugins/*/setup.php files for enabled plugins. 
+         * starts all squirrelmail_plugin_init_pluginname functions
       7.4. functions/constants.php
       7.5. do_hook('loading_prefs')
-         7.5.1. files loaded by plugins that use 'loading_prefs'
+         7.5.1. files loaded by plugins that use 'loading_prefs' hook
    8. functions/page_header.php
       8.1. functions/strings.php
       8.2. functions/html.php
       8.3. functions/imap_mailbox.php
          8.3.1. functions/imap_utf7_local.php
       8.4. functions/global.php
-   9. functions/prefs.php
-      9.1. functions/global.php
-      9.2. $prefs_backend (only in 1.4.3 and 1.5.0)
-           do_hook_function('prefs_backend') (since 1.4.4 and 1.5.1)
-           functions/db_prefs.php
-           functions/file_prefs.php
-         9.2.1. functions/display_messages.php
-                (loaded only by file_prefs.php)
-         9.2.2. files loaded by plugin that uses 'prefs_backend'
+   9. functions/prefs.php (already loaded. see 7.2)
+
+Since SquirrelMail 1.5.1 functions/global.php file must be loaded before 
+setting any own global variables. If variables are set before loading 
+functions/global.php library, they can be corrupted in PHP register_globals=On 
+setups.
+
 
 Hook Types:  Parameters and Return Values
 -----------------------------------------
@@ -303,10 +326,11 @@ but may be out of date soon thereafter.  You never know.  ;-)
   loading_prefs                  include/load_prefs.php          do_hook
   addrbook_html_search_below     src/addrbook_search_html.php    do_hook
   addressbook_bottom             src/addressbook.php             do_hook
-  compose_form                   src/compose.php                 do_hook
+! compose_form                   src/compose.php                 do_hook
   compose_bottom                 src/compose.php                 do_hook
   compose_button_row             src/compose.php                 do_hook
   compose_send                   src/compose.php                 do_hook
+  compose_send_after             src/compose.php                 do_hook
   folders_bottom                 src/folders.php                 do_hook
   help_top                       src/help.php                    do_hook
   help_chapter                   src/help.php                    do_hook
@@ -371,6 +395,7 @@ O info_bottom                    plugins/info/options.php        do_hook
 ^ = Special attachments hook (see below)
 * = Special options hooks (see below)
 O = Optional hook provided by a particular plugin
+! = See below for notes about working with the compose page's <form> tag
 
 
 (#) Called With
@@ -381,6 +406,35 @@ Each hook is called using the hook type specified in the list above:
    concat_hook   concat_hook_function()
 
 
+(!) Compose Form
+----------------
+The compose_form hook allows plugins to insert their own code into 
+the form tag for the main message composition HTML form.  Usually
+plugins will want to insert some kind of code in an onsubmit event
+handler.  In order to allow more than one plugin to do so, all plugins
+using this hook to add some onsubmit code need to add that code (without
+the enclosing attribute name and quotes) as a new array entry to the 
+global $compose_onsubmit array.  The code should use "return false"
+if the plugin has found a reason to stop form submission, otherwise,
+it should DO NOTHING (that is, please do not use "return true", as that
+will prevent other plugins from using the onsubmit handler).  SquirrelMail
+itself will insert a final "return true".  All onsubmit code will be
+enclosed in double quotes by SquirrelMail, so plugins need to quote 
+accordingly if needed.  For example:
+
+   global $compose_onsubmit;
+   $compose_onsubmit[] = ' if (somevar == \'no\') return false; ';
+
+Note the escaped single quotes.  If you use double quotes, they would have
+to be escaped as such:
+
+   global $compose_onsubmit;
+   $compose_onsubmit[] = ' if (somevar == \'no\') { alert(\\"Sorry\\"); return false; }';
+
+Any other form tag additions by a plugin (beside onsubmit event code) can 
+currently be echoed directly to the browser.
+
+
 (&) Identity Hooks
 ------------------
 This set of hooks is passed special information in the array of arguments:
@@ -1040,7 +1094,7 @@ it isn't much trouble, either.  This document will only describe how you can
 accomplish the internationalization of a plugin.  For more general information
 about PHP and SquirrelMail translation facilities, see:
 
-http://www.squirrelmail.org/wiki/wiki.php?LanguageTranslation
+http://www.squirrelmail.org/wiki/LanguageTranslation
 
 The unofficial way to internationalize a plugin is to put all plugin output
 into the proper format but to rely on the SquirrelMail translation facilities
@@ -1346,6 +1400,10 @@ scope automatically.  There is nothing more to do than this:
    global $favorite_color;
    sqgetGlobalVar('favorite_color', $favorite_color, SQ_FORM);
 
+SquirrelMail 1.5.1+ cleans globals in functions/global.php library. If 
+plugin depends on PHP register_globals=On and loads this library, it will 
+be broken.
+
 
 Security considerations
 -----------------------
@@ -1609,7 +1667,7 @@ and seamlessly support both 1.2.x and 1.4.x SquirrelMail installations.  For
 more information about how to use the "Compatibility" plugin, download it and
 read its README file or see:
 
-   http://www.squirrelmail.org/wiki/wiki.php?PluginUpgrading
+   http://www.squirrelmail.org/wiki/PluginUpgrading
 
 
 REQUESTING NEW HOOKS
@@ -1654,5 +1712,5 @@ official SquirrelMail plugin developer.
       do not respond, you should feel free to ask for help contacting them
       on the squirrelmail-plugins mailing list.
 
-         http://www.squirrelmail.org/wiki/wiki.php?SquirrelMailLeadership
+         http://www.squirrelmail.org/wiki/SquirrelMailLeadership