Update httemplate/elements/selectlayers.html
[freeside.git] / rt / etc / upgrade / 3.8.4 / content
1
2 @Final = (
3     sub {
4         $RT::Logger->debug("Going to correct arguments of NotifyGroup actions if you have any");
5         use strict;
6
7         my $actions = RT::ScripActions->new( RT->SystemUser );
8         $actions->Limit(
9             FIELD => 'ExecModule',
10             VALUE => 'NotifyGroup',
11         );
12         $actions->Limit(
13             FIELD => 'ExecModule',
14             VALUE => 'NotifyGroupAsComment',
15         );
16
17         my $converter = sub {
18             my $arg = shift;
19             my @res;
20             foreach my $r ( @{ $arg } ) {
21                 my $obj;
22                 next unless $r->{'Type'};
23                 if( lc $r->{'Type'} eq 'user' ) {
24                     $obj = RT::User->new( RT->SystemUser );
25                 } elsif ( lc $r->{'Type'} eq 'group' ) {
26                     $obj = RT::Group->new( RT->SystemUser );
27                 } else {
28                     next;
29                 }
30                 $obj->Load( $r->{'Instance'} );
31                 my $id = $obj->id;
32                 next unless( $id );
33
34                 push @res, $id;
35             }
36
37             return join ',', @res;
38         };
39
40         require Storable;
41         while ( my $action = $actions->Next ) {
42             my $argument = $action->Argument;
43             my $new = '';
44             local $@;
45             if ( my $struct = eval { Storable::thaw( $argument ) } ) {
46                 $new = $converter->( $struct );
47             } else {
48                 $new = join /, /, grep length, split /[^0-9]+/, $argument;
49             }
50             next if $new eq $argument;
51
52             my ($status, $msg) = $action->__Set( Field => 'Argument', Value => $new );
53             $RT::Logger->warning( "Couldn't change argument value of the action: $msg" )
54                 unless $status;
55         }
56     },
57 );
58
59