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) {
72 <li> <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-SquelchMailTo" value="<%$addr->address%>" /> <%$addr->address%>
76 % if (RT->Config->Get('PreviewScripMessages')) {
77 <textarea cols="80" rows="5">
78 <%$scrip->ActionObj->TemplateObj->MIMEObj->as_string%>
85 <h2><&|/l&>Messages about this ticket will not be sent to...</&></h2>
86 <i><&|/l&>(Check boxes to enable notifications to the listed recipients)</&></i>
89 % foreach my $recipient (@non_recipients) {
90 <li><input type="checkbox" class="checkbox" name="Ticket-<%$TicketObj->id%>-UnsquelchMailTo" value="<%$recipient->Content%>" />
91 <% $recipient->Content %>
94 <& /Elements/Submit, Name => 'UpdatePreview', Value => 'UpdatePreview', Label => loc('Save Changes')&>
96 <%METHOD SquelchRecipients>
101 my $arg = 'Ticket-'.$TicketObj->Id.'-SquelchMailTo';
102 my @squelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
104 foreach my $address (@squelchto) {
105 $TicketObj->SquelchMailTo($address) if ($address);
109 $arg = 'Ticket-'.$TicketObj->Id.'-UnsquelchMailTo';
110 my @unsquelchto = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
112 foreach my $address (@unsquelchto) {
113 $TicketObj->UnsquelchMailTo($address) if ($address);
119 if (($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' ) || ($ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' )) {
120 $action = 'Correspond';
126 my $Message = MakeMIMEEntity(
127 Subject => $ARGS{'UpdateSubject'},
128 Body => $ARGS{'UpdateContent'},
131 my ( $Transaction, $Description, $Object ) = $TicketObj->$action(
132 CcMessageTo => $ARGS{'UpdateCc'},
133 BccMessageTo => $ARGS{'UpdateBcc'},
135 TimeTaken => $ARGS{'UpdateTimeWorked'},
138 unless ( $Transaction ) {
139 $RT::Logger->error("Coulfn't fire '$action' action: $Description");
143 return (Object => $Object, EmailAddresses => [$TicketObj->SquelchMailTo]);
147 <%METHOD GetRecipients>
153 if ( ( $ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq 'response' )
154 || ( $ARGS{'Action'} && $ARGS{'Action'} eq 'Respond' ) )
156 $action = 'Correspond';
162 my $Message = MakeMIMEEntity(
163 Subject => $ARGS{'UpdateSubject'},
164 Body => $ARGS{'UpdateContent'},
167 my ( $id, $msg, $txn ) = $TicketObj->$action(
168 CcMessageTo => $ARGS{'UpdateCc'},
169 BccMessageTo => $ARGS{'UpdateBcc'},
171 TimeTaken => $ARGS{'UpdateTimeWorked'},
174 unless ( $id && $txn ) {
175 $RT::Logger->error("Couldn't fire '$action' action: $msg");
180 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
181 my $action = $scrip->ActionObj->Action;
182 next unless $action->isa('RT::Action::SendEmail');
184 foreach my $type qw(To Cc Bcc) {
185 push @recipients, $action->$type();
192 <%METHOD GetRecipientsOnCreate>
195 my $Message = MakeMIMEEntity(
196 Subject => $ARGS{'Subject'},
198 Body => $ARGS{'Content'},
201 my $TicketObj = RT::Ticket->new( $session{'CurrentUser'} );
202 my ( $id, $txn, $msg ) = $TicketObj->Create(
203 Type => $ARGS{'Type'} || 'ticket',
204 Queue => $ARGS{'Queue'},
205 Owner => $ARGS{'Owner'},
206 Requestor => $ARGS{'Requestors'},
208 AdminCc => $ARGS{'AdminCc'},
209 InitialPriority => $ARGS{'InitialPriority'},
210 FinalPriority => $ARGS{'FinalPriority'},
211 TimeLeft => $ARGS{'TimeLeft'},
212 TimeEstimated => $ARGS{'TimeEstimated'},
213 TimeWorked => $ARGS{'TimeWorked'},
214 Subject => $ARGS{'Subject'},
215 Status => $ARGS{'Status'},
219 unless ( $id && $txn ) {
220 $RT::Logger->error("Couldn't fire '$action' action: $msg");
225 foreach my $scrip ( @{ $txn->Scrips->Prepared } ) {
226 my $action = $scrip->ActionObj->Action;
227 next unless $action->isa('RT::Action::SendEmail');
229 foreach my $type qw(To Cc Bcc) {
230 push @recipients, $action->$type();