[rt-users] Notify Potential Owners
Ian Norton
i.norton at lancaster.ac.uk
Mon Mar 14 06:15:46 EST 2005
Hi All,
I have a requirement to notify potential ticket owners in a particular
queue, so I've patched lib/RT/Action/Notify.pm to do what I needed.
I thought others may find this potentially useful so here's the patch:
<PATCH>
--- lib/RT/Action/Notify.pm 2005-02-01 14:20:40.000000000 +0000
+++ lib/RT/Action/Notify.pm 2005-03-08 14:15:32.860190560 +0000
@@ -79,7 +79,7 @@
my $arg = $self->Argument;
- $arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc/;
+ $arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc,PotentialOwners/;
my ( @To, @PseudoTo, @Cc, @Bcc );
@@ -138,6 +138,20 @@
push ( @Bcc,
$self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses
);
}
+ if ( $arg =~ /PotentialOwners/ ) {
+ # Find out who can own tickets in this queue.
+
+ my $Users = RT::Users->new($RT::SystemUser);
+ $Users->WhoHaveRight(Right => 'OwnTicket', Object =>
$self->TicketObj->
QueueObj, IncludeSystemRights => 1, IncludeSuperusers => 0);
+
+ my @users;
+
+ while (my $User = $Users->Next()) {
+ next if ($User->id == $RT::Nobody->id); # skip nobody here
+ push ( @To, $User->EmailAddress ) ;
+ }
+ }
+
if ($RT::UseFriendlyToLine) {
unless (@To) {
push (
</PATCH>
In addition, there's a database insert to do to use the patch:
INSERT INTO scripactions (name, description, execmodule, argument,
creator, lastupdatedby) VALUES ('Notify Potential Owners', 'Notify all
people who can potentially own this ticket', 'Notify',
'PotentialOwners', '1', '1');
This is using postgres psql, sorry I'm not familiar enough with the RT
API to do it in a nice db independent way :)
Thanks to all the people on the list who provide such great information
and discussion with problems.
I'd welcome comments on improvement for the above code.
Regards, Ian.
--
Ian Norton
Mail & Systems Support
University of Lancaster
More information about the rt-users
mailing list