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