[Bps-public-commit] rt-extension-notificationmatrix branch, master, updated. ee630cf68e2c9a6ecf66351366761cd3a6402617
Chia-liang Kao
clkao at bestpractical.com
Sun Jun 27 00:22:13 EDT 2010
The branch, master has been updated
via ee630cf68e2c9a6ecf66351366761cd3a6402617 (commit)
via f402a2f9ea05e110c47d72921f62507008134f11 (commit)
via 4b6e22e479fedb290fbcd56f9c73b924dbbf8d7f (commit)
via cb401ea553c888404ac2ef335866b31db08927f9 (commit)
via d2cd0362ef061327500401118d957af3d1ee1776 (commit)
via 4788e4c075cbe9a09c4ccd63ebee6b3905bebb67 (commit)
via e3e9df42c8ea8369aa62d805497acc2a1496a687 (commit)
from 8cdc9a4c0917689b6717b3956ba55abf9ab6bf96 (commit)
Summary of changes:
html/Admin/Queues/NotificationMatrix.html | 57 +++++++++++++++-----
.../Admin/Elements/QueueTabs/Default | 14 +++++
lib/RT/Extension/NotificationMatrix.pm | 1 +
.../NotificationMatrix/Rule/TicketTaken.pm | 2 +-
.../Rule/TicketUpdatedExternally.pm | 28 ++++++++++
t/basic.t | 30 ++++++++++-
6 files changed, 115 insertions(+), 17 deletions(-)
create mode 100644 html/Callbacks/NotificationMatrix/Admin/Elements/QueueTabs/Default
create mode 100644 lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
- Log -----------------------------------------------------------------
commit e3e9df42c8ea8369aa62d805497acc2a1496a687
Author: Chia-liang Kao <clkao at clkao.org>
Date: Thu Jun 24 23:08:59 2010 +0800
use real rule names.
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index 4dbcc28..4e05068 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -64,7 +64,7 @@ $Groups->LimitToRolesForQueue($QueueObj->Id);
my @groups = @{ $Groups->ItemsArrayRef };
-my @actions = qw(TicketCreated OnComment OnResolve);
+my @actions = qw(TicketCreated TicketCommented TicketTaken TicketResolved QueueChanged);
my $matrix;
my $UserGroups;
commit 4788e4c075cbe9a09c4ccd63ebee6b3905bebb67
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 10:56:02 2010 +0800
minor cleanup
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index 4e05068..0d3fda2 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -92,8 +92,7 @@ if ($ARGS{SetMatrix}) {
$QueueObj->SetAttribute(Name => 'NotificationMatrix', Description => 'Notification Matrix Internal Data', Content => $matrix);
}
else {
- my $attr = $QueueObj->FirstAttribute('NotificationMatrix');
- $matrix = $attr ? $attr->Content : {};
+ $matrix = RT::Extension::NotificationMatrix->get_queue_matrix($QueueObj);
}
my $group_hash = { map { $_->Id => 1 } @groups };
commit d2cd0362ef061327500401118d957af3d1ee1776
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 11:40:51 2010 +0800
fix misplaced tag
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index 0d3fda2..dc5db18 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -20,9 +20,9 @@ Find User defined groups:
% }
<& /Elements/Submit, Name => "Save", Label => loc('Subscribe to Queue notification') &>
+</form>
% }
-</form>
<form method="post">
<input type="hidden" name="SetMatrix" value="1">
commit cb401ea553c888404ac2ef335866b31db08927f9
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 11:41:12 2010 +0800
UI tweaks.
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index dc5db18..f15c9f5 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -4,6 +4,30 @@
current_tab => 'Admin/Queues/NotificationMatrix.html?id='.$id,
Title => $title &>
+<style type="text/css" media="screen">
+table.notification-matrix tr.sep {
+ border: 0 0 1 0 #000000 solid;
+}
+
+table.notification-matrix tr.group-type th {
+ width: 10em;
+}
+
+table.notification-matrix th.action {
+ text-align: left;
+}
+
+table.notification-matrix th.group-item {
+ text-align: center;
+ width: 5em;
+}
+
+table.notification-matrix td {
+ text-align: center;
+}
+
+</style>
+
<form method="post">
Find User defined groups:
<input name="GroupString" value="<% $GroupString %>">
@@ -27,16 +51,23 @@ Find User defined groups:
<form method="post">
<input type="hidden" name="SetMatrix" value="1">
<table class="notification-matrix">
-<tr>
-<th>\</th>
-% for my $Group (@groups) {
- <th><% $Group->SelfDescription %></th>
+<tr class="group-type">
+<th></th>
+<th colspan="<% scalar @groups %>">Ticket Roles</th>
+% if (@user_groups) {
+<th colspan="<% scalar @user_groups %>">User Defined Groups</th>
+% }
+</tr>
+<tr class="sep">
+<th></th>
+% for my $Group (@groups, @user_groups) {
+ <th class="group-item"><% $Group->Domain eq 'UserDefined' ? $Group->Name : $Group->Type %></th>
% }
</tr>
% for my $action (@actions) {
<tr>
-<th><% $action %></th>
-% for my $Group (@groups) {
+<th class="action"><% $action %></th>
+% for my $Group (@groups, @user_groups) {
<td><input type="checkbox" name="NM-<% $action %>-<% $Group->Id %>" <% $matrix_hash->{$action}{$Group->Id} ? 'checked' : '' %> />
</td>
% }
@@ -63,7 +94,7 @@ my $Groups = RT::Groups->new($session{'CurrentUser'});
$Groups->LimitToRolesForQueue($QueueObj->Id);
my @groups = @{ $Groups->ItemsArrayRef };
-
+my @user_groups;
my @actions = qw(TicketCreated TicketCommented TicketTaken TicketResolved QueueChanged);
my $matrix;
@@ -80,7 +111,7 @@ if ($ARGS{SelectUserGroup}) {
for (map { s/SelectUserGroup-// ? $_ : () } keys %ARGS) {
my $group = RT::Group->new($session{'CurrentUser'});
$group->LoadUserDefinedGroup($_);
- push @groups, $group if $group->Id;
+ push @user_groups, $group if $group->Id;
}
}
@@ -100,12 +131,11 @@ my $matrix_hash = { map { $_ => { map { $_ => 1 } @{$matrix->{$_}} } } keys %$ma
use List::MoreUtils qw(uniq);
-
for (uniq map { @{$matrix->{$_}} } keys %$matrix) {
unless ($group_hash->{$_}) {
my $group = RT::Group->new($session{'CurrentUser'});
$group->LoadUserDefinedGroup($_);
- push @groups, $group if $group->Id;
+ push @user_groups, $group if $group->Id;
}
}
commit 4b6e22e479fedb290fbcd56f9c73b924dbbf8d7f
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 12:02:58 2010 +0800
silence a warning.
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketTaken.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketTaken.pm
index 5abde86..f029e1d 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule/TicketTaken.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketTaken.pm
@@ -9,7 +9,7 @@ sub ConditionMatched {
my $self = shift;
my $txn = $self->TransactionObj;
- return ($txn->Field eq 'Owner' && $txn->OldValue == $RT::Nobody->Id)
+ return ($txn->Field && $txn->Field eq 'Owner' && $txn->OldValue == $RT::Nobody->Id)
}
1;
commit f402a2f9ea05e110c47d72921f62507008134f11
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 12:03:59 2010 +0800
ticket updated externally rule.
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index f15c9f5..6b50f12 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -95,7 +95,7 @@ $Groups->LimitToRolesForQueue($QueueObj->Id);
my @groups = @{ $Groups->ItemsArrayRef };
my @user_groups;
-my @actions = qw(TicketCreated TicketCommented TicketTaken TicketResolved QueueChanged);
+my @actions = qw(TicketCreated TicketCommented TicketTaken TicketResolved TicketUpdatedExternally QueueChanged);
my $matrix;
my $UserGroups;
diff --git a/lib/RT/Extension/NotificationMatrix.pm b/lib/RT/Extension/NotificationMatrix.pm
index 25ed776..a343adf 100644
--- a/lib/RT/Extension/NotificationMatrix.pm
+++ b/lib/RT/Extension/NotificationMatrix.pm
@@ -11,6 +11,7 @@ RT::Ruleset->Add(
'RT::Extension::NotificationMatrix::Rule::TicketCommented',
'RT::Extension::NotificationMatrix::Rule::TicketTaken',
'RT::Extension::NotificationMatrix::Rule::TicketResolved',
+ 'RT::Extension::NotificationMatrix::Rule::TicketUpdatedExternally',
'RT::Extension::NotificationMatrix::Rule::QueueChanged',
]);
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
new file mode 100644
index 0000000..40e5e1e
--- /dev/null
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketUpdatedExternally.pm
@@ -0,0 +1,28 @@
+package RT::Extension::NotificationMatrix::Rule::TicketUpdatedExternally;
+use strict;
+use warnings;
+use base 'RT::Extension::NotificationMatrix::Rule';
+
+use constant NM_Entry => 'TicketUpdatedExternally';
+
+sub ConditionMatched {
+ my $self = shift;
+ return unless $self->ScripConditionMatched("On Correspond");
+
+ my @groups = ((map { my $g = RT::Group->new($self->CurrentUser);
+ $g->LoadQueueRoleGroup(Queue => $self->TicketObj->QueueObj->Id, Type => $_);
+ $g;
+ } qw(Cc Owner)),
+ (map { my $g = RT::Group->new($self->CurrentUser);
+ $g->LoadTicketRoleGroup(Ticket => $self->TicketObj->Id, Type => $_);
+ $g;
+ } qw(Cc Owner)));
+
+ for (@groups) {
+ return if $_->HasMember($self->TransactionObj->CreatorObj->PrincipalId);
+ }
+
+ return 1;
+}
+
+1;
diff --git a/t/basic.t b/t/basic.t
index 88e1d7e..e2bda44 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -10,7 +10,7 @@ BEGIN {
}
use RT;
-use RT::Test tests => 9;
+use RT::Test tests => 14;
use RT::Test::Email;
RT->Config->Set( LogToScreen => 'debug' );
RT->Config->Set('Plugins',qw(RT::Extension::NotificationMatrix));
@@ -86,6 +86,7 @@ $cu->Load( $users{user_b} );
my $t = RT::Ticket->new($cu);
+# no rules defined, no mail
mail_ok {
($tid, $ttrans, $tmsg) =
$t->Create(Subject => "a test",
@@ -106,6 +107,7 @@ $owners->LoadQueueRoleGroup(Queue => $q->Id, Type => 'Owner');
my $matrix = { TicketCreated => [ $owners->id, $groups{group_a}->id ],
TicketTaken => [ $groups{group_b}->id ],
+ TicketUpdatedExternally => [ $owners->id ],
};
$q->SetAttribute(Name => 'NotificationMatrix',
@@ -117,7 +119,6 @@ $q->SetAttribute(Name => 'NotificationMatrix',
mail_ok {
($tid, $ttrans, $tmsg) =
$t->Create(Subject => "a test",
-# Owner => "user_a",
Requestor => 'user_b',
Queue => $q->Id,
AdminCc => 'user_c',
@@ -139,6 +140,31 @@ mail_ok {
};
+mail_ok {
+ my $cu = RT::CurrentUser->new;
+ $cu->Load( $users{user_b} );
+ $t->SetCurrentUser($cu);
+ my $t2 = RT::Ticket->new($cu);
+ $t2->Load($t->id);
+ my ($res, $msg) = $t2->Correspond(Content => "foobar");
+ ok($res, $msg);
+};
+
+mail_ok {
+ my $cu = RT::CurrentUser->new;
+ $cu->Load( $users{user_a} );
+ $t->SetCurrentUser($cu);
+ my $t2 = RT::Ticket->new($cu);
+ $t2->Load($t->id);
+ my ($res, $msg) = $t2->Correspond(Content => "foobar");
+ ok($res, $msg);
+} { from => qr'USER_A via RT',
+ to => 'user_b at company.com',
+ subject => qr/a test/,
+ body => qr/foobar/,
+};
+
+
#my ($baseurl, $m) = RT::Test->started_ok;
#diag "$baseurl/?user=root&pass=password"; sleep 1 while 1;
commit ee630cf68e2c9a6ecf66351366761cd3a6402617
Author: Chia-liang Kao <clkao at clkao.org>
Date: Sun Jun 27 12:23:19 2010 +0800
menu hook.
diff --git a/html/Callbacks/NotificationMatrix/Admin/Elements/QueueTabs/Default b/html/Callbacks/NotificationMatrix/Admin/Elements/QueueTabs/Default
new file mode 100644
index 0000000..9db7ae5
--- /dev/null
+++ b/html/Callbacks/NotificationMatrix/Admin/Elements/QueueTabs/Default
@@ -0,0 +1,14 @@
+<%init>
+if ($QueueObj) {
+
+ my $path = 'Admin/Queues/NotificationMatrix.html?id='. $QueueObj->Id;
+ $tabs->{'this'}{'subtabs'}{'z-nm'} = {
+ title => loc('Notification'),
+ path => $path
+ };
+}
+</%init>
+<%args>
+$QueueObj => undef
+$tabs => undef
+</%args>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list