소스 검색

Don't let more general attachment plugins override changes made by specific ones; also judge by changes to the defaultlink in addition to added links. Thanks to Thierry Godefroy.

pdontthink 17 년 전
부모
커밋
d36dcbdbe6
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      functions/mime.php

+ 10 - 1
functions/mime.php

@@ -561,6 +561,9 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) {
          * for a more generic type. Finally, a hook for ALL attachment
          * for a more generic type. Finally, a hook for ALL attachment
          * types is run as well.
          * types is run as well.
          */
          */
+        // First remember the default link.
+        $defaultlink_orig = $defaultlink;
+
         /* The API for this hook has changed as of 1.5.2 so that all plugin
         /* The API for this hook has changed as of 1.5.2 so that all plugin
            arguments are passed in an array instead of each their own plugin
            arguments are passed in an array instead of each their own plugin
            argument, and arguments are passed by reference, so instead of
            argument, and arguments are passed by reference, so instead of
@@ -569,7 +572,7 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) {
         $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
         $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
                     &$defaultlink, &$display_filename, &$where, &$what);
                     &$defaultlink, &$display_filename, &$where, &$what);
         do_hook("attachment $type0/$type1", $temp);
         do_hook("attachment $type0/$type1", $temp);
-        if(count($links) <= 1) {
+        if(count($links) <= 1 && $defaultlink == $defaultlink_orig) {
             /* The API for this hook has changed as of 1.5.2 so that all plugin
             /* The API for this hook has changed as of 1.5.2 so that all plugin
                arguments are passed in an array instead of each their own plugin
                arguments are passed in an array instead of each their own plugin
                argument, and arguments are passed by reference, so instead of
                argument, and arguments are passed by reference, so instead of
@@ -586,6 +589,12 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) {
            arguments themselves. */
            arguments themselves. */
         $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
         $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
                       &$defaultlink, &$display_filename, &$where, &$what);
                       &$defaultlink, &$display_filename, &$where, &$what);
+        // Do not let a generic plugin change the default link if a more
+        // specialized one already did it...
+        if ($defaultlink != $defaultlink_orig) {
+            $dummy = '';
+            $temp[5] = &$dummy;
+        }
         do_hook("attachment */*", $temp);
         do_hook("attachment */*", $temp);
 
 
         $this_attachment = array();
         $this_attachment = array();