summaryrefslogtreecommitdiff
path: root/common.pl
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-11 05:44:08 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-11 05:44:08 +0000
commitde1f421b250192d25bfbbc867a9cec91f6826485 (patch)
treedd437b37f962751d39ed0a2b4cf24a40eaa148c6 /common.pl
parent67a247228e7204dea87eb95e32abc16a5f028da8 (diff)
Adding common.pl
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@515 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'common.pl')
-rw-r--r--common.pl52
1 files changed, 52 insertions, 0 deletions
diff --git a/common.pl b/common.pl
new file mode 100644
index 00000000..b4b524b5
--- /dev/null
+++ b/common.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+#
+######################################################################
+# LedgerSMB Accounting and ERP
+
+# http://www.ledgersmb.org/
+#
+# Copyright (C) 2006
+# This work contains copyrighted information from a number of sources all used
+# with permission.
+#
+# This file contains source code included with or based on SQL-Ledger which
+# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
+# under the GNU General Public License version 2 or, at your option, any later
+# version. For a full list including contact information of contributors,
+# maintainers, and copyright holders, see the CONTRIBUTORS file.
+#
+#####################################################################
+#
+# Common script handling routines for menu.pl, admin.pl, login.pl
+#
+#####################################################################
+
+use LedgerSMB::Sysconfig;
+
+sub redirect {
+ use List::Util qw(first);
+ my ($script, $argv) = split(/\?/, $form->{callback});
+
+ my @common_attrs = qw(dbh login favicon stylesheet titlebar password);
+
+ $form->error($locale->text("Invalid Redirect"))
+ unless first {$_ eq $script} @{LedgerSMB::Sysconfig::scripts};
+
+ $oldform = $form;
+ require "bin/$script";
+ $form = new Form($argv);
+
+ for (@common_attrs){
+ $form->{$_} = $oldform->{$_};
+ }
+ if (!$myconfig){ # needed for login
+ %myconfig = %{LedgerSMB::User->fetch_config($form->{login})};
+ }
+ if (!$form->{dbh}){
+ $form->db_init(\%myconfig);
+ }
+
+ &{$form->{action}};
+}
+
+1;