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