X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-dump-database.in;h=cb9f0c3d3bc197543a822eb5ea9df1949c3569d0;hb=455e6e87a13c4044e51217eb47f0838c76e228eb;hp=734e00b7781206ab93ccb3d12f6d241b5c57a2d0;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git diff --git a/rt/sbin/rt-dump-database.in b/rt/sbin/rt-dump-database.in index 734e00b77..cb9f0c3d3 100755 --- a/rt/sbin/rt-dump-database.in +++ b/rt/sbin/rt-dump-database.in @@ -2,8 +2,8 @@ # BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: -# -# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +# +# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -25,7 +25,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 or visit their web page on the internet at -# http://www.gnu.org/copyleft/gpl.html. +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. # # # CONTRIBUTION SUBMISSION POLICY: @@ -48,8 +48,34 @@ # END BPS TAGGED BLOCK }}} use strict; -use lib "@LOCAL_LIB_PATH@"; -use lib "@RT_LIB_PATH@"; +# As we specify that XML is UTF-8 and we output it to STDOUT, we must be sure +# it is UTF-8 so further XMLin will not break +binmode(STDOUT, ":utf8"); + +# fix lib paths, some may be relative +BEGIN { + require File::Spec; + 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; + } + } + $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib ); + } + unshift @INC, $lib; + } + +} use RT; use XML::Simple; @@ -117,7 +143,7 @@ foreach my $class (@classes) { # next if $obj-> # skip default names foreach my $field (sort keys %fields) { my $value = $obj->__Value($field); - $rv->{$field} = $value if length($value); + $rv->{$field} = $value if ( defined ($value) && length($value) ); } delete $rv->{Disabled} unless $rv->{Disabled};