From ae2f65a94bf9c368da229c226a66cd11264fd8b7 Mon Sep 17 00:00:00 2001 From: kink Date: Tue, 29 Jan 2002 10:18:32 +0000 Subject: [PATCH 1/1] Attachment hooks now also allow specification of generic rules like text/* which will be used when no specific rule is available. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2276 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 2 ++ doc/plugin.txt | 5 ++++- functions/attachment_common.php | 8 +++++++- functions/mime.php | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cb01b4f..b3495cbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ Version 1.2.5 -- CVS - Added options to conf.pl to enable automated plugin installation: ./conf.pl --install-plugin . This allows plugins to be distributed in packages. Conf.pl now also reports when saving fails. + - Attachment hooks now also allow specification of generic rules like + text/* which will be used when no specific rule is available. Version 1.2.4 -- 25 January 2002 -------------------------------- diff --git a/doc/plugin.txt b/doc/plugin.txt index 501e9b30..f5d32035 100644 --- a/doc/plugin.txt +++ b/doc/plugin.txt @@ -147,7 +147,6 @@ List of hooks addressbook_bottom src/addressbook.php ^ attachment $type0/$type1 functions/mime.php (see note on attachments) - (*) Options ----------- There are two ways to do options for your plugin. First, you can incorporate it @@ -277,6 +276,10 @@ To set up links for actions, you assign them like this: $Args[1]['your_plugin_name']['href'] = 'URL to link to'; $Args[1]['your_plugin_name']['text'] = 'What to display'; +It's also possible to specify a hook as "attachment type0/*", +for example "attachment text/*". This hook will be executed whenever there's +no more specific rule available for that type. + Outputting Your Own Pages ------------------------- diff --git a/functions/attachment_common.php b/functions/attachment_common.php index 7a64a736..fc37d988 100644 --- a/functions/attachment_common.php +++ b/functions/attachment_common.php @@ -56,9 +56,15 @@ register_attachment_common('text/richtext', 'link_text'); /* Register HTML */ register_attachment_common('text/html', 'link_html'); + /* Register vcards */ register_attachment_common('text/x-vcard', 'link_vcard'); +/* Register rules for general types. + * These will be used if there isn't a more specific rule available. */ +register_attachment_common('text/*', 'link_text'); +register_attachment_common('message/*', 'link_text'); + /* Register "unknown" attachments */ register_attachment_common('application/octet-stream', 'octet_stream'); @@ -192,4 +198,4 @@ function attachment_common_octet_stream(&$Args) } } -?> \ No newline at end of file +?> diff --git a/functions/mime.php b/functions/mime.php index 1175f26f..c8f4f2cf 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -694,9 +694,17 @@ function formatAttachments ($message, $ent_id, $mailbox, $id) { "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent"; $ImageURL = ''; + / * this executes the attachment hook with a specific MIME-type. + * if that doens't have results, it tries if there's a rule + * for a more generic type. */ $HookResults = do_hook("attachment $type0/$type1", $Links, $startMessage, $id, $urlMailbox, $ent, $DefaultLink, $display_filename, $where, $what); + if(count($HookResults[1]) <= 1) { + $HookResults = do_hook("attachment $type0/*", $Links, + $startMessage, $id, $urlMailbox, $ent, $DefaultLink, + $display_filename, $where, $what); + } $Links = $HookResults[1]; $DefaultLink = $HookResults[6]; -- 2.25.1