1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %# <jesse@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%>
89 <h2><&|/l&>Messages about this ticket will not be sent to...</&></h2>
90 <i><&|/l&>(Check boxes to enable notifications to the listed recipients)</&></i>
93 % foreach my $recipient (@non_recipients) {
94 <li><input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-UnsquelchMailTo" value="<%$recipient->Content%>" />
95 <% $recipient->Content %>
98 <& /Elements/Submit, Name => 'UpdatePreview', Value => 'UpdatePreview', Label => loc('Save Changes')&>
100 <%METHOD SquelchRecipients>
105 my $arg = 'Ticket-'.$TicketObj->Id.'-SquelchMailTo';
106 my @squelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
108 foreach my $address (@squelchto) {
109 $TicketObj->SquelchMailTo($address) if ($address);
113 $arg = 'Ticket-'.$TicketObj->Id.'-UnsquelchMailTo';
114 my @unsquelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
116 foreach my $address (@unsquelchto) {
117 $TicketObj->UnsquelchMailTo($address) if ($address);
123 if (($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' ) || ($ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' )) {
124 $action = 'Correspond';
130 my $Message = MakeMIMEEntity(
131 Subject => $ARGS{'UpdateSubject'},
132 Body => $ARGS{'UpdateContent'},
135 my ( $Transaction, $Description, $Object ) = $TicketObj->$action(
136 CcMessageTo => $ARGS{'UpdateCc'},
137 BccMessageTo => $ARGS{'UpdateBcc'},
139 TimeTaken => $ARGS{'UpdateTimeWorked'},
142 unless ( $Transaction ) {
143 $RT::Logger->error("Coulfn't fire '$action' action: $Description");
147 return (Object => $Object, EmailAddresses => [$TicketObj->SquelchMailTo]);
151 <%METHOD GetRecipients>
157 if ( ( $ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' )
158 || ( $ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' ) )
160 $action = 'Correspond';
166 my $Message = MakeMIMEEntity(
167 Subject => $ARGS{'UpdateSubject'},
168 Body => $ARGS{'UpdateContent'},
171 my ( $id, $msg, $txn ) = $TicketObj->$action(
172 CcMessageTo => $ARGS{'UpdateCc'},
173 BccMessageTo => $ARGS{'UpdateBcc'},
175 TimeTaken => $ARGS{'UpdateTimeWorked'},
178 unless ( $id && $txn ) {
179 $RT::Logger->error("Couldn't fire '$action' action: $msg");
184 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
185 my $action = $scrip->ActionObj->Action;
186 next unless $action->isa('RT::Action::SendEmail');
188 foreach my $type qw(To Cc Bcc) {
189 push @recipients, $action->$type();
196 <%METHOD GetRecipientsOnCreate>
199 my $Message = MakeMIMEEntity(
200 Subject => $ARGS{'Subject'},
202 Body => $ARGS{'Content'},
205 my $TicketObj = RT::Ticket->new( $session{'CurrentUser'} );
206 my ( $id, $txn, $msg ) = $TicketObj->Create(
207 Type => $ARGS{'Type'} || 'ticket',
208 Queue => $ARGS{'Queue'},
209 Owner => $ARGS{'Owner'},
210 Requestor => $ARGS{'Requestors'},
212 AdminCc => $ARGS{'AdminCc'},
213 InitialPriority => $ARGS{'InitialPriority'},
214 FinalPriority => $ARGS{'FinalPriority'},
215 TimeLeft => $ARGS{'TimeLeft'},
216 TimeEstimated => $ARGS{'TimeEstimated'},
217 TimeWorked => $ARGS{'TimeWorked'},
218 Subject => $ARGS{'Subject'},
219 Status => $ARGS{'Status'},
223 unless ( $id && $txn ) {
224 $RT::Logger->error("Couldn't fire '$action' action: $msg");
229 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
230 my $action = $scrip->ActionObj->Action;
231 next unless $action->isa('RT::Action::SendEmail');
233 foreach my $type qw(To Cc Bcc) {
234 push @recipients, $action->$type();