1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
53 my %squelch = $m->comp('SELF:SquelchRecipients', %ARGS);
54 my $Object = $squelch{'Object'};
55 my @non_recipients = @{ $squelch{'EmailAddresses'} };
58 <h2><&|/l&>This message will be sent to...</&></h2>
60 % if ( $Object and $Object->Scrips ) {
61 <i><&|/l&>(Check boxes to disable notifications to the listed recipients)</&></i><br />
63 % foreach my $scrip (@{$Object->Scrips->Prepared}) {
64 % next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
65 <b><% $scrip->Description || loc('Scrip #[_1]',$scrip->id) %></b><br />
66 <&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->TemplateObj->Name)&>[_1] [_2] with template [_3]</&>
68 %foreach my $type qw(To Cc Bcc) {
69 %my @addresses = $scrip->ActionObj->Action->$type();
71 %foreach my $addr (@addresses) {
73 <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-SquelchMailTo" value="<%$addr->address%>" /> <%$addr->address%>
75 % $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
80 % if (RT->Config->Get('PreviewScripMessages')) {
81 <textarea cols="80" rows="5">
82 <%$scrip->ActionObj->TemplateObj->MIMEObj->as_string%>
88 % if ( $Object and $Object->Rules ) {
89 % for my $rule (@{$Object->Rules}) {
90 % next unless $rule->{hints} && $rule->{hints}{class} eq 'SendEmail';
91 <b><% $rule->Describe %></b>
92 % my $data = $rule->{hints}{recipients};
93 % foreach my $type qw(To Cc Bcc) {
95 % foreach my $address (@{$data->{$type}}) {
97 <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-SquelchMailTo" value="<%$address%>" /> <%$address%>
99 % $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type);
109 <h2><&|/l&>Messages about this ticket will not be sent to...</&></h2>
110 <i><&|/l&>(Check boxes to enable notifications to the listed recipients)</&></i>
113 % foreach my $recipient (@non_recipients) {
114 <li><input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-UnsquelchMailTo" value="<%$recipient->Content%>" />
115 <% $recipient->Content %>
118 <& /Elements/Submit, Name => 'UpdatePreview', Value => 'UpdatePreview', Label => loc('Save Changes')&>
120 <%METHOD SquelchRecipients>
125 my $arg = 'Ticket-'.$TicketObj->Id.'-SquelchMailTo';
126 my @squelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
128 foreach my $address (@squelchto) {
129 $TicketObj->SquelchMailTo($address) if ($address);
133 $arg = 'Ticket-'.$TicketObj->Id.'-UnsquelchMailTo';
134 my @unsquelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
136 foreach my $address (@unsquelchto) {
137 $TicketObj->UnsquelchMailTo($address) if ($address);
143 if (($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' ) || ($ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' )) {
144 $action = 'Correspond';
150 my $Message = MakeMIMEEntity(
151 Subject => $ARGS{'UpdateSubject'},
152 Body => $ARGS{'UpdateContent'},
155 my ( $Transaction, $Description, $Object ) = $TicketObj->$action(
156 CcMessageTo => $ARGS{'UpdateCc'},
157 BccMessageTo => $ARGS{'UpdateBcc'},
159 TimeTaken => $ARGS{'UpdateTimeWorked'},
162 unless ( $Transaction ) {
163 $RT::Logger->error("Coulfn't fire '$action' action: $Description");
167 return (Object => $Object, EmailAddresses => [$TicketObj->SquelchMailTo]);
171 <%METHOD GetRecipients>
177 if ( ( $ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' )
178 || ( $ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' ) )
180 $action = 'Correspond';
186 my $Message = MakeMIMEEntity(
187 Subject => $ARGS{'UpdateSubject'},
188 Body => $ARGS{'UpdateContent'},
191 my ( $id, $msg, $txn ) = $TicketObj->$action(
192 CcMessageTo => $ARGS{'UpdateCc'},
193 BccMessageTo => $ARGS{'UpdateBcc'},
195 TimeTaken => $ARGS{'UpdateTimeWorked'},
198 unless ( $id && $txn ) {
199 $RT::Logger->error("Couldn't fire '$action' action: $msg");
204 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
205 my $action = $scrip->ActionObj->Action;
206 next unless $action->isa('RT::Action::SendEmail');
208 foreach my $type qw(To Cc Bcc) {
209 push @recipients, $action->$type();
216 <%METHOD GetRecipientsOnCreate>
219 my $Message = MakeMIMEEntity(
220 Subject => $ARGS{'Subject'},
222 Body => $ARGS{'Content'},
225 my $TicketObj = RT::Ticket->new( $session{'CurrentUser'} );
226 my ( $id, $txn, $msg ) = $TicketObj->Create(
227 Type => $ARGS{'Type'} || 'ticket',
228 Queue => $ARGS{'Queue'},
229 Owner => $ARGS{'Owner'},
230 Requestor => $ARGS{'Requestors'},
232 AdminCc => $ARGS{'AdminCc'},
233 InitialPriority => $ARGS{'InitialPriority'},
234 FinalPriority => $ARGS{'FinalPriority'},
235 TimeLeft => $ARGS{'TimeLeft'},
236 TimeEstimated => $ARGS{'TimeEstimated'},
237 TimeWorked => $ARGS{'TimeWorked'},
238 Subject => $ARGS{'Subject'},
239 Status => $ARGS{'Status'},
243 unless ( $id && $txn ) {
244 $RT::Logger->error("Couldn't fire '$action' action: $msg");
249 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
250 my $action = $scrip->ActionObj->Action;
251 next unless $action->isa('RT::Action::SendEmail');
253 foreach my $type qw(To Cc Bcc) {
254 push @recipients, $action->$type();