package C4::Context;
use strict;
use DBI;
+use C4::Boolean;
use vars qw($VERSION $AUTOLOAD),
qw($context),
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))
{
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
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);
}