From 0985ef49e6f5a86a0eedfb65ac7b2a5d45ccc0e6 Mon Sep 17 00:00:00 2001 From: tetragon Date: Tue, 20 Mar 2007 19:33:15 +0000 Subject: Rearranging menu.pl git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@959 4979c152-3d1c-0410-bac9-87ea11338e46 --- menu.pl | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'menu.pl') diff --git a/menu.pl b/menu.pl index 12e2e50a..7501df85 100755 --- a/menu.pl +++ b/menu.pl @@ -77,23 +77,28 @@ $script =~ s/\.pl//; # pull in DBI use DBI qw(:sql_types); -# grab user config. This is ugly and unecessary if/when -# we get rid of myconfig and use User as a real object -%myconfig = %{LedgerSMB::User->fetch_config($form->{login})}; +# send warnings to browser +$SIG{__WARN__} = sub { $form->info($_[0]) }; -if ($@) { - $locale = LedgerSMB::Locale->get_handle($myconfig{countrycode}) or +# send errors to browser +$SIG{__DIE__} = sub { $form->error(__FILE__.':'.__LINE__.': '.$_[0]) }; + +# did sysadmin lock us out +if (-f "${LedgerSMB::Sysconfig::userspath}/nologin") { + $locale = LedgerSMB::Locale->get_handle(${LedgerSMB::Sysconfig::language}) or $form->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n"); - $form->{charset} = $locale->encoding; $form->{charset} = 'UTF-8'; $locale->encoding('UTF-8'); $form->{callback} = ""; - $msg1 = $locale->text('You are logged out!'); - $msg2 = $locale->text('Login'); - $form->redirect("$msg1

$msg2

"); + $form->error(__FILE__.':'.__LINE__.': '.$locale->text('System currently down for maintenance!')); } +&check_password; +# grab user config. This is ugly and unecessary if/when +# we get rid of myconfig and use User as a real object +%myconfig = %{LedgerSMB::User->fetch_config($form->{login})}; + # locale messages $locale = LedgerSMB::Locale->get_handle($myconfig{countrycode}) or $form->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n"); @@ -101,19 +106,16 @@ $locale = LedgerSMB::Locale->get_handle($myconfig{countrycode}) or $form->{charset} = 'UTF-8'; $locale->encoding('UTF-8'); -# send warnings to browser -$SIG{__WARN__} = sub { $form->info($_[0]) }; - -# send errors to browser -$SIG{__DIE__} = sub { $form->error(__FILE__.':'.__LINE__.': '.$_[0]) }; +if ($@) { + $form->{callback} = ""; + $msg1 = $locale->text('You are logged out!'); + $msg2 = $locale->text('Login'); + $form->redirect("$msg1

$msg2

"); +} map { $form->{$_} = $myconfig{$_} } qw(stylesheet timeout) unless ($form->{type} eq 'preferences'); -$form->db_init(\%myconfig); -# did sysadmin lock us out -if (-f "${LedgerSMB::Sysconfig::userspath}/nologin") { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('System currently down for maintenance!')); -} +$form->db_init(\%myconfig); # pull in the main code require "bin/$form->{script}"; @@ -133,7 +135,6 @@ if ($form->{action}) { # window title bar, user info $form->{titlebar} = "LedgerSMB ".$locale->text('Version'). " $form->{version} - $myconfig{name} - $myconfig{dbname}"; - &check_password; &{ $form->{action} }; -- cgit v1.2.3