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