[Rt-commit] rt branch, 4.2/no-preview-rules, created. rt-4.2.6-27-g409cde6

Alex Vandiver alexmv at bestpractical.com
Wed Jul 23 14:07:07 EDT 2014


The branch, 4.2/no-preview-rules has been created
        at  409cde6c15351c1041285d5cef2ac987b7bf0c99 (commit)

- Log -----------------------------------------------------------------
commit 409cde6c15351c1041285d5cef2ac987b7bf0c99
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jul 23 13:47:42 2014 -0400

    Remove mostly-duplicate code for Rules which can never trigger
    
    PreviewScrips includes a mostly-duplicated block of code to preview
    emails produced by Rules, the mechanism behind Approvals.  However, this
    code is unnecessary because /Ticket/Update.html is not accessible for
    tickets of type 'approval' (the only objects which could currently
    trigger Rules in a stock RT), because /Tickets/autohandler redirects all
    but a small number of files under /Tickets/ to /Approvals/ instead.
    /Ticket/Update.html is not in the whitelist, and thus cannot render for
    Approvals.
    
    Furthermore, the code checks $rule->{hints}{class} to determine if it
    should display the rule; no rule ever has a ->{hints} set on it, and
    never has, since the introduction of this code in 6d14f535.  As such,
    even if /Ticket/Update.html were accessible, or some local customization
    made use of Rules for something other than Approvals, they would still
    not appear in PreviewScrips.
    
    Remove the duplicated and unused code.

diff --git a/share/html/Ticket/Elements/PreviewScrips b/share/html/Ticket/Elements/PreviewScrips
index 973fe0d..d050696 100644
--- a/share/html/Ticket/Elements/PreviewScrips
+++ b/share/html/Ticket/Elements/PreviewScrips
@@ -94,30 +94,6 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 %     }
 % }
 
-% if ( $Object->Rules ) {
-%     for my $rule (@{$Object->Rules}) {
-%         next unless $rule->{hints} && $rule->{hints}{class} eq 'SendEmail';
-          <b><% $rule->Describe %></b>
-%         my $data = $rule->{hints}{recipients};
-%         for my $type (qw(To Cc Bcc)) {
-%             next unless @{$data->{$type}};
-              <ul>
-%             for my $address (@{$data->{$type}}) {
-                  <li>
-%                 my $checked = not $squelched{$address};
-%                 $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type, Checked => \$checked);
-%                 $recips{$address}++;
-                  <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$address%>" id="TxnSendMailTo-<% $address %>-<% $recips{$address} %>" />
-                  <label for="TxnSendMailTo-<% $address %>-<% $recips{$address} %>"><%$address%></label>
-%                 $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type);
-                  </li>
-%             }
-              </ul>
-%         }
-          <br />
-%     }
-% }
-
 % $m->callback( CallbackName => 'AfterRecipients', TicketObj => $TicketObj );
 
 % $m->notes("DryRun-Recipients-".$TicketObj->Id, \%recips);
diff --git a/share/html/Ticket/Elements/ShowSimplifiedRecipients b/share/html/Ticket/Elements/ShowSimplifiedRecipients
index bc662b2..8300f88 100644
--- a/share/html/Ticket/Elements/ShowSimplifiedRecipients
+++ b/share/html/Ticket/Elements/ShowSimplifiedRecipients
@@ -64,14 +64,6 @@ if ($Object->Scrips) {
         }
     }
 }
-if ($Object->Rules) {
-    for my $rule (grep {$_->{hints} and $_->{hints}{class} eq "SendEmail"} @{$Object->Rules}) {
-        for my $type (qw(To Cc Bcc)) {
-            $headers{$type}{$_} ||= @{[Email::Address->parse($_)]}[0] # Hate list context
-                for @{$rule->{hints}{recipients}{$type}};
-        }
-    }
-}
 my %recips;
 my %squelched = ProcessTransactionSquelching( \%ARGS );
 </%init>

-----------------------------------------------------------------------


More information about the rt-commit mailing list