X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FXMLRPC.pm;h=84f3e4141f60dcccfa32fa38faa0b8da45065062;hb=98526af3dcd590daecea6f202a61a4b21589fbab;hp=287a502c59c09a5bb3abf5a120296a0958049ca9;hpb=68c43e49c834314e64b8c6929ba231feca151e7e;p=freeside.git diff --git a/FS/FS/XMLRPC.pm b/FS/FS/XMLRPC.pm index 287a502c5..84f3e4141 100644 --- a/FS/FS/XMLRPC.pm +++ b/FS/FS/XMLRPC.pm @@ -7,6 +7,7 @@ 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; @@ -96,31 +97,48 @@ 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); if (grep { UNIVERSAL::can($_, 'hashref') ? 0 : 1 } @result) { - warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " . - "support the 'hashref' method."; - return []; + #warn "FS::XMLRPC: One or more objects returned from '${fssub}' doesn't " . + # "support the 'hashref' method."; + + # If they're not FS::Record decendants, just return the results unmap'd? + # This is more flexible, but possibly more error-prone. + return [ @result ]; } else { return [ map { $_->hashref } @result ]; }