[Bps-public-commit] rt-extension-nonwatcherrecipients branch add-html-content-option created. 1.02-4-g5fbf3b8
BPS Git Server
git at git.bestpractical.com
Tue Feb 8 17:37:37 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 5fbf3b8a440a2bb6caed86b72dfdf23893e1612b (commit)
- Log -----------------------------------------------------------------
commit 5fbf3b8a440a2bb6caed86b72dfdf23893e1612b
Author: Brad Embree <brad at bestpractical.com>
Date: Tue Feb 8 08:41:56 2022 -0800
Prep version 1.03
diff --git a/META.yml b/META.yml
index 2d55365..19cb7ed 100644
--- a/META.yml
+++ b/META.yml
@@ -24,7 +24,7 @@ requires:
resources:
license: http://opensource.org/licenses/gpl-license.php
repository: https://github.com/bestpractical/rt-extension-nonwatcherrecipients
-version: '1.02'
+version: '1.03'
x_module_install_rtx_version: '0.42'
x_requires_rt: 4.0.0
x_rt_too_new: 5.2.0
diff --git a/README b/README
index ffb735e..d5aebf5 100644
--- a/README
+++ b/README
@@ -26,6 +26,8 @@ DESCRIPTION
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.
+
INSTALLATION
perl Makefile.PL
make
@@ -56,18 +58,19 @@ INSTALLATION
Restart your webserver
USAGE
- If you run the make initdb step, a new global template called
- NonWatcherRecipients Admin Correspondence is installed on your system.
- You can then select this template for any scrips that use the standard
- Admin Correspondence template. We recommend the Admin Correspondence
- template because you'll need RT privileges to add the user to the
- ticket.
+ If you run the make initdb step, two new global templates called
+ NonWatcherRecipients Admin Correspondence and 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 Admin
+ Correspondence or Admin Correspondence in HTML templates. We recommend
+ the 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:
{ RT::Extension::NonWatcherRecipients->FindRecipients(
- Transaction => $Transaction, Ticket => $Ticket ) }
+ 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
@@ -78,8 +81,13 @@ METHODS
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 accepts either 'text/plain' or 'text/html' and defaults to
+ 'text/plain' if not specified.
Returns: a message to insert in a template
diff --git a/lib/RT/Extension/NonWatcherRecipients.pm b/lib/RT/Extension/NonWatcherRecipients.pm
index bd3f683..361486b 100644
--- a/lib/RT/Extension/NonWatcherRecipients.pm
+++ b/lib/RT/Extension/NonWatcherRecipients.pm
@@ -2,7 +2,7 @@ use strict;
use warnings;
package RT::Extension::NonWatcherRecipients;
-our $VERSION = '1.02';
+our $VERSION = '1.03';
=head1 NAME
commit c316f13a3f5c7dc0c143eff0c527236b75db0596
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 a8d509e..bd3f683 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,18 +75,19 @@ 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:
{ RT::Extension::NonWatcherRecipients->FindRecipients(
- Transaction => $Transaction, Ticket => $Ticket ) }
+ 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
@@ -98,8 +101,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 accepts either 'text/plain' or 'text/html' and defaults to 'text/plain'
+if not specified.
Returns: a message to insert in a template
commit e1e4e748f4974032a8037009d0f3583d3d352ffa
Author: Brad Embree <brad at bestpractical.com>
Date: Tue Feb 8 08:27:56 2022 -0800
Add Format parameter
diff --git a/lib/RT/Extension/NonWatcherRecipients.pm b/lib/RT/Extension/NonWatcherRecipients.pm
index 6149bfa..a8d509e 100644
--- a/lib/RT/Extension/NonWatcherRecipients.pm
+++ b/lib/RT/Extension/NonWatcherRecipients.pm
@@ -107,10 +107,12 @@ 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 $recipients; # List of recipients
+ my $Format = $args{Format};
+ my @recipients; # array of recipients
my $message = ""; # Message for template
unless ( $Transaction->Id and $Ticket->Id ){
@@ -128,24 +130,44 @@ sub FindRecipients {
# 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"
+ push @recipients, [ $hdr, $self->Format(\@new) ]
if @new;
}
- if ($recipients) {
- $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";
+ if (@recipients) {
+ if ( $Format eq 'text/plain' ) {
+ $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";
+ $message .= join "\n", map { " $_->[0]: " . $_->[1] } @recipients;
+ $message .= "\n";
+ }
+ else {
+ my $href = ${RT::WebURL} . 'Ticket/ModifyPeople.html?id=' . $Ticket->id;
+ $message = '<p>The following people received a copy of this email '
+ . 'but are not on the ticket. You may want to add them '
+ . 'before replying: <a href="' . $href . '">' . $href
+ . "</a></p>\n";
+ $message .= '<table border="0">' . "\n";
+ $message .= join "\n", map { '<tr><td align="right"><b>' . $_->[0] . ':</b></td><td>' . $_->[1] . '</td></tr>' } @recipients;
+ $message .= "\n</table>\n";
+ }
}
# 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")
- if @from;
+ if (@from) {
+ if ( $Format eq 'text/plain' ) {
+ $message = " From: " . $self->Format(\@from) . ($message ? "\n\n$message" : "\n");
+ }
+ else {
+ $message = '<p><b>From:</b> ' . $self->Format(\@from) . '</p>' . ($message ? "<br /><br />$message\n" : "<br />\n");
+ }
+ }
if ($message) {
- my $sep = "-" x 72;
+ my $sep = $Format eq 'text/plain' ? "-" x 72 : '<hr />';
$message = "$sep\n$message$sep\n";
}
commit d3fd154ba9957987a75786d2ba61b3c1e74a539f
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..4043cee 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 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 non-ticket-watchers receiving email on correspondence',
+ Content => <<' TEMPLATE',
+RT-Attach-Message: yes
+Content-Type: text/html
+
+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') }
+{$Transaction->Content(Type => "text/html");}
+ TEMPLATE
+ }
+);
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-nonwatcherrecipients
More information about the Bps-public-commit
mailing list