As I was trying to get approvals to work using the CreateTicket action and instructions found on the wiki, I encoutered a few problems:<br><br>1. AdminCcs of ___Approvals weren't notified, because the approval action only notified the owner. Of course, there can't be more than one owner, so getting approval from a few people doesn't work.<br>
<br>2. The notice of approval said that the script was approved by "nobody", because there was no owner of the approval request. Using a normal change owner script didn't work, since the email was generated before the owner change would take effect.<br>
<br>So I fixed that by (1) using "Notify AdminCcs" instead of "Notify Owner", and (2) by changing the owner of the approval ticket, if it wasn't set.<br><br>The patch after the fold.<br><br>--<br>
Mathieu Longtin<br>
1-514-803-8977<br><br><br>diff -ur lib/RT/Approval/Rule/NewPending.pm local/lib/RT/Approval/Rule/NewPending.pm<br>--- lib/RT/Approval/Rule/NewPending.pm 2009-08-10 14:45:44.000000000 -0400<br>+++ local/lib/RT/Approval/Rule/NewPending.pm 2009-10-14 15:39:13.000000000 -0400<br>
@@ -75,7 +75,8 @@<br><br> # first txn entry of the approval ticket<br> local $self->{TransactionObj} = $to;<br>- $self->RunScripAction('Notify Owner', 'New Pending Approval', @_);<br>+ $self->RunScripAction('Notify AdminCcs', 'New Pending Approval', @_);<br>
+ #$self->RunScripAction('Notify Owner', 'New Pending Approval', @_);<br><br> return;<br><br>diff -ur lib/RT/Approval/Rule/Passed.pm local/lib/RT/Approval/Rule/Passed.pm<br>--- lib/RT/Approval/Rule/Passed.pm 2009-08-10 14:45:44.000000000 -0400<br>
+++ local/lib/RT/Approval/Rule/Passed.pm 2009-10-15 13:52:37.000000000 -0400<br>@@ -63,6 +63,19 @@<br> sub Commit {<br> my $self = shift;<br> my $note;<br>+<br>+ # Assign approval ticket to transaction creator, if it's not owned already<br>
+ if ( $self->TicketObj->Owner == $RT::Nobody->id ) {<br>+ my $ActorObj = $self->TransactionObj->CreatorObj;<br>+<br>+ $RT::Logger->info("Auto assigning ticket #".$self->TicketObj->id." to user ". $ActorObj->Name);<br>
+ my ($status, $msg) = $self->TicketObj->SetOwner( $ActorObj->id );<br>+ unless( $status ) {<br>+ $RT::Logger->warning("Error assigning ticket #".$self->TicketObj->id." to ".$ActorObj->Name.": ".$msg);<br>
+ return undef;<br>+ }<br>+ }<br>+<br> my $t = $self->TicketObj->Transactions;<br><br> while ( my $o = $t->Next ) {<br>diff -ur lib/RT/Approval/Rule/Rejected.pm local/lib/RT/Approval/Rule/Rejected.pm<br>
--- lib/RT/Approval/Rule/Rejected.pm 2009-08-10 14:45:44.000000000 -0400<br>+++ local/lib/RT/Approval/Rule/Rejected.pm 2009-10-15 14:01:30.000000000 -0400<br>@@ -63,6 +63,19 @@<br><br> sub Commit { # XXX: from custom prepare code<br>
my $self = shift;<br>+<br>+ # Assign approval ticket to transaction creator, if it's not owned already<br>+ if ( $self->TicketObj->Owner == $RT::Nobody->id ) {<br>+ my $ActorObj = $self->TransactionObj->CreatorObj;<br>
+<br>+ $RT::Logger->info("Auto assigning ticket #".$self->TicketObj->id." to user ". $ActorObj->Name);<br>+ my ($status, $msg) = $self->TicketObj->SetOwner( $ActorObj->id );<br>
+ unless( $status ) {<br>+ $RT::Logger->warning("Error assigning ticket #".$self->TicketObj->id." to ".$ActorObj->Name.": ".$msg);<br>+ return undef;<br>
+ }<br>+ }<br>+<br> if ( my ($rejected) =<br> $self->TicketObj->AllDependedOnBy( Type => 'ticket' ) ) {<br> my $note = '';<br><br>