diff options
author | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
commit | b4b0c7e72d7eaee2fbfc7022022c9698323203dd (patch) | |
tree | ba4cd21399e412c32fe3737eaa8478e3271509f9 /rt/etc/upgrade/3.8.4 | |
parent | 2dfda73eeb3eae2d4f894099754794ef07d060dd (diff) |
import rt 3.8.7
Diffstat (limited to 'rt/etc/upgrade/3.8.4')
-rw-r--r-- | rt/etc/upgrade/3.8.4/content | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/rt/etc/upgrade/3.8.4/content b/rt/etc/upgrade/3.8.4/content new file mode 100644 index 000000000..be5a6bf39 --- /dev/null +++ b/rt/etc/upgrade/3.8.4/content @@ -0,0 +1,59 @@ + +@Final = ( + sub { + $RT::Logger->debug("Going to correct arguments of NotifyGroup actions if you have any"); + use strict; + + my $actions = RT::ScripActions->new( $RT::SystemUser ); + $actions->Limit( + FIELD => 'ExecModule', + VALUE => 'NotifyGroup', + ); + $actions->Limit( + FIELD => 'ExecModule', + VALUE => 'NotifyGroupAsComment', + ); + + my $converter = sub { + my $arg = shift; + my @res; + foreach my $r ( @{ $arg } ) { + my $obj; + next unless $r->{'Type'}; + if( lc $r->{'Type'} eq 'user' ) { + $obj = RT::User->new( $RT::SystemUser ); + } elsif ( lc $r->{'Type'} eq 'group' ) { + $obj = RT::Group->new( $RT::SystemUser ); + } else { + next; + } + $obj->Load( $r->{'Instance'} ); + my $id = $obj->id; + next unless( $id ); + + push @res, $id; + } + + return join ',', @res; + }; + + require Storable; + while ( my $action = $actions->Next ) { + my $argument = $action->Argument; + my $new = ''; + local $@; + if ( my $struct = eval { Storable::thaw( $argument ) } ) { + $new = $converter->( $struct ); + } else { + $new = join /, /, grep length, split /[^0-9]+/, $argument; + } + next if $new eq $argument; + + my ($status, $msg) = $action->__Set( Field => 'Argument', Value => $new ); + $RT::Logger->warning( "Couldn't change argument value of the action: $msg" ) + unless $status; + } + }, +); + + |