I really needed more than the requestor’s email. I created a new scrip
action and modified RT::Template a bit to to get a real UserObj into my
new template. RT now sends our custom RMA form to requestors whenever a
ticket is moved into our site’s rma queue. It is klugie, but works
well. What is really needed is a new “rma” object which can be attached
to a ticket. I’ve included some of the details below.
RT is sweet. I’m having so much fun.
ashley
The Action:
I set up the scrip action NotifyRequestorOwnerCcWithRMA. The action had
to provide a UserObj to the template RMA form. The stock RT template
system only receives a TicketObj and a TransactionObj. First I created
a new action which grabs the UserObj of the first requester of the
ticket and passes it to the template handler. The ugly part is there
can be only_one requester per ticket: since RT::Requestors
returns a hash of Watcher objects, there is no way to guarentee the
which requestor will be grabbed for a UserObj if there are more than
one.
These are the relevent parts of rt2/lib/RT/Action/NotifyWithRMA.pm:
package RT::Action::NotifyWithRMA;
require RT::Action::SendEmail;
require RT::Action::Notify;
@ISA = qw(RT::Action::Notify);
{{{ sub Prepare
Same as RT::Action::Sendmail::Prepare but adds a $UserObj to the call
to RT::Template::Parse.
sub Prepare {
snip
Ashley’s hack
Get a user object from $self->TicketObj
$RT::Logger->debug(“RT::Action::NotifyWithRMA.pm\n”);
my $UserObj = $self->TicketObj->Requestors->Next->OwnerObj();
$RT::Logger->debug(“$UserObj\n”);
Ashley added the UserObj
$self->TemplateObj->Parse(Argument => $self->Argument,
TicketObj => $self->TicketObj,
TransactionObj => $self->TransactionObj,
UserObj => $UserObj);
snip
Next I modified RT::Template to accept a UserObj. This was just a minor
change in RT::Template::_ParseContent:
{{{ sub _ParseContent
Perform Template substitutions on the Body
Ashley’s hack: include a UserObj in $T
sub ParseContent {
my $self=shift;
my %args = ( Argument => undef,
TicketObj => undef,
UserObj => undef, # Ashley’s hack
TransactionObj => undef,
@);
$RT::Logger->debug(“RT::Template: $args{‘UserObj’}\n”);
Might be subject to change
require Text::Template;
$T::Ticket = $args{‘TicketObj’};
$T::Transaction = $args{‘TransactionObj’};
$T::Argument = $args{‘Argument’};
$T::rtname=$RT::rtname;
$T::WebRT=$RT::WebRT;
$T::User = $args{‘UserObj’}; # Ashley’s hack
$RT::Logger->debug(“RT::Template: $T::User\n”);
We need to untaint the content of the template, since we’ll be working
with it
my $content = $self->Content();
$content =~ s/^(.*)$/$1/;
$template=Text::Template->new(TYPE=>STRING,
SOURCE=>$content);
return ($template->fill_in(PACKAGE=>T));
}
}}}On Sat, Nov 17, 2001 at 01:39:45PM -0500, Jesse Vincent wrote:
On Fri, Nov 16, 2001 at 08:49:41PM -0800, Ashley Gould wrote:
HI list,
I’m creating a template which sends a filled in RMA form to requestors.
I need to catch the requestor’s user information. But from what I can
see a TemplateObj only knows about Ticket objects and Transaction objects.
And something called Argument:
So, you can get the Requestors out of the ticket object like this:
{ $Ticket->RequestorsAsString }
–
http://www.bestpractical.com/products/rt – Trouble Ticketing. Free.