From 850a3e41f6997a32f3077d78c263a324c5da163d Mon Sep 17 00:00:00 2001 From: acli Date: Thu, 6 Feb 2003 06:35:26 +0000 Subject: [PATCH] Use the new C4::Boolean module and the new C4::Auth::boolean_parameter function to test for boolean values in parameters --- C4/Auth.pm | 4 ++-- C4/Context.pm | 8 ++++++++ acqui/acquire.pl | 2 +- acqui/newbiblio.pl | 2 +- loadmodules.pl | 5 +++-- memberentry.pl | 4 ++-- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 0a7466a620..acd614ef12 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -301,9 +301,9 @@ sub checkauth { } } } - my $insecure = C4::Context->preference("insecure"); + my $insecure = C4::Context->boolean_preference('insecure'); # finished authentification, now respond - if ($loggedin || $authnotrequired ||(defined($insecure) && $insecure eq "yes")) { + if ($loggedin || $authnotrequired || (defined($insecure) && $insecure)) { # successful login unless ($cookie) { $cookie=$query->cookie(-name => 'sessionID', diff --git a/C4/Context.pm b/C4/Context.pm index 04ec6c1f85..9fcdb09e9b 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -20,6 +20,7 @@ package C4::Context; use strict; use DBI; +use C4::Boolean; use vars qw($VERSION $AUTOLOAD), qw($context), @@ -325,6 +326,13 @@ EOT return $retval; } +sub boolean_preference ($) { + my $self = shift; + my $var = shift; # The system preference to return + my $it = preference($var); + return defined($it)? C4::Boolean::is_true($it): undef; +} + # AUTOLOAD # This implements C4::Config->foo, and simply returns # C4::Context->config("foo"), as described in the documentation for diff --git a/acqui/acquire.pl b/acqui/acquire.pl index 969f49719f..12c960707b 100755 --- a/acqui/acquire.pl +++ b/acqui/acquire.pl @@ -173,7 +173,7 @@ print <preference("autoBarcode") || 0; +my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0; # See whether barcodes should be automatically allocated. # Defaults to 0, meaning "no". if ($auto_barcode eq '1') { diff --git a/acqui/newbiblio.pl b/acqui/newbiblio.pl index 97d11eb984..b5f6dbd214 100755 --- a/acqui/newbiblio.pl +++ b/acqui/newbiblio.pl @@ -231,7 +231,7 @@ print <preference("autoBarcode") || 0; +my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0; # See whether barcodes should be automatically allocated. # Defaults to 0, meaning "no". if ($auto_barcode eq '1') { diff --git a/loadmodules.pl b/loadmodules.pl index 35030930bf..52918453e4 100755 --- a/loadmodules.pl +++ b/loadmodules.pl @@ -52,10 +52,11 @@ sub acquisitions { } sub catalogue_search { - my $aq_type = C4::Context->preference("marc") || "ON"; + my $marc_p = C4::Context->boolean_preference("marc"); + $marc_p = 1 unless defined $aq_type; my $query = new CGI; my $type = $query->param('type'); - if ($aq_type eq 'ON') { + if ($marc_p) { print $input->redirect("/cgi-bin/koha/search.marc/search.pl?type=$type"); } else { print $input ->redirect("/cgi-bin/koha/catalogue-home.pl"); diff --git a/memberentry.pl b/memberentry.pl index 3e532aebfc..65882c8447 100755 --- a/memberentry.pl +++ b/memberentry.pl @@ -70,7 +70,7 @@ if ($delete){ } my $cardnumber=$data->{'cardnumber'}; - my $autonumber_members = C4::Context->preference("autoMemberNum") || 0; + my $autonumber_members = C4::Context->boolean_preference("autoMemberNum") || 0; # Find out whether member numbers should be generated # automatically. Should be either "1" or something else. # Defaults to "0", which is interpreted as "no". @@ -78,7 +78,7 @@ if ($delete){ # This logic should probably be moved out of the presentation code. # Not tonight though. # - if ($cardnumber eq '' && $autonumber_members eq '1') { + if ($cardnumber eq '' && $autonumber_members) { my $dbh = C4::Context->dbh; my $query="select max(substring(borrowers.cardnumber,2,7)) from borrowers"; my $sth=$dbh->prepare($query); -- 2.39.5