فهرست منبع

Adding ability to hook into ANY attachment type. Also, please review my comments, Does anyone know if/when/how the wildcard attachment code was working??? It looks pretty broken to me, but has been here a long time, so...????

pdontthink 18 سال پیش
والد
کامیت
b6ff5b5a46
1فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 13 1
      functions/mime.php

+ 13 - 1
functions/mime.php

@@ -543,16 +543,28 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) {
 
 
         /* This executes the attachment hook with a specific MIME-type.
         /* This executes the attachment hook with a specific MIME-type.
          * If that doesn't have results, it tries if there's a rule
          * If that doesn't have results, it tries if there's a rule
-         * for a more generic type.
+         * for a more generic type. Finally, a hook for ALL attachment
+         * types is run as well.
          */
          */
         $hookresults = do_hook("attachment $type0/$type1", $links,
         $hookresults = do_hook("attachment $type0/$type1", $links,
                 $startMessage, $id, $urlMailbox, $ent, $defaultlink,
                 $startMessage, $id, $urlMailbox, $ent, $defaultlink,
                 $display_filename, $where, $what);
                 $display_filename, $where, $what);
+// FIXME: How does this code ever get executed?  $hookresults[1] is $links
+//        from above, and should always be returned by do_hook().  I will
+//        test this and fix if needed (but it has been working, right???)
+//        and get rid of these comments (Paul)
+// UPDATE: Preliminary testing shows that in fact I am correct that the
+//         following never gets executed (unless a strange plugin actually
+//         unsets the contents of the links)... how did this ever work???
+//         Can someonen please show a plugin that worked here?
         if(count($hookresults[1]) <= 1) {
         if(count($hookresults[1]) <= 1) {
             $hookresults = do_hook("attachment $type0/*", $links,
             $hookresults = do_hook("attachment $type0/*", $links,
                     $startMessage, $id, $urlMailbox, $ent, $defaultlink,
                     $startMessage, $id, $urlMailbox, $ent, $defaultlink,
                     $display_filename, $where, $what);
                     $display_filename, $where, $what);
         }
         }
+        $hookresults = do_hook("attachment */*", $hookresults[1],
+                $startMessage, $id, $urlMailbox, $ent, $hookresults[6], 
+                $display_filename, $where, $what);
 
 
         $links = $hookresults[1];
         $links = $hookresults[1];
         $defaultlink = $hookresults[6];
         $defaultlink = $hookresults[6];