[Bps-public-commit] rt-extension-notificationmatrix branch, master, updated. 62b204fe086ed9dfe60174b15f57bfac81323fa2
Chia-liang Kao
clkao at bestpractical.com
Tue Jun 29 23:03:25 EDT 2010
The branch, master has been updated
via 62b204fe086ed9dfe60174b15f57bfac81323fa2 (commit)
via 69d64cfe10327c46d19f79c69997506e4b930fd9 (commit)
via 7b36a842e69e3e1654ad41c5b05d02412faacbf0 (commit)
via 96469da221dac828da0cd49f6d6087521efb4d56 (commit)
from ee630cf68e2c9a6ecf66351366761cd3a6402617 (commit)
Summary of changes:
lib/RT/Extension/NotificationMatrix.pm | 51 ++++++++++++++++++++
lib/RT/Extension/NotificationMatrix/Rule.pm | 24 ++++++++-
.../NotificationMatrix/Rule/TicketCommented.pm | 1 +
.../NotificationMatrix/Rule/TicketResolved.pm | 1 +
.../Rule/TicketUpdatedExternally.pm | 1 +
5 files changed, 76 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 96469da221dac828da0cd49f6d6087521efb4d56
Author: Chia-liang Kao <clkao at clkao.org>
Date: Wed Jun 30 10:47:42 2010 +0800
Load templates in a chain-of-responsibility fashion.
diff --git a/lib/RT/Extension/NotificationMatrix/Rule.pm b/lib/RT/Extension/NotificationMatrix/Rule.pm
index ce271c5..9aef0b1 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule.pm
@@ -42,13 +42,31 @@ sub ScripConditionMatched {
return $ConditionObj->IsApplicable();
}
+sub LoadTemplate {
+ my $self = shift;
+ my $template = RT::Template->new($self->CurrentUser);
+
+ my $name = ref($self);
+ $name =~ s/^RT::Extension::NotificationMatrix::Rule::// or die "unknown rule: $name";
+
+ for my $tname ($self->TicketObj->QueueObj->Name.'-'.$name, $name, 'Transaction') {
+ $template->Load($tname);
+ last if $template->Id;
+ }
+
+ unless ($template->Id) {
+ die 'Failed to load template for notification rule: '.$name;
+ }
+
+ return $template;
+}
+
sub Prepare {
my $self = shift;
my @recipients = $self->GetRecipients or return 0;
- my $template = RT::Template->new($self->CurrentUser);
- $template->Load('Transaction') or die;
+ my $template = $self->LoadTemplate;
# RT::Action weakens the following, so we need to keep additional references
my $ref = [RT::Scrip->new($self->CurrentUser),
{ _Message_ID => 0},
commit 7b36a842e69e3e1654ad41c5b05d02412faacbf0
Author: Chia-liang Kao <clkao at clkao.org>
Date: Wed Jun 30 10:54:55 2010 +0800
doc
diff --git a/lib/RT/Extension/NotificationMatrix.pm b/lib/RT/Extension/NotificationMatrix.pm
index a343adf..2b6a006 100644
--- a/lib/RT/Extension/NotificationMatrix.pm
+++ b/lib/RT/Extension/NotificationMatrix.pm
@@ -24,3 +24,54 @@ sub get_queue_matrix {
}
1;
+
+=head1 NAME
+
+RT::Extension::NotificationMatrix - RT Extension for custom ticket notification
+
+=head1 SYNOPSIS
+
+ # In your RT site config:
+ Set(@Plugins,(qw(RT::Extension::NotificationMatrix));
+
+=head1 DESCRIPTION
+
+This plugin provides per-queue configuration for notification
+triggering based on ticket actions, and notification delivery for
+selected ticket roles and/or user-defined groups.
+
+Note that this plugin can co-exist with the L<RT::Scrip>-based
+notification, which you probably want to disable to avoid duplicated
+messages.
+
+When the plugin is enabled, you will have an additional
+C<Notification> tab in the queue admin page. When a notification rule
+is triggered, the designated ticket roles or user defined groups get a
+message with the first found template of:
+
+=over
+
+=item $QueueName-$RuleName
+
+For example: General-TicketResolved
+
+=item $RuleName
+
+For example: TicketResolved
+
+=item The default tempalte defined by the rule
+
+=item The C<Transaction> template
+
+=back
+
+=head1 CAVEATS
+
+Internally, the matrix is stored on the queue object as attributes,
+with mappings to the subscribe L<RT::Group> object ids. The role
+groups are stored as queue-role groups, as at the time of
+configuration we do not have ticket instances to create ticket-role
+groups. The queue-role gorups are then instantiated as ticket-role
+when the notification rules are triggered.
+
+=cut
commit 69d64cfe10327c46d19f79c69997506e4b930fd9
Author: Chia-liang Kao <clkao at clkao.org>
Date: Wed Jun 30 10:55:22 2010 +0800
per rule default template
diff --git a/lib/RT/Extension/NotificationMatrix/Rule.pm b/lib/RT/Extension/NotificationMatrix/Rule.pm
index 9aef0b1..e45643a 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule.pm
@@ -42,6 +42,8 @@ sub ScripConditionMatched {
return $ConditionObj->IsApplicable();
}
+sub DefaultTemplate {}
+
sub LoadTemplate {
my $self = shift;
my $template = RT::Template->new($self->CurrentUser);
@@ -49,7 +51,7 @@ sub LoadTemplate {
my $name = ref($self);
$name =~ s/^RT::Extension::NotificationMatrix::Rule::// or die "unknown rule: $name";
- for my $tname ($self->TicketObj->QueueObj->Name.'-'.$name, $name, 'Transaction') {
+ for my $tname ($self->TicketObj->QueueObj->Name.'-'.$name, $name, $self->DefaultTemplate, 'Transaction') {
$template->Load($tname);
last if $template->Id;
}
commit 62b204fe086ed9dfe60174b15f57bfac81323fa2
Author: Chia-liang Kao <clkao at clkao.org>
Date: Wed Jun 30 10:59:39 2010 +0800
Fill in default templates.
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
index 1ea2d52..b9fe241 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
@@ -4,6 +4,7 @@ use warnings;
use base 'RT::Extension::NotificationMatrix::Rule';
use constant NM_Entry => 'TicketCommented';
+use constant DefaultTemplate => 'Admin Comment';
sub ConditionMatched {
my $self = shift;
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketResolved.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketResolved.pm
index 594cbd1..cb07d20 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule/TicketResolved.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketResolved.pm
@@ -4,6 +4,7 @@ use warnings;
use base 'RT::Extension::NotificationMatrix::Rule';
use constant NM_Entry => 'TicketResolved';
+use constant DefaultTemplate => 'Resolved';
sub ConditionMatched {
my $self = shift;
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
index 40e5e1e..b0001ef 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
@@ -4,6 +4,7 @@ use warnings;
use base 'RT::Extension::NotificationMatrix::Rule';
use constant NM_Entry => 'TicketUpdatedExternally';
+use constant DefaultTemplate => 'Admin Correspondence';
sub ConditionMatched {
my $self = shift;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list