From 6e515418431c0a99f10705da21366fe7093f95b6 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 10 Dec 2006 05:13:40 +0000 Subject: [PATCH] Massive update to plugin system architecture. Please test! Not all core plugins are tested yet, please point out issues that need to be fixed. Please see http://marc.theaimsgroup.com/?t=116282394000001&r=1&w=2 git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11991 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/change_password/functions.php | 10 ++++----- plugins/change_password/options.php | 4 ++-- plugins/filters/setup.php | 2 +- plugins/info/options.php | 2 +- src/addrbook_search_html.php | 4 ++-- src/addressbook.php | 8 +++---- src/compose.php | 21 ++++++++++--------- src/configtest.php | 6 +++--- src/folders.php | 6 +++--- src/help.php | 8 +++---- src/login.php | 9 +++++--- src/options.php | 14 ++++++------- src/options_highlight.php | 4 ++-- src/options_identities.php | 8 +++---- src/printer_friendly_bottom.php | 4 ++-- src/read_body.php | 7 ++++--- src/redirect.php | 4 ++-- src/right_main.php | 4 ++-- src/search.php | 8 +++---- src/signout.php | 3 +-- src/view_html.php | 3 +-- src/view_text.php | 5 ++--- src/webmail.php | 2 +- templates/default/folder_manip.tpl | 4 ++-- templates/default/left_main.tpl | 14 ++++++++----- templates/default/message_list.tpl | 9 +++++--- .../default/options_advidentity_list.tpl | 6 +++--- templates/default/page_header.tpl | 2 +- templates/default/signout.tpl | 1 - templates/default/webmail.tpl | 6 ------ templates/default_advanced/left_main.tpl | 2 +- 31 files changed, 96 insertions(+), 94 deletions(-) diff --git a/plugins/change_password/functions.php b/plugins/change_password/functions.php index a0cd81dc..9e180f6f 100644 --- a/plugins/change_password/functions.php +++ b/plugins/change_password/functions.php @@ -85,11 +85,11 @@ function cpw_do_change() require_once(SM_PATH . 'plugins/change_password/backend/'.$cpw_backend.'.php'); - $msgs = do_hook_function('change_password_dochange', - array ( - 'username' => $username, - 'curpw' => $curpw, - 'newpw' => $newpw + $msgs = do_hook('change_password_dochange', + $temp=array ( + 'username' => &$username, + 'curpw' => &$curpw, + 'newpw' => &$newpw ) ); /* something bad happened, return */ diff --git a/plugins/change_password/options.php b/plugins/change_password/options.php index d4c8659a..c51fdde0 100644 --- a/plugins/change_password/options.php +++ b/plugins/change_password/options.php @@ -64,7 +64,7 @@ if(sqgetGlobalVar('cpw_go', $cpw_go, SQ_POST)) { displayPageHeader($color, 'None'); -do_hook('change_password_init'); +do_hook('change_password_init', $null); ?>
@@ -104,4 +104,4 @@ if (isset($Messages) && count($Messages) > 0) { - \ No newline at end of file + diff --git a/plugins/filters/setup.php b/plugins/filters/setup.php index 7821ca72..e5658051 100644 --- a/plugins/filters/setup.php +++ b/plugins/filters/setup.php @@ -22,7 +22,7 @@ function squirrelmail_plugin_init_filters() { $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; - $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['template_construct_login_webmail.tpl']['filters'] = 'start_filters_hook'; $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; } diff --git a/plugins/info/options.php b/plugins/info/options.php index 8da3dd9e..278e22c2 100644 --- a/plugins/info/options.php +++ b/plugins/info/options.php @@ -203,6 +203,6 @@ sqimap_logout($imap_stream); * * Hook allows attaching plugin to bottom of info plugin */ -do_hook('info_bottom'); +do_hook('info_bottom', $null); ?> diff --git a/src/addrbook_search_html.php b/src/addrbook_search_html.php index 9fabda51..a22da9a7 100644 --- a/src/addrbook_search_html.php +++ b/src/addrbook_search_html.php @@ -114,7 +114,7 @@ $oTemplate->assign('backends', getBackends()); $oTemplate->display('addressbook_search_form.tpl'); echo "\n"; -do_hook('addrbook_html_search_below'); +do_hook('addrbook_html_search_below', $null); /* End search form */ /* List addresses. Show personal addressbook */ @@ -174,4 +174,4 @@ if ($addrquery == '' || sizeof($res) == 0) { echo '
'; $oTemplate->display('footer.tpl'); -?> \ No newline at end of file +?> diff --git a/src/addressbook.php b/src/addressbook.php index a75a8f7e..90a9b3b2 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -266,18 +266,18 @@ if ($showaddrlist) { $oTemplate->display('addressbook_list.tpl'); +//FIXME: Remove HTML from here! echo "\n"; } /* Display the "new address" form */ +//FIXME: Remove HTML from here! echo '' . "\n"; abook_create_form($form_url,'addaddr',_("Add to address book"),_("Add address"),$defdata); echo "\n"; /* Hook for extra address book blocks */ -echo "\n"; -do_hook('addressbook_bottom'); -echo "\n\n"; +do_hook('addressbook_bottom', $null); $oTemplate->display('footer.tpl'); -?> \ No newline at end of file +?> diff --git a/src/compose.php b/src/compose.php index 93845a4c..19d34d3a 100644 --- a/src/compose.php +++ b/src/compose.php @@ -491,7 +491,10 @@ if ($send) { $Result = deliverMessage($composeMessage); - do_hook('compose_send_after', $Result, $composeMessage); + // NOTE: this hook changed in 1.5.2 from sending $Result and + // $composeMessage as args #2 and #3 to being in an array + // under arg #2 + do_hook('compose_send_after', $temp=array(&$Result, &$composeMessage)); if (! $Result) { showInputForm($session); exit(); @@ -1107,7 +1110,8 @@ function showInputForm ($session, $values=false) { 'enctype="multipart/form-data"'; $compose_onsubmit = array(); - do_hook('compose_form'); + global $null; + do_hook('compose_form', $null); // Plugins that use compose_form hook can add an array entry // to the globally scoped $compose_onsubmit; we add them up @@ -1300,7 +1304,7 @@ function showInputForm ($session, $values=false) { . "

\r\n"; } - do_hook('compose_bottom'); + do_hook('compose_bottom', $null); if ($compose_new_win=='1') { $oTemplate->display('compose_newwin_close.tpl'); @@ -1550,12 +1554,9 @@ function deliverMessage($composeMessage, $draft=false) { $composeMessage->rfc822_header = $rfc822_header; /* Here you can modify the message structure just before we hand - it over to deliver */ - $hookReturn = do_hook('compose_send', $composeMessage); - /* Get any changes made by plugins to $composeMessage. */ - if ( is_object($hookReturn[1]) ) { - $composeMessage = $hookReturn[1]; - } + it over to deliver; plugin authors note that $composeMessage + is sent and modified by reference since 1.5.2 */ + do_hook('compose_send', $composeMessage); if (!$useSendmail && !$draft) { require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php'); @@ -1710,4 +1711,4 @@ function deliverMessage($composeMessage, $draft=false) { } return $success; } -?> \ No newline at end of file +?> diff --git a/src/configtest.php b/src/configtest.php index 4375cd72..8fabfbbe 100644 --- a/src/configtest.php +++ b/src/configtest.php @@ -328,10 +328,10 @@ if (isset($plugins[0])) { do_err($plugin_load_error); } /** - * Hook is added in 1.5.2. Plugins should print error message and return true - * if there is an error in plugin. + * This hook was added in 1.5.2. Each plugins should print an error + * message and return TRUE if there are any errors in its setup/configuration. */ - $plugin_err = boolean_hook_function('configtest'); + $plugin_err = boolean_hook_function('configtest', $null); if($plugin_err) { do_err('Some plugin tests failed.'); } else { diff --git a/src/folders.php b/src/folders.php index 02bd5dd8..03e21a7c 100644 --- a/src/folders.php +++ b/src/folders.php @@ -80,8 +80,8 @@ if ( sqgetGlobalVar('smaction', $action, SQ_POST) ) { $td_str = _("Unsubscribed successfully."); break; default: - // TODO: add hook for plugin action processing. - $td_str = ''; +// TODO: this is a new hook for plugin action processing that has not been TESTED. + $td_str = do_hook('folder_action', $action); break; } @@ -193,4 +193,4 @@ $oTemplate->assign('subbox_option_list', $subbox_option_list); $oTemplate->display('folder_manip.tpl'); $oTemplate->display('footer.tpl'); -?> \ No newline at end of file +?> diff --git a/src/help.php b/src/help.php index 8490961a..39d4786e 100644 --- a/src/help.php +++ b/src/help.php @@ -92,7 +92,7 @@ function get_info($doc, $pos) { /**************[ END HELP FUNCTIONS ]******************/ -do_hook('help_top'); +do_hook('help_top', $null); if (!isset($squirrelmail_language)) { $squirrelmail_language = 'en_US'; @@ -160,7 +160,7 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { } // Provide hook for external help scripts. - do_hook('help_chapter'); + do_hook('help_chapter', $null); $new_toc = array(); foreach ($toc as $ch) { @@ -234,7 +234,7 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) { $oTemplate->display('help_chapter.tpl'); } -do_hook('help_bottom'); +do_hook('help_bottom', $null); $oTemplate->display('footer.tpl'); -?> \ No newline at end of file +?> diff --git a/src/login.php b/src/login.php index 14ee6030..25d45e20 100644 --- a/src/login.php +++ b/src/login.php @@ -79,10 +79,11 @@ if($imap_auth_mech == 'login') { } } -do_hook('login_cookie'); +do_hook('login_cookie', $null); $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); +//FIXME: should be part of the template, not the core! /* Output the javascript onload function. */ $header = "
- +
-- 2.25.1