Permalink
Browse files

Add an option to skip disabled objects

  • Loading branch information...
1 parent 846f209 commit 27ab8d05874aee6b2313f0b8e343aa733d71b988 @giganteous committed Mar 14, 2013
Showing with 8 additions and 6 deletions.
  1. +8 −6 sbin/rt-dump-metadata.in
View
14 sbin/rt-dump-metadata.in
@@ -81,6 +81,7 @@ use Getopt::Long;
my %opt;
GetOptions( \%opt, "help|h",
"limit-to-privileged|l",
+ "skip-disabled|s",
);
if ( $opt{help} ) {
@@ -119,7 +120,7 @@ my @classes = qw(
foreach my $class (@classes) {
require "RT/$class.pm";
my $objects = "RT::$class"->new( RT->SystemUser );
- $objects->{find_disabled_rows} = 1;
+ $objects->{find_disabled_rows} = 1 unless $opt{'skip-disabled'};
$objects->UnLimit;
$objects->LimitToPrivileged if $class eq 'Users'
&& $opt{'limit-to-privileged'};
@@ -154,6 +155,7 @@ foreach my $class (@classes) {
}
my %fields;
+OBJECT:
while ( my $obj = $objects->Next ) {
next
if $obj->can('LastUpdatedBy')
@@ -218,16 +220,16 @@ foreach my $class (@classes) {
# 2) Pick a level: Granted on Queue, CF, CF+Queue, or Globally?
for ( $obj->ObjectType ) {
if ( /^RT::Queue$/ ) {
- #return if $obj->Object->Disabled;
+ next OBJECT if $opt{'skip-disabled'} && $obj->Object->Disabled;
$rv->{Queue} = $obj->Object->Name;
}
elsif ( /^RT::CustomField$/ ) {
- #return if $obj->Object->Disabled;
+ next OBJECT if $opt{'skip-disabled'} && $obj->Object->Disabled;
$rv->{CF} = $obj->Object->Name;
}
elsif ( /^RT::Group$/ ) {
# No support for RT::Group ACLs in RT::Handle yet.
- return;
+ next OBJECT;
}
elsif ( /^RT::System$/ ) {
# skip setting anything on $rv;
@@ -237,7 +239,7 @@ foreach my $class (@classes) {
# 3) Pick a Principal; User or Group or Role
if ( $obj->PrincipalType eq 'Group' ) {
- #return if $obj->PrincipalObj->Disabled;
+ next OBJECT if $opt{'skip-disabled'} && $obj->PrincipalObj->Disabled;
my $group = $obj->PrincipalObj->Object;
for ( $group->Domain ) {
# An internal user group
@@ -248,7 +250,7 @@ foreach my $class (@classes) {
# An individual user
elsif ( /^ACLEquivalence$/ ) {
my $member = $group->MembersObj->Next->MemberObj;
- #return if $member->Disabled;
+ next OBJECT if $opt{'skip-disabled'} && $member->Disabled;
$rv->{UserId} = $member->Object->Name;
}
# A group you created

0 comments on commit 27ab8d0

Please sign in to comment.