]> git.uio.no Git - usit-rt.git/blame - etc/upgrade/3.9.1/content
Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / etc / upgrade / 3.9.1 / content
CommitLineData
af59614d
MKG
1use strict;
2use warnings;
3
4our @Initial = (
01e3b242 5 sub {
af59614d 6 RT->Logger->debug('Make sure templates all have known types');
01e3b242
MKG
7
8 # We update all NULL rows, below. We want to find non-NULL
9 # rows, which weren't created by the current codebase running
10 # through earlier initialdatas. Type != 'Perl' enforces the
11 # non-NULL part, as well
12 my $templates = RT::Templates->new(RT->SystemUser);
13 $templates->Limit(
14 FIELD => 'Type',
15 OPERATOR => '!=',
16 VALUE => 'Perl',
17 );
18
19 if ($templates->Count) {
20 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 }
22
23 $templates = RT::Templates->new(RT->SystemUser);
24 $templates->Limit(
25 FIELD => 'Type',
26 OPERATOR => 'IS',
27 VALUE => 'NULL',
28 );
29 while (my $template = $templates->Next) {
30 my ($status, $msg) = $template->SetType('Perl');
af59614d 31 RT->Logger->warning( "Couldn't change Type of Template #" . $template->Id . ": $msg" ) unless $status;
01e3b242
MKG
32 }
33 },
34 sub {
af59614d 35 RT->Logger->debug('Adding ExecuteCode right to principals that currently have ModifyTemplate or ModifyScrips');
01e3b242
MKG
36
37 my $acl = RT::ACL->new(RT->SystemUser);
38 $acl->Limit(
39 FIELD => 'RightName',
40 OPERATOR => '=',
41 VALUE => 'ModifyTemplate',
42 ENTRYAGGREGATOR => 'OR',
43 );
44 $acl->Limit(
45 FIELD => 'RightName',
46 OPERATOR => '=',
47 VALUE => 'ModifyScrips',
48 ENTRYAGGREGATOR => 'OR',
49 );
50
51 while (my $ace = $acl->Next) {
52 my $principal = $ace->PrincipalObj;
53 next if $principal->HasRight(
54 Right => 'ExecuteCode',
55 Object => $RT::System,
56 );
57
58 my ($ok, $msg) = $principal->GrantRight(
59 Right => 'ExecuteCode',
60 Object => $RT::System,
61 );
62
63 if (!$ok) {
af59614d 64 RT->Logger->warn("Unable to grant ExecuteCode on principal " . $principal->id . ": $msg");
01e3b242
MKG
65 }
66 }
67 },
68);
69