rt 4.0.20 (RT#13852)
[freeside.git] / rt / etc / upgrade / 3.8.9 / content
1 @Initial = (
2     sub {
3         use strict;
4         $RT::Logger->debug('Make sure local links are local');
5
6         use RT::URI::fsck_com_rt;
7         my $prefix = RT::URI::fsck_com_rt->LocalURIPrefix . '/ticket/';
8
9         foreach my $dir (qw(Target Base)) {
10             my $found;
11             do {
12                 $found = 0;
13                 my $links = RT::Links->new( RT->SystemUser );
14                 $links->Limit( FIELD => $dir, OPERATOR => 'STARTSWITH', VALUE => $prefix );
15                 $links->Limit( FIELD => 'Local'.$dir, VALUE => 0 );
16                 $links->Limit(
17                     ENTRYAGGREGATOR => 'OR',
18                     FIELD => 'Local'.$dir,
19                     OPERATOR => 'IS',
20                     VALUE => 'NULL',
21                 );
22                 $links->RowsPerPage( 1000 );
23                 while ( my $link = $links->Next ) {
24                     $found++;
25                     my $uri = $link->$dir();
26                     $uri =~ s/^\Q$prefix//;
27                     if ( int($uri) eq $uri && $uri > 0 ) {
28                         my $method = 'SetLocal'. $dir;
29                         my ($status, $msg) = $link->$method( $uri );
30                         unless ( $status ) {
31                             die "Couldn't change local $dir: $msg";
32                         }
33                     } else {
34                         die "$dir URI looks like local, but is not parseable";
35                     }
36                 }
37             } while $found == 1000;
38         }
39     },
40     sub {
41         my $queue = RT::Queue->new( $RT::SystemUser );
42         $queue->Load('___Approvals');
43         return unless $queue->id;
44
45         for my $name (
46             'All Approvals Passed', 'Approval Passed', 'Approval Rejected'
47           )
48         {
49             my $template = RT::Template->new($RT::SystemUser);
50             $template->LoadQueueTemplate( Name => $name, Queue => $queue->id );
51             next unless $template->id;
52             my $content = $template->Content;
53
54             # there is only one OwnerObj->Name normally, so no need /g
55             if ( $content =~
56 s!(?<=Your ticket has been (?:approved|rejected) by { eval { )\$Approval->OwnerObj->Name!\$Approver->Name!
57               )
58             {
59                 $template->SetType('Perl');
60                 $template->SetContent($content);
61             }
62         }
63     },
64 );