From c89cf3316e3296067eae5989d403c4a4015a6955 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Wed, 21 Mar 2007 00:10:55 +0000 Subject: Fixing error posting payments and requring user for User::fetch_config git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@964 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/CP.pm | 2 +- LedgerSMB/User.pm | 62 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 33 insertions(+), 31 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/CP.pm b/LedgerSMB/CP.pm index ca464262..47e278a4 100755 --- a/LedgerSMB/CP.pm +++ b/LedgerSMB/CP.pm @@ -669,7 +669,7 @@ sub post_payments { WHERE e.curr = ? AND a.id = ?|; - $sth = $sbh->prepare($query); + $sth = $dbh->prepare($query); $sth->execute($form->{currency}, $form->{"id_$i"}) || $form->dberror($query, 'CP.pm', 671); my ($exchangerate) = $sth->fetchrow_array; diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm index bd40b3b7..0d918640 100755 --- a/LedgerSMB/User.pm +++ b/LedgerSMB/User.pm @@ -112,39 +112,41 @@ sub fetch_config { my ($self, $login) = @_; - if ($login ne "") { - - # use central db - my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; - - # for now, this is querying the table directly... ugly - my $fetchUserPrefs = $dbh->prepare("SELECT acs, address, businessnumber, - company, countrycode, currency, - dateformat, dbdriver, dbhost, dbname, - dboptions, dbpasswd, dbport, dbuser, - email, fax, menuwidth, name, numberformat, - password, print, printer, role, sid, - signature, stylesheet, tel, templates, - timeout, vclimit, u.username - FROM users_conf as uc, users as u - WHERE u.username = ? - AND u.id = uc.id;"); - - $fetchUserPrefs->execute($login); - - my $userHashRef = $fetchUserPrefs->fetchrow_hashref; + if (!$login){ + &error($self, "Access Denied"); + } - while ( my ($key, $value) = each(%{$userHashRef}) ) { - $myconfig{$key} = $value; - } + + # use central db + my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; + + # for now, this is querying the table directly... ugly + my $fetchUserPrefs = $dbh->prepare("SELECT acs, address, businessnumber, + company, countrycode, currency, + dateformat, dbdriver, dbhost, dbname, + dboptions, dbpasswd, dbport, dbuser, + email, fax, menuwidth, name, numberformat, + password, print, printer, role, sid, + signature, stylesheet, tel, templates, + timeout, vclimit, u.username + FROM users_conf as uc, users as u + WHERE u.username = ? + AND u.id = uc.id;"); + + $fetchUserPrefs->execute($login); + + my $userHashRef = $fetchUserPrefs->fetchrow_hashref; + + while ( my ($key, $value) = each(%{$userHashRef}) ) { + $myconfig{$key} = $value; + } - chomp($myconfig{'dbport'}); - chomp($myconfig{'dbname'}); - chomp($myconfig{'dbhost'}); + chomp($myconfig{'dbport'}); + chomp($myconfig{'dbname'}); + chomp($myconfig{'dbhost'}); - $myconfig{'login'} = $login; - $myconfig{'dbconnect'} = 'dbi:Pg:dbname='.$myconfig{'dbname'}.';host='.$myconfig{'dbhost'}.';port='.$myconfig{'dbport'}; - } + $myconfig{'login'} = $login; + $myconfig{'dbconnect'} = 'dbi:Pg:dbname='.$myconfig{'dbname'}.';host='.$myconfig{'dbhost'}.';port='.$myconfig{'dbport'}; return \%myconfig; } -- cgit v1.2.3