[Bps-public-commit] rt-extension-nonwatcherrecipients branch add-html-content-option created. 1.02-3-g087e050
BPS Git Server
git at git.bestpractical.com
Thu Feb 10 23:39:46 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-nonwatcherrecipients".
The branch, add-html-content-option has been created
at 087e050d0ec6f403ca12d24b7a448554149b9ce9 (commit)
- Log -----------------------------------------------------------------
commit 087e050d0ec6f403ca12d24b7a448554149b9ce9
Author: Brad Embree <brad at bestpractical.com>
Date: Tue Feb 8 08:39:23 2022 -0800
Update POD
diff --git a/lib/RT/Extension/NonWatcherRecipients.pm b/lib/RT/Extension/NonWatcherRecipients.pm
index f51ced0..3794a7a 100644
--- a/lib/RT/Extension/NonWatcherRecipients.pm
+++ b/lib/RT/Extension/NonWatcherRecipients.pm
@@ -33,6 +33,8 @@ so you know someone may need to be added:
If you want the person to see correspondence, you can click the link and add
them. If not, you can just ignore the message.
+You can choose between a text message or html formatted message.
+
=head1 INSTALLATION
=over
@@ -73,19 +75,25 @@ or add C<RT::Extension::NonWatcherRecipients> to your existing C<@Plugins> line.
=head1 USAGE
-If you run the C<make initdb> step, a new global template called
-C<NonWatcherRecipients Admin Correspondence> is installed on your system.
-You can then select this template for any scrips that use the
-standard C<Admin Correspondence> template. We recommend the
-C<Admin Correspondence> template because you'll need RT privileges
-to add the user to the ticket.
+If you run the C<make initdb> step, two new global templates called
+C<NonWatcherRecipients Admin Correspondence> and
+C<NonWatcherRecipients Admin Correspondence in HTML> are installed on your
+system. You can then select one of these templates for any scrips that use the
+standard C<Admin Correspondence> or C<Admin Correspondence in HTML> templates.
+We recommend the C<Admin Correspondence> templates because you'll need RT
+privileges to add the user to the ticket.
-You can also add this to existing templates by adding the following
-to any template:
+You can also add these to existing templates by adding the following
+to any template for the plain text version:
{ RT::Extension::NonWatcherRecipients->FindRecipients(
Transaction => $Transaction, Ticket => $Ticket ) }
+or adding the following for the html version:
+
+ { RT::Extension::NonWatcherRecipients->FindRecipients(
+ Transaction => $Transaction, Ticket => $Ticket, Format => 'text/html' ) }
+
As described below, this method returns a message which is then inserted into
your template. Look at the installed template for an example. You may also
call the method and use the returned string however you'd like.
@@ -98,8 +106,13 @@ Search headers for recipients not included as watchers on the ticket
and return a message to insert in the outgoing email to notify
participants.
-Takes: (Transaction => $Transaction, Ticket => $Ticket)
-These are the objects provided in the RT template.
+Takes:
+
+ (Transaction => $Transaction, Ticket => $Ticket, Format => 'text/html')
+
+Transaction and Ticket are the objects provided in the RT template.
+Format is an optional parameter that accepts either 'text/plain' or 'text/html'
+and defaults to 'text/plain' if not specified.
Returns: a message to insert in a template
commit d9c67125ebe62ab9db17f880e867ec5d96fc4a21
Author: Brad Embree <brad at bestpractical.com>
Date: Tue Feb 8 08:17:13 2022 -0800
Add HTML template
diff --git a/etc/initialdata b/etc/initialdata
index 8d83fe1..39eabb2 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -1,8 +1,9 @@
- at Templates = {
- Queue => 0,
- Name => 'NonWatcherRecipients Admin Correspondence',
- Description => 'Note non-ticket-watchers receiving email on correspondence',
- Content => <<' TEMPLATE',
+ at Templates = (
+ {
+ Queue => 0,
+ Name => 'NonWatcherRecipients Admin Correspondence',
+ Description => 'Plain text note about non-ticket-watchers receiving email on correspondence',
+ Content => <<' TEMPLATE',
RT-Attach-Message: yes
<URL: {RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id} >
@@ -10,4 +11,20 @@ RT-Attach-Message: yes
{ RT::Extension::NonWatcherRecipients->FindRecipients(Transaction => $Transaction, Ticket => $Ticket) }
{$Transaction->Content()}
TEMPLATE
-};
+ },
+ {
+ Queue => 0,
+ Name => 'NonWatcherRecipients Admin Correspondence in HTML',
+ Description => 'HTML note about non-ticket-watchers receiving email on correspondence',
+ Content => <<' TEMPLATE',
+RT-Attach-Message: yes
+Content-Type: text/html
+
+<p>Ticket URL: <a href="{RT->Config->Get("WebURL")}Ticket/Display.html?id={$Ticket->id}">{RT->Config->Get("WebURL")}Ticket/Display.html?id={$Ticket->id}</a>
+<br />
+<br />
+{ RT::Extension::NonWatcherRecipients->FindRecipients(Transaction => $Transaction, Ticket => $Ticket, Format => 'text/html') }</p>
+{$Transaction->Content(Type => "text/html");}
+ TEMPLATE
+ }
+);
commit 6d124da41be94c4da2c21f88468b53225b9048dc
Author: Brad Embree <brad at bestpractical.com>
Date: Tue Feb 8 08:27:56 2022 -0800
Add Format parameter
Adding the Format parameter for use in html formatted admin correspondence
diff --git a/lib/RT/Extension/NonWatcherRecipients.pm b/lib/RT/Extension/NonWatcherRecipients.pm
index 6149bfa..f51ced0 100644
--- a/lib/RT/Extension/NonWatcherRecipients.pm
+++ b/lib/RT/Extension/NonWatcherRecipients.pm
@@ -107,9 +107,11 @@ Returns: a message to insert in a template
sub FindRecipients {
my $self = shift;
- my %args = @_;
+ my %args = ( Format => 'text/plain',
+ @_ );
my $Transaction = $args{Transaction};
my $Ticket = $args{Ticket};
+ my $Format = $args{Format};
my $recipients; # List of recipients
my $message = ""; # Message for template
@@ -125,27 +127,34 @@ sub FindRecipients {
my %addr = %{ $att->Addresses };
my $creator = $Transaction->CreatorObj->RealName || '';
+ my $newline = "\n";
+ if ( $Format eq 'text/html' ) {
+ $newline = "<br/>\n";
+ }
+
# Show any extra recipients
for my $hdr (qw(From To Cc RT-Send-Cc RT-Send-Bcc)) {
my @new = grep { not $self->IsWatcher($_->address, $Ticket) } @{$addr{$hdr} || []};
- $recipients .= " $hdr: " . $self->Format(\@new) . "\n"
+ $recipients .= " $hdr: " . $self->Format(\@new) . $newline
if @new;
}
-
if ($recipients) {
+ my $href = "${RT::WebURL}Ticket/ModifyPeople.html?id=" . $Ticket->id;
+ if ( $Format eq 'text/html' ) {
+ $href = '<a href="' . $href . '">' . $href . '</a>';
+ }
$message = "The following people received a copy of this email "
. "but are not on the ticket. You may want to add them "
- . "before replying: ${RT::WebURL}Ticket/ModifyPeople.html?id="
- . $Ticket->id . "\n\n$recipients";
+ . "before replying: $href$newline$newline$recipients";
}
# Show From if there's a different phrase; this catches name changes and "via RT"
my @from = grep { ($_->phrase||'') ne $creator } @{$addr{From} || []};
- $message = " From: " . $self->Format(\@from) . ($message ? "\n\n$message" : "\n")
+ $message = " From: " . $self->Format(\@from) . ($message ? "$newline$newline$message" : $newline)
if @from;
if ($message) {
- my $sep = "-" x 72;
+ my $sep = $Format eq 'text/html' ? '<hr />' : "-" x 72;
$message = "$sep\n$message$sep\n";
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-nonwatcherrecipients
More information about the Bps-public-commit
mailing list