瀏覽代碼

Attachment hooks now also allow specification of generic rules like
text/* which will be used when no specific rule is available.

Thijs Kinkhorst 23 年之前
父節點
當前提交
8e645fcc65
共有 4 個文件被更改,包括 21 次插入2 次删除
  1. 2 0
      ChangeLog
  2. 4 1
      doc/plugin.txt
  3. 7 1
      functions/attachment_common.php
  4. 8 0
      functions/mime.php

+ 2 - 0
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
 --------------------------------

+ 4 - 1
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
 -------------------------

+ 7 - 1
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)
     }
 }
 
-?>
+?>

+ 8 - 0
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];