7 my %global = %{ RT->System->AvailableRights };
8 my $handle = RT->DatabaseHandle;
10 for my $role (RT::System->Roles) {
11 my $group = RT::Group->new( RT->SystemUser );
12 my ($ok, $msg) = $group->LoadRoleGroup(
18 RT->Logger->error("Can't load role group $role: $msg");
22 my %rights = %{ RT->System->AvailableRights( $group->PrincipalObj ) };
24 # Global rights which aren't available on the role anymore
25 my @remove = grep { not $rights{$_} }
27 my $placeholders = join ",", map { "?" } 1 .. scalar @remove;
31 WHERE PrincipalType = ?
33 AND ObjectType = 'RT::System'
34 AND RightName IN ($placeholders)
37 my $res = $handle->SimpleQuery(
40 $group->PrincipalId, # Id
41 @remove, # Right names
45 RT->Logger->error("Failed to delete invalid rights on system role $role!");