Attachment hooks now also allow specification of generic rules like
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 29 Jan 2002 10:18:32 +0000 (10:18 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 29 Jan 2002 10:18:32 +0000 (10:18 +0000)
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
doc/plugin.txt
functions/attachment_common.php
functions/mime.php

index 0cb01b4ffc0bd5b375e14c472cf7a65b16c322a6..b3495cbca02cb691a21093f254f433b1675fa562 100644 (file)
--- 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 <pluginname>. 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
 --------------------------------
index 501e9b30174f25e792bd45849357a998f002f473..f5d32035e45b2a22c309fe20c2ab55b1d2c6639b 100644 (file)
@@ -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
 -------------------------
index 7a64a736cd60d64cd711edd6895d5e3cbda4d537..fc37d988421dc981719eaeb06292505f8731c843 100644 (file)
@@ -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
+?>
index 1175f26f4ba2eaee8aa3659463f8a6e9795857d5..c8f4f2cfb94f930b998b1e0c45518cce4dbd3c45 100644 (file)
@@ -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];