summaryrefslogtreecommitdiff
path: root/lsmb-request.pl
blob: 5c75d6f339d2fcc032b8b38065b0368ba9905975 (plain)
  1. #!/usr/bin/perl
  2. =head1 NAME
  3. The LedgerSMB Request Handler
  4. =head1 SYNOPSYS
  5. This file receives the web request, instantiates the proper objects, and passes
  6. execution off to the appropriate workflow scripts. This is for use with new
  7. code only and should not be used with old SQL-Ledger(TM) code as it is
  8. architecturally dissimilar.
  9. =head1 COPYRIGHT
  10. Copyright (C) 2007 The LedgerSMB Core Team
  11. This file is licensed under the GNU General Public License (GPL) version 2 or
  12. at your option any later version. A copy of the GNU GPL has been included with
  13. this software.
  14. =cut
  15. package LedgerSMB::Handler;
  16. use LedgerSMB::Sysconfig;
  17. use Digest::MD5;
  18. use Error qw(:try);
  19. $| = 1;
  20. use LedgerSMB::User;
  21. use LedgerSMB;
  22. use LedgerSMB::Locale;
  23. use LedgerSMB::Session;
  24. use Data::Dumper;
  25. # for custom preprocessing logic
  26. eval { require "custom.pl"; };
  27. $request = new LedgerSMB;
  28. $request->{action} = '__default' if (!$request->{action});
  29. $ENV{SCRIPT_NAME} =~ m/([^\/\\]*.pl)\?*.*$/;
  30. $script = $1;
  31. $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} )
  32. or $request->error( __FILE__ . ':' . __LINE__ . ": Locale not loaded: $!\n" );
  33. if (!$script){
  34. $request->error($locale->text('No workflow script specified'));
  35. }
  36. eval { require "scripts/$script" }
  37. || $request->error($locale->text('Unable to open script') . ": scripts/$script : $!");
  38. $script =~ s/\.pl$//;
  39. $script = "LedgerSMB::Scripts::$script";
  40. $script->can($request->{action})
  41. || $request->error($locale->text("Action Not Defined: ") . $request->{action});
  42. $script->can( $request->{action} )->($request);
  43. 1;