X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FContext.pm;h=2d9e9e24a33f800693fd10323d61913a3a53e9cc;hb=4d0ad1b93fc4c9d3392c28a0a764315623178954;hp=b1efd7b03ec14b16343a9685825e76fe16d77272;hpb=40d6ddb38325c82ed9811dad4e25cfd8677e1c2a;p=koha.git diff --git a/C4/Context.pm b/C4/Context.pm index b1efd7b03e..2d9e9e24a3 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), @@ -170,7 +171,7 @@ sub new my $self = {}; # check that the specified config file exists - undef $conf_fname unless (-e $conf_fname); + undef $conf_fname unless (defined $conf_fname && -e $conf_fname); # Figure out a good config file to load if none was specified. if (!defined($conf_fname)) { @@ -325,6 +326,13 @@ EOT return $retval; } +sub boolean_preference ($) { + my $self = shift; + my $var = shift; # The system preference to return + my $it = preference($self, $var); + return defined($it)? C4::Boolean::true_p($it): undef; +} + # AUTOLOAD # This implements C4::Config->foo, and simply returns # C4::Context->config("foo"), as described in the documentation for @@ -357,7 +365,6 @@ sub _new_dbh my $db_host = $context->{"config"}{"hostname"}; my $db_user = $context->{"config"}{"user"}; my $db_passwd = $context->{"config"}{"pass"}; - return DBI->connect("DBI:$db_driver:$db_name:$db_host", $db_user, $db_passwd); }