[Rt-devel] "This message will be sent to..." confirmation
page
Stephen Turner
sturner at MIT.EDU
Tue Mar 28 10:25:38 EST 2006
At Friday 3/24/2006 09:38 AM, Werner van den Berg wrote:
>We have RT 3.4.4 running with appr. 25 users. Most of them struggle with
>whom a message will be sent to using the RT transaction page.
>
>Although RT clearly lists who will receive the message (below the message
>field), I would like to add an additional page before a message will be
>sent.
>
>This page should display a small recap of the people who actually will
>receive the message, together with something like a Confirm and a Cancel
>button.
>
>Is there anyone who has such functionality? Or does someone have a good idea
>how to implement this in RT? Or are others using a different "solution"
>maybe?
>
>
>Best Regards,
>
>Werner van den Berg
Hello Werner,
We have a mason component called ShowAutoRecipients that will list
the mail recipients in a format similar to a mail client (To, Cc, and
Bcc sections). I've attached the code. There's a call to a
GetAttribute method that's part of another mod we made, so you'll
need to remove that if you use this code.
Steve
-------------- next part --------------
%#
%# Displays users who should automatically receive email for a reply or
%# comment transaction, as determined by the scrips.
%#
<%args>
$TicketObj => undef
</%args>
<%init>
my $action;
if (( $ARGS{'UpdateType'} eq 'response' ) || ($ARGS{'Action'} eq 'Respond' )) {
$action = 'Correspond';
}
else {
$action = 'Comment';
}
my $Message = MakeMIMEEntity(
Subject => $ARGS{'UpdateSubject'},
Body => $ARGS{'UpdateContent'},
);
my ( $Transaction, $Description, $Object ) = $TicketObj->$action(
CcMessageTo => $ARGS{'UpdateCc'},
BccMessageTo => $ARGS{'UpdateBcc'},
MIMEObj => $Message,
TimeTaken => $ARGS{'UpdateTimeWorked'},
DryRun => 1
);
my @non_recipients = ();
foreach my $nr ($TicketObj->SquelchMailTo) {
push (@non_recipients, $nr->Content);
}
# Gather all the auto recipients from the scrips:
my @all_autorecipients = ();
my @to_addresses = ();
my @cc_addresses = ();
my @bcc_addresses = ();
my %to_addresses = ();
my %cc_addresses = ();
my %bcc_addresses = ();
#
# We use hashes to gather the addresses to eliminate duplicate entries:
#
foreach my $scrip (@{$Object->Scrips->Prepared}) {
next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
foreach my $to ($scrip->ActionObj->Action->To()) {
$to_addresses{$to->address} = 1;
}
foreach my $cc ($scrip->ActionObj->Action->Cc()) {
$cc_addresses{$cc->address} = 1;
}
foreach my $bcc ($scrip->ActionObj->Action->Bcc()) {
$bcc_addresses{$bcc->address} = 1;
}
}
push (@to_addresses, sort keys %to_addresses);
push (@cc_addresses, sort keys %cc_addresses);
push (@bcc_addresses, sort keys %bcc_addresses);
push ( @all_autorecipients, @to_addresses, @cc_addresses, @bcc_addresses);
my $addr;
my $checked;
my $RecipientsCheckedDefault = GetAttributeValue(
Name => 'RecipientsChecked',
Object => $TicketObj->QueueObj,
DefaultValue => 'true');
my $checked_default = $RecipientsCheckedDefault eq 'true' ? "checked" : "";
</%init>
% foreach $addr (@all_autorecipients) {
<input type="hidden" name="autorecipient" value="<% $addr %>">
% } # end foreach
<table border="0" bgcolor="#DDDDDD" width="100%">
% if (scalar(@to_addresses)) {
<tr>
<td align="right" width="20%" valign="top">To:</td>
<td valign="top">
% foreach $addr (@to_addresses) {
% $checked = "";
% $checked = $checked_default if ! grep (/$addr/, @non_recipients);
<input type="checkbox" name="auto_to" value="<% $addr %>" <% $checked %>><strong><% $addr %></strong><br>
% } # end foreach
</td>
</tr>
% } # endif
% if (scalar(@cc_addresses)) {
<tr>
<td align="right" width="20%" valign="top">Cc:</td>
<td valign="top">
% foreach $addr (@cc_addresses) {
% $checked = "";
% $checked = $checked_default if ! grep (/$addr/, @non_recipients);
<input type="checkbox" name="auto_to" value="<% $addr %>" <% $checked %>><strong><% $addr %></strong><br>
% } # end foreach
</td>
</tr>
% } # endif
% if (scalar(@bcc_addresses)) {
<tr>
<td align="right" width="20%" valign="top">Bcc:</td>
<td valign="top">
% foreach $addr (@bcc_addresses) {
% $checked = "";
% $checked = $checked_default if ! grep (/$addr/, @non_recipients);
<input type="checkbox" name="auto_to" value="<% $addr %>" <% $checked %>><strong><% $addr %></strong><br>
% } # end foreach
</td>
</tr>
% } # endif
<tr><td colspan="2">
<i>
% if (scalar(@to_addresses) || scalar(@cc_addresses) || scalar(@cc_addresses)) {
(Uncheck boxes to disable notifications to the listed recipients. Does <b>not</b> change who will receive future updates.)
% } else {
There are no automatic recipients for this update.
%}
</i><br>
</td></tr>
</table>
More information about the Rt-devel
mailing list