summaryrefslogtreecommitdiff
path: root/rt/etc/upgrade/4.0.1/content
blob: 9b74ff1a840a8efd96d082ab1448b3872cf20cd0 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@Initial = (
    sub {
        use strict;
        $RT::Logger->debug('Removing all delegated rights');

        my $acl = RT::ACL->new(RT->SystemUser);
        my $groupjoin = $acl->NewAlias('Groups');
        $acl->Join( ALIAS1 => 'main',
                    FIELD1 => 'PrincipalId',
                    ALIAS2 => $groupjoin,
                    FIELD2 => 'id'
                  );
        $acl->Limit( ALIAS           => $groupjoin,
                     FIELD           => 'Domain',
                     OPERATOR        => '=',
                     VALUE           => 'Personal',
                    );

        while ( my $ace = $acl->Next ) {
            my ( $ok, $msg ) = $ace->Delete();

            if ( !$ok ) {
                $RT::Logger->warn( "Unable to delete ACE " . $ace->id . ": " . $msg );
            }
        }

        my $groups = RT::Groups->new(RT->SystemUser);
        $groups->Limit( FIELD    => 'Domain',
                        OPERATOR => '=',
                        VALUE    => 'Personal'
                      );
        while ( my $group = $groups->Next ) {
            my $members = $group->MembersObj();
            while ( my $member = $members->Next ) {
                my ( $ok, $msg ) = $group->DeleteMember( $member->MemberId );
                if ( !$ok ) {
                    $RT::Logger->warn(   "Unable to remove group member "
                                       . $member->id . ": "
                                       . $msg );
                }
            }
            $group->PrincipalObj->Delete;
            $group->RT::Record::Delete();
        }
    },
    sub {
        use strict;
        $RT::Logger->debug('Removing all Delegate and PersonalGroup rights');

        my $acl = RT::ACL->new(RT->SystemUser);
        for my $right (qw/AdminOwnPersonalGroups AdminAllPersonalGroups DelegateRights/) {
            $acl->Limit( FIELD => 'RightName', VALUE => $right );
        }

        while ( my $ace = $acl->Next ) {
            my ( $ok, $msg ) = $ace->Delete();
            $RT::Logger->debug("Removing ACE ".$ace->id." for right ".$ace->__Value('RightName'));

            if ( !$ok ) {
                $RT::Logger->warn( "Unable to delete ACE " . $ace->id . ": " . $msg );
            }
        }
    },
    sub {
        use strict;
        $RT::Logger->debug('Removing unimplemented RejectTicket and ModifyTicketStatus rights');

        my $acl = RT::ACL->new(RT->SystemUser);
        for my $right (qw/RejectTicket ModifyTicketStatus/) {
            $acl->Limit( FIELD => 'RightName', VALUE => $right );
        }

        while ( my $ace = $acl->Next ) {
            my ( $ok, $msg ) = $ace->Delete();
            $RT::Logger->debug("Removing ACE ".$ace->id." for right ".$ace->__Value('RightName'));

            if ( !$ok ) {
                $RT::Logger->warn( "Unable to delete ACE " . $ace->id . ": " . $msg );
            }
        }
    },
);