From ddd452af128f9b4698a1c1d6cc7fe2f23a0e6c90 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 7 Oct 2008 16:19:44 +0000 Subject: Adding Sadashiva's fix for non-existant defaults values git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@2353 4979c152-3d1c-0410-bac9-87ea11338e46 --- CONTRIBUTORS | 3 +-- LedgerSMB/AM.pm | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b8c2ef5c..e8023818 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -69,8 +69,7 @@ Donna Robinson [email omitted] contributed some fixes to the HTML code. Victor Sterpu has contributed several bug fixes to COGS handling. -Sadashiva Ambiger [email omitted] has committed a fix to the admin screen regarding -access errors when deleting a user. +Sadashiva Ambiger [email omitted] has contributed several bug fixes. Original Authors of SQL-Ledger: =================================== diff --git a/LedgerSMB/AM.pm b/LedgerSMB/AM.pm index 328a745b..1d209358 100755 --- a/LedgerSMB/AM.pm +++ b/LedgerSMB/AM.pm @@ -1415,8 +1415,28 @@ sub save_defaults { || $form->dberror("Saving $_"); } else { - $sth_plain->execute( $val, $_ ) - || $form->dberror("Saving $_"); + my $found=0; + my $sth_defcheck=$dbh->prepare("select count(*) from defaults where setting_key='$_';") || $form->dberror("Select defaults $_"); + $sth_defcheck->execute() || $form->dberror("execute defaults $_"); + while(my $found1=$sth_defcheck->fetchrow()){$found=$found1;} + + if($val ne '') + { + if($found) + { + $dbh->do("update defaults set value='$val' where setting_key='$_';"); + } + else + { + $dbh->do("insert into defaults(value,setting_key) values('$val','$_');"); + } + } + else + { + if($found){$dbh->do("delete from defaults where setting_key='$_';")}; + + } + } } -- cgit v1.2.3