[Rt-commit] rt branch, squelch, updated. rt-3.8.8-840-g2632132

Alex Vandiver alexmv at bestpractical.com
Wed Sep 22 18:55:25 EDT 2010


The branch, squelch has been updated
       via  2632132f09828373901ff6a09f86a20553c41e1f (commit)
       via  917a0764c92226d4aa1883286e060de0373d7cf2 (commit)
       via  e9354bd023ac15880e02ac7f77c8c89174d3b18f (commit)
       via  0a2d2b563d9c37e698cec629e17681df8901d040 (commit)
       via  b97f5bd371088221ab8f74871836a353f00231e9 (commit)
      from  8da73e8f65570d936604d21d5491963984509f2c (commit)

Summary of changes:
 lib/RT/Interface/Web.pm                  |    1 +
 lib/RT/Record.pm                         |    2 +
 lib/RT/Ticket_Overlay.pm                 |    2 +-
 share/html/Ticket/Elements/PreviewScrips |  127 ++++++++++++------------------
 share/html/Ticket/ModifyPeople.html      |   43 ++++++++++
 share/html/Ticket/Update.html            |   41 ++++------
 6 files changed, 114 insertions(+), 102 deletions(-)

- Log -----------------------------------------------------------------
commit b97f5bd371088221ab8f74871836a353f00231e9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Sep 22 13:02:17 2010 -0400

    Fix method call -- we want to update Told, not LastUpdated

diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index f76d707..8cc8ad4 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -2101,7 +2101,7 @@ sub Correspond {
     unless ( $self->IsRequestor($self->CurrentUser->id) ) {
         my %squelch;
         $squelch{$_}++ for map {$_->Content} $self->SquelchMailTo, $results[2]->SquelchMailTo;
-        $self->_SetLastUpdated
+        $self->_SetTold
             if grep {not $squelch{$_}} $self->Requestors->MemberEmailAddresses;
     }
 

commit 0a2d2b563d9c37e698cec629e17681df8901d040
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Sep 22 14:00:49 2010 -0400

    Add ticket-level squelching to the People page

diff --git a/share/html/Ticket/ModifyPeople.html b/share/html/Ticket/ModifyPeople.html
index 5d9e6c6..7b901d1 100755
--- a/share/html/Ticket/ModifyPeople.html
+++ b/share/html/Ticket/ModifyPeople.html
@@ -60,6 +60,17 @@
 <&| /Widgets/TitleBox, title => loc('Modify people related to ticket #[_1]', $Ticket->Id),   width => "100%", color=> "#333399", class=>'ticket-info-people' &>
 <& Elements/EditPeople, Ticket => $Ticket, UserField => $UserField, UserString => $UserString, UserOp => $UserOp, GroupString => $GroupString, GroupOp => $GroupOp, GroupField => $GroupField &>
 </&>
+<&| /Widgets/TitleBox, title => loc("Modify who receives mail for ticket #[_1]", $Ticket->Id),   width => "100%", color=> "#333399", class=>'ticket-info-squelch' &>
+<p><em>The checked addresses will possibly receive e-mail related to
+actions on this ticket, depending on the action taken. To prevent an
+address from receiving e-mail for this ticket, uncheck the
+address.</em></p>
+
+% for my $addr (sort keys %recips) {
+  <input type="hidden" name="autorecipient" value="<% $addr %>">
+  <input type="checkbox" name="checked_recipient" value="<%$addr%>" <% $recips{$addr} ? "checked" : "" %>> <%$addr%><br />
+% }
+</&>
 <& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), color => "#333399" &>
 </form>
 
@@ -70,12 +81,44 @@ my @results;
 my $Ticket = LoadTicket($id);
 $m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
+# Update the squelch list
+my %squelched = map {$_->Content => 1} $Ticket->SquelchMailTo;
+my %checked = map {$_ => 1} grep {defined}
+    (ref $ARGS{'checked_recipient'} eq "ARRAY" ? @{$ARGS{'checked_recipient'}}
+         : defined $ARGS{'checked_recipient'} ? ($ARGS{'checked_recipient'}) : ());
+my @all = grep {defined}
+    (ref $ARGS{'autorecipient'} eq "ARRAY" ? @{$ARGS{'autorecipient'}}
+         : defined $ARGS{'autorecipient'} ? ($ARGS{'autorecipient'}) : ());
+$Ticket->UnsquelchMailTo($_)
+    for grep {$squelched{$_}} keys %checked;
+$Ticket->SquelchMailTo($_)
+    for grep {!$squelched{$_} and !$checked{$_}} @all;
+
 # if we're trying to search for watchers and nothing else
 unless ($OnlySearchForPeople or $OnlySearchForGroup) {
     push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS);
     push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
     $Ticket->ApplyTransactionBatch;
 }
+
+# Use the ticket's scrips to figure out the new list of recipients.
+my @txns = map {$Ticket->DryRun( Action => $_ )} qw/comment respond/;
+my %recips=();
+for my $scrip (map {@{$_->Scrips->Prepared}} @txns) {
+    next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
+    for my $type qw(To Cc Bcc) {
+        $recips{$_->address} = 1 for $scrip->ActionObj->Action->$type();
+    }
+}
+for my $rule (map {@{$_->Rules}} @txns) {
+    next unless $rule->{hints} && $rule->{hints}{class} eq "SendEmail";
+    for my $type qw(To Cc Bcc) {
+        $recips{$_} = 1 for @{$rule->{hints}{recips}{$type}};
+    }
+}
+
+# Use tkt squelch list to get recipients who will NOT get mail:
+$recips{$_->Content} = 0 for $Ticket->SquelchMailTo;
 </%INIT>
 
 

commit e9354bd023ac15880e02ac7f77c8c89174d3b18f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Sep 22 15:08:32 2010 -0400

    Make _NewTransaction pass through SquelchMailTo to RT::Transaction->Create
    
    _NewTransaction does not simply pass its arguments through; as such,
    2047c was incomplete, and fails to actually propagate per-transaction
    squelching.

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 266ca41..a567dc5 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1412,6 +1412,7 @@ sub _NewTransaction {
         MIMEObj   => undef,
         ActivateScrips => 1,
         CommitScrips => 1,
+        SquelchMailTo => undef,
         @_
     );
 
@@ -1445,6 +1446,7 @@ sub _NewTransaction {
         MIMEObj   => $args{'MIMEObj'},
         ActivateScrips => $args{'ActivateScrips'},
         CommitScrips => $args{'CommitScrips'},
+        SquelchMailTo => $args{'SquelchMailTo'},
     );
 
     # Rationalize the object since we may have done things to it during the caching.

commit 917a0764c92226d4aa1883286e060de0373d7cf2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Sep 22 18:07:17 2010 -0400

    Remove tabbing from ticket update page
    
    This is in preparation for making the squelch on this page be for the
    current transaction only, not a durasive squelch.  Between having to
    store "people to squelch on the upcoming unborn transaction" or alter
    the UI to have that information on the same page, the latter seemed
    more correct.

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index f8042e9..2316408 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -45,14 +45,11 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header,
-    Title  => $title,
-    onload => "function () { hide(document.getElementById('Ticket-Update-squelch')) }" &>
-<& /Ticket/Elements/Tabs, 
-    Ticket => $TicketObj, 
-    Title=> $title,
-    actions => $actions &>
-    
+<& /Elements/Header, Title  => $title &>
+<& /Ticket/Elements/Tabs,
+    Ticket => $TicketObj,
+    Title => $title &>
+
 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
 <& /Elements/ListActions, actions => \@results &>
 
@@ -65,9 +62,6 @@
 
 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
 
-<div id="Ticket-Update-basics">
-<a name="basics"></a>
-
 <div id="ticket-update-metadata">
   <&|/Widgets/TitleBox, title => loc('Ticket and Transaction') &>
 <table width="100%" border="0">
@@ -170,18 +164,14 @@
     <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $TicketObj &>
   </table>
 </&>
-  <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
 
-</div>
-</div>
-
-<div id="Ticket-Update-squelch">
-<a name="squelch"></a>
 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
   <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips' &>
     <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
   </&>
 % }
+
+  <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
 </div>
 
 </form>
@@ -307,15 +297,6 @@ if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
 }
-
-my $actions = {
-    A => {
-        html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Update-basics','Ticket-Update-squelch');">] . loc('Show basics') . q[</a>],
-    },
-    B => {
-        html => q[<a href="#squelch" onclick="return switchVisibility('Ticket-Update-squelch','Ticket-Update-basics');">] . loc('Squelch recipients') . q[</a>],
-    },
-};
 </%INIT>
 
 <%ARGS>

commit 2632132f09828373901ff6a09f86a20553c41e1f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Sep 22 18:20:26 2010 -0400

    Make the squelching on ticket update be for this transaction only

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index cb945e3..f80adf5 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1229,6 +1229,7 @@ sub _ProcessUpdateMessageRecipients {
         push @txn_squelch, $args{TicketObj}->Requestors->MemberEmailAddresses;
     }
 
+    push @txn_squelch, @{$args{ARGSRef}{SquelchMailTo}} if $args{ARGSRef}{SquelchMailTo};
     $message_args->{SquelchMailTo} = \@txn_squelch
         if @txn_squelch;
 
diff --git a/share/html/Ticket/Elements/PreviewScrips b/share/html/Ticket/Elements/PreviewScrips
index 32c50e8..340b8d9 100755
--- a/share/html/Ticket/Elements/PreviewScrips
+++ b/share/html/Ticket/Elements/PreviewScrips
@@ -49,88 +49,65 @@
 $TicketObj => undef
 </%args>
 <%init>
-my %diff;
-$diff{$_}++ for Email::Address->parse($ARGS{"Ticket-".$TicketObj->Id."-Recipients"});
-my $arg = 'Ticket-'.$TicketObj->Id.'-SendMailTo';
-$diff{$_}-- for grep {$_} ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
-
-foreach my $address (grep {$diff{$_} > 0} keys %diff) {
-    $TicketObj->SquelchMailTo($address);
-}
-
-
-$arg = 'Ticket-'.$TicketObj->Id.'-UnsquelchMailTo';
-my @unsquelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
-
-foreach my $address (@unsquelchto) {
-    $TicketObj->UnsquelchMailTo($address) if ($address);
-}
-
 my $Object = $TicketObj->DryRun(%ARGS);
-my @non_recipients = $TicketObj->SquelchMailTo;
-my @recipients;
+my %recips;
 </%init>
 <h2><&|/l&>This message will be sent to...</&></h2>
+<i><&|/l, RT->Config->Get('WebPath')."/Ticket/ModifyPeople.html?id=".$TicketObj->Id,
+&>Uncheck boxes to disable notifications to the listed recipients <b>for this transaction only</b>; persistent squelching is managed on the <a href="[_1]">People page</a>.</&></i>
+<br /><br />
 
 % if ( $Object and $Object->Scrips ) {
-<i><&|/l&>(Uncheck boxes to disable notifications to the listed recipients)</&></i><br />
-
-% foreach my $scrip (@{$Object->Scrips->Prepared}) {
-% next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
-<b><% $scrip->Description || loc('Scrip #[_1]',$scrip->id) %></b><br />
-<&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->TemplateObj->Name)&>[_1] [_2] with template [_3]</&>
-<br />
-%foreach my $type qw(To Cc Bcc) {
-%my @addresses =  $scrip->ActionObj->Action->$type();
-<ul>
-%foreach my $addr (@addresses) {
-<li>
-    <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-SendMailTo" checked="1" value="<%$addr->address%>" /> <%$addr->address%>
-
-% $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
-% push @recipients, $addr->address;
-</li>
-% }
-</ul>
-% }
-% if (RT->Config->Get('PreviewScripMessages')) {
-<textarea cols="80" rows="5">
-<%$scrip->ActionObj->TemplateObj->MIMEObj->as_string%>
-</textarea>
-% }
-% }
+%     for my $scrip (@{$Object->Scrips->Prepared}) {
+%         next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
+          <b><% $scrip->Description || loc('Scrip #[_1]',$scrip->id) %></b><br />
+          <&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->TemplateObj->Name)&>[_1] [_2] with template [_3]</&>
+          <br />
+%         for my $type qw(To Cc Bcc) {
+%             my @addresses =  $scrip->ActionObj->Action->$type();
+%             next unless @addresses;
+              <ul>
+%             for my $addr (@addresses) {
+                  <li>
+%                 my $checked = 1;
+%                 $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
+%                 $recips{$addr->address}++;
+                  <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="TxnSendMailTo" checked="<% $checked %>" value="<%$addr->address%>" />
+                                         <%$addr->address%>
+%                 $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
+                  </li>
+%             }
+              </ul>
+%         }
+%         if (RT->Config->Get('PreviewScripMessages')) {
+              <textarea cols="80" rows="5"><%$scrip->ActionObj->TemplateObj->MIMEObj->as_string%></textarea>
+%         }
+          <br />
+%     }
 % }
 
 % if ( $Object and $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};
-%    foreach my $type qw(To Cc Bcc) {
-<ul>
-%        foreach my $address (@{$data->{$type}}) {
-<li>
-    <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-SendMailTo" value="<%$address%>" /> <%$address%>
-
-%            $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type);
-% push @recipients, $address;
-</li>
-%        }
-</ul>
-
-%   }
-% }
+%     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 = 1;
+%                 $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" value="<%$address%>" />
+                                         <%$address%>
+%                 $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type);
+                  </li>
+%             }
+              </ul>
+%         }
+          <br />
+%     }
 % }
-<input type="hidden" name="Ticket-<%$TicketObj->id%>-Recipients" value="<%join(",", at recipients)%>" />
-<br />
 
-<h2><&|/l&>Messages about this ticket will not be sent to...</&></h2>
-<i><&|/l&>(Check boxes to enable notifications to the listed recipients)</&></i>
-<br />
-<ul>
-% foreach my $recipient (@non_recipients) {
-<li><input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-UnsquelchMailTo" value="<%$recipient->Content%>" />
-<% $recipient->Content %>
-% }
-</ul>
-<& /Elements/Submit, Name => 'UpdatePreview', Value => 'UpdatePreview', Label => loc('Save Changes')&>
+<input type="hidden" name="TxnRecipients" value="<% join ",",keys %recips %>" />
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 2316408..3c3cab6 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -256,6 +256,14 @@ $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
 );
 
 if ( $ARGS{'SubmitTicket'} ) {
+
+    my %checked = map {$_ => 1} grep {defined}
+        (ref $ARGS{'TxnSendMailTo'} eq "ARRAY" ? @{$ARGS{'TxnSendMailTo'}}
+             : defined $ARGS{'TxnSendMailTo'} ? ($ARGS{'TxnSendMailTo'}) : ());
+
+    my @squelchlist = grep {not $checked{$_}} split /,/, $ARGS{'TxnRecipients'};
+    $ARGS{'SquelchMailTo'} = \@squelchlist if @squelchlist;
+
     my $CFs = $TicketObj->TransactionCustomFields;
     my $ValidCFs = $m->comp(
         '/Elements/ValidateCustomFields',

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


More information about the Rt-commit mailing list