Upgrade to 4.2.8
[usit-rt.git] / etc / upgrade / 3.9.2 / content
1 use strict;
2 use warnings;
3
4 our @Initial = (
5     sub {
6         RT->Logger->debug('Removing all delegated rights');
7
8         my $acl = RT::ACL->new(RT->SystemUser);
9         $acl->Limit( CLAUSE   => 'search',
10                      FIELD    => 'DelegatedBy',
11                      OPERATOR => '>',
12                      VALUE    => '0'
13                    );
14         $acl->Limit( CLAUSE          => 'search',
15                      FIELD           => 'DelegatedFrom',
16                      OPERATOR        => '>',
17                      VALUE           => '0',
18                      ENTRYAGGREGATOR => 'OR',
19                    );
20
21         while ( my $ace = $acl->Next ) {
22             my ( $ok, $msg ) = $ace->Delete();
23
24             if ( !$ok ) {
25                 RT->Logger->warn(
26                            "Unable to delete ACE " . $ace->id . ": " . $msg );
27             }
28         }
29
30         my $groups = RT::Groups->new(RT->SystemUser);
31         $groups->Limit( FIELD    => 'Domain',
32                         OPERATOR => '=',
33                         VALUE    => 'Personal',
34                         CASESENSITIVE => 0,
35                       );
36         while ( my $group = $groups->Next ) {
37             my $members = $group->MembersObj();
38             while ( my $member = $members->Next ) {
39                 my ( $ok, $msg ) = $group->DeleteMember( $member->MemberId );
40                 if ( !$ok ) {
41                     RT->Logger->warn(   "Unable to remove group member "
42                                        . $member->id . ": "
43                                        . $msg );
44                 }
45             }
46             $group->PrincipalObj->Delete;
47             $group->RT::Record::Delete();
48         }
49     },
50 );
51