X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fetc%2Fupgrade%2F3.8.3%2Fcontent;h=3147c87e274700fbfedae9397667041fd7664cfe;hp=b8052acde2b0d90529ae0ab21f47983ece332f86;hb=9aee669886202be7035e6c6049fc71bc99dd3013;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7 diff --git a/rt/etc/upgrade/3.8.3/content b/rt/etc/upgrade/3.8.3/content index b8052acde..3147c87e2 100644 --- a/rt/etc/upgrade/3.8.3/content +++ b/rt/etc/upgrade/3.8.3/content @@ -1,4 +1,7 @@ -@ScripConditions = ( +use strict; +use warnings; + +our @ScripConditions = ( { Name => 'On Reject', # loc Description => 'Whenever a ticket is rejected', # loc ApplicableTransTypes => 'Status', @@ -8,9 +11,9 @@ }, ); -@Final = ( +our @Final = ( sub { - $RT::Logger->debug("Going to correct descriptions of notify actions in the DB"); + RT->Logger->debug("Going to correct descriptions of notify actions in the DB"); my $actions = RT::ScripActions->new( RT->SystemUser ); $actions->Limit( @@ -23,11 +26,11 @@ ); while ( my $action = $actions->Next ) { my ($status, $msg) = $action->__Set( Field => 'Name', Value => 'Notify Owner, Requestors, Ccs and AdminCcs' ); - $RT::Logger->warning( "Couldn't change action name: $msg" ) + RT->Logger->warning( "Couldn't change action name: $msg" ) unless $status; ($status, $msg) = $action->__Set( Field => 'Description', Value => 'Send mail to owner and all watchers' ); - $RT::Logger->warning( "Couldn't change action description: $msg" ) + RT->Logger->warning( "Couldn't change action description: $msg" ) unless $status; } @@ -42,24 +45,24 @@ ); while ( my $action = $actions->Next ) { my ($status, $msg) = $action->__Set( Field => 'Name', Value => 'Notify Owner, Requestors, Ccs and AdminCcs as Comment' ); - $RT::Logger->warning( "Couldn't change action name: $msg" ) + RT->Logger->warning( "Couldn't change action name: $msg" ) unless $status; ($status, $msg) = $action->__Set( Field => 'Description', Value => 'Send mail to owner and all watchers as a "comment"' ); - $RT::Logger->warning( "Couldn't change action description: $msg" ) + RT->Logger->warning( "Couldn't change action description: $msg" ) unless $status; } - $RT::Logger->debug("Corrected descriptions of notify actions in the DB."); + RT->Logger->debug("Corrected descriptions of notify actions in the DB."); return 1; }, ); - +our (@ScripActions, @Scrips); { -$RT::Logger->debug("Going to add in Extract Subject Tag actions if they were missed during a previous upgrade"); +RT->Logger->debug("Going to add in Extract Subject Tag actions if they were missed during a previous upgrade"); -$actions = RT::ScripActions->new( RT->SystemUser ); +my $actions = RT::ScripActions->new( RT->SystemUser ); $actions->Limit( FIELD => 'ExecModule', VALUE => 'ExtractSubjectTag', @@ -67,10 +70,10 @@ $actions->Limit( my $extract_action = $actions->First; if ( $extract_action && $extract_action->Id ) { - $RT::Logger->debug("You appear to already have an Extract Subject Tag action, skipping"); + RT->Logger->debug("You appear to already have an Extract Subject Tag action, skipping"); return 1; } else { - $RT::Logger->debug("Didn't find an existing Extract Subject Tag action, adding it"); + RT->Logger->debug("Didn't find an existing Extract Subject Tag action, adding it"); push @ScripActions, ( { Name => 'Extract Subject Tag', # loc Description => 'Extract tags from a Transaction\'s subject and add them to the Ticket\'s subject.', # loc @@ -78,14 +81,24 @@ if ( $extract_action && $extract_action->Id ) { }, ); - $RT::Logger->debug("Adding Extract Subject Tag Scrip"); - push @Scrips, ( - { Description => "On transaction, add any tags in the transaction's subject to the ticket's subject", - ScripCondition => 'On Transaction', - ScripAction => 'Extract Subject Tag', - Template => 'Blank' - }, - ); + RT->Logger->debug("Adding Extract Subject Tag Scrip"); + push @Final, sub { + my $action = RT::ScripAction->new( RT->SystemUser ); + $action->Load( 'Extract Subject Tag' ); + my $condition = RT::ScripCondition->new( RT->SystemUser ); + $condition->Load( 'On Transaction' ); + my $template = RT::Template->new( RT->SystemUser ); + $template->LoadByName( Name => 'Blank', Queue => 0 ); + my $scrip = RT::Scrip->new( RT->SystemUser ); + $scrip->RT::Record::Create( + Description => "On transaction, add any tags in the transaction's subject to the ticket's subject", + ScripCondition => $condition->id, + ScripAction => $action->id, + Template => $template->id, + Stage => 'TransactionCreate', + Queue => 0, + ); + }; } }