summaryrefslogtreecommitdiff
path: root/lsmb-request.pl
blob: 66978712731e356bab05a5f07960bc918475b89a (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. $0 =~ m/([^\/\\]*.pl)$/;
  29. if (!$1){
  30. $0 =~ m/([^\/\\]*.pl)[? ]/;
  31. }
  32. $script = $1;
  33. $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} )
  34. or $request->error( __FILE__ . ':' . __LINE__ . ": Locale not loaded: $!\n" );
  35. if (!$script){
  36. $request->error($locale->text('No workflow script specified'));
  37. }
  38. eval { require "scripts/$script" }
  39. || $request->error($locale->text('Unable to open script' . ": $!";
  40. $script =~ s/\.pl$//;
  41. $script = "LedgerSMB::Scripts::$script";
  42. $script->can($request->{action})
  43. || $request->error($locale->text("Action Not Defined: ") . $request->{action};
  44. $script->can($request->{action})->($request);