summaryrefslogtreecommitdiff
path: root/rt/sbin/rt-dump-metadata.in
diff options
context:
space:
mode:
Diffstat (limited to 'rt/sbin/rt-dump-metadata.in')
-rw-r--r--rt/sbin/rt-dump-metadata.in53
1 files changed, 11 insertions, 42 deletions
diff --git a/rt/sbin/rt-dump-metadata.in b/rt/sbin/rt-dump-metadata.in
index 29c44d763..2b5747645 100644
--- a/rt/sbin/rt-dump-metadata.in
+++ b/rt/sbin/rt-dump-metadata.in
@@ -54,22 +54,15 @@ use warnings;
binmode( STDOUT, ":utf8" );
# fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
require File::Spec;
- my @libs = ( "@RT_LIB_PATH@", "@LOCAL_LIB_PATH@" );
+ require Cwd;
+ my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
my $bin_path;
for my $lib (@libs) {
unless ( File::Spec->file_name_is_absolute($lib) ) {
- unless ($bin_path) {
- if ( File::Spec->file_name_is_absolute(__FILE__) ) {
- $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
- } else {
- require FindBin;
- no warnings "once";
- $bin_path = $FindBin::Bin;
- }
- }
+ $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
$lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
}
unshift @INC, $lib;
@@ -77,26 +70,16 @@ BEGIN {
}
-use Getopt::Long;
+use RT::Interface::CLI qw(Init);
my %opt;
-GetOptions( \%opt, "help|h",
+Init( \%opt,
"limit-to-privileged|l",
"skip-disabled|s",
"all|a",
);
-if ( $opt{help} ) {
- require Pod::Usage;
- Pod::Usage::pod2usage( { verbose => 2 } );
- exit;
-}
-
-require RT;
require XML::Simple;
-RT::LoadConfig();
-RT::Init();
-
my %RV;
my %Ignore = (
All => [
@@ -104,11 +87,6 @@ my %Ignore = (
id Created Creator LastUpdated LastUpdatedBy
)
],
- Templates => [
- qw(
- TranslationOf
- )
- ],
);
my $SystemUserId = RT->SystemUser->Id;
@@ -117,7 +95,6 @@ my @classes = qw(
Templates Scrips ACL CustomFields
);
foreach my $class (@classes) {
- require "RT/$class.pm";
my $objects = "RT::$class"->new( RT->SystemUser );
$objects->{find_disabled_rows} = 1 unless $opt{'skip-disabled'};
$objects->UnLimit;
@@ -126,7 +103,8 @@ foreach my $class (@classes) {
$objects->Limit(
FIELD => 'Domain',
OPERATOR => '=',
- VALUE => 'UserDefined'
+ VALUE => 'UserDefined',
+ CASESENSITIVE => 0,
) if $class eq 'Groups';
if ( $class eq 'CustomFields' ) {
@@ -182,6 +160,7 @@ OBJECT:
foreach my $key ( map "$record$_", ( '', 'Id' ) ) {
next unless exists $rv->{$key};
my $id = $rv->{$key} or next;
+ next unless $id =~ /^\d+$/;
my $obj = "RT::$record"->new( RT->SystemUser );
$obj->LoadByCols( Id => $id ) or next;
$rv->{$key} = $obj->__Value('Name') || 0;
@@ -244,7 +223,7 @@ OBJECT:
# An internal user group
if ( /^SystemInternal$/ ) {
$rv->{GroupDomain} = $group->Domain;
- $rv->{GroupType} = $group->Type;
+ $rv->{GroupType} = $group->Name;
}
# An individual user
elsif ( /^ACLEquivalence$/ ) {
@@ -269,19 +248,9 @@ OBJECT:
$rv->{GroupDomain} = 'RT::Queue-Role';
}
}
- if ( $obj->LookupType eq 'RT::Queue-RT::Ticket' ) {
- # XXX-TODO: unused CF's turn into global CF when importing
- # as the sub InsertData in RT::Handle creates a global CF
- # when no queue is specified.
- $rv->{Queue} = [];
- my $applies = $obj->AppliedTo;
- while ( my $queue = $applies->Next ) {
- push @{ $rv->{Queue} }, $queue->Name;
- }
- }
}
- if ( eval { require RT::Attributes; 1 } ) {
+ if ( RT::Attributes->require ) {
my $attributes = $obj->Attributes;
while ( my $attribute = $attributes->Next ) {
my $content = $attribute->Content;