X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FXMLRPC.pm;h=fb0e5ac74ada7a7a207bd15193c3923637611dc3;hb=79721949b23e7052efdaacadcfb38e6a8f241416;hp=d7ba75a233dcf1edf5ffc9b5a689430dd9211f96;hpb=a18e0aadb62be9f96c0aa42b3a6464dc933477dc;p=freeside.git diff --git a/FS/FS/XMLRPC.pm b/FS/FS/XMLRPC.pm index d7ba75a23..fb0e5ac74 100644 --- a/FS/FS/XMLRPC.pm +++ b/FS/FS/XMLRPC.pm @@ -7,12 +7,15 @@ use Frontier::RPC2; # Instead of 'use'ing freeside modules on the fly below, just preload them now. use FS; use FS::CGI; +use FS::Conf; use FS::Record; use FS::cust_main; +use Data::Dumper; + @ISA = qw( ); -$DEBUG = 1; +$DEBUG = 0; =head1 NAME @@ -83,7 +86,6 @@ sub _serve { #Subroutine, not method my ($method_name, $params) = (shift, shift); - use Data::Dumper; #die 'Called _serve without parameters' unless ref($params) eq 'ARRAY'; $params = [] unless (ref($params) eq 'ARRAY'); @@ -96,26 +98,40 @@ sub _serve { #Subroutine, not method warn "fssub: ${fssub}" if $DEBUG; warn "params: " . Dumper($params) if $DEBUG; - unless (UNIVERSAL::can("FS::${class}", $sub)) { - warn "FS::XMLRPC: Can't call undefined subroutine '${fssub}'"; - # Should we encode an error in the response, - # or just break silently to the remote caller and complain locally? - return []; - } - my @result; - eval { - no strict 'refs'; - my $fssub = "FS::${class}::${sub}"; - @result = (&$fssub(@$params)); - }; - - if ($@) { - warn "FS::XMLRPC: Error while calling '${fssub}': $@"; - return []; + + if ($class eq 'Conf') { #Special case for FS::Conf because we need an obj. + + if ($sub eq 'config') { + my $conf = new FS::Conf; + @result = ($conf->config(@$params)); + } else { + warn "FS::XMLRPC: Can't call undefined subroutine '${fssub}'"; + } + + } else { + + unless (UNIVERSAL::can("FS::${class}", $sub)) { + warn "FS::XMLRPC: Can't call undefined subroutine '${fssub}'"; + # Should we encode an error in the response, + # or just break silently to the remote caller and complain locally? + return []; + } + + eval { + no strict 'refs'; + my $fssub = "FS::${class}::${sub}"; + @result = (&$fssub(@$params)); + }; + + if ($@) { + warn "FS::XMLRPC: Error while calling '${fssub}': $@"; + return []; + } + } - warn Dumper(@result); + warn Dumper(@result) if $DEBUG; if (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) { #warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " .