4 $RT::Logger->debug('Make sure templates all have known types');
6 # We update all NULL rows, below. We want to find non-NULL
7 # rows, which weren't created by the current codebase running
8 # through earlier initialdatas. Type != 'Perl' enforces the
9 # non-NULL part, as well
10 my $templates = RT::Templates->new(RT->SystemUser);
17 if ($templates->Count) {
18 die "You have templates with Type already set. This will interfere with your upgrade because RT used to ignore the template Type field, but now uses it.";
21 $templates = RT::Templates->new(RT->SystemUser);
27 while (my $template = $templates->Next) {
28 my ($status, $msg) = $template->SetType('Perl');
29 $RT::Logger->warning( "Couldn't change Type of Template #" . $template->Id . ": $msg" ) unless $status;
34 $RT::Logger->debug('Adding ExecuteCode right to principals that currently have ModifyTemplate or ModifyScrips');
36 my $acl = RT::ACL->new(RT->SystemUser);
40 VALUE => 'ModifyTemplate',
41 ENTRYAGGREGATOR => 'OR',
46 VALUE => 'ModifyScrips',
47 ENTRYAGGREGATOR => 'OR',
50 while (my $ace = $acl->Next) {
51 my $principal = $ace->PrincipalObj;
52 next if $principal->HasRight(
53 Right => 'ExecuteCode',
54 Object => $RT::System,
57 my ($ok, $msg) = $principal->GrantRight(
58 Right => 'ExecuteCode',
59 Object => $RT::System,
63 $RT::Logger->warn("Unable to grant ExecuteCode on principal " . $principal->id . ": $msg");