}
print "</body></html>";
}
- CGI::Carp::set_message(\&handle_errors);
+ #CGI::Carp::set_message(\&handle_errors);
## give a stack backtrace if KOHA_BACKTRACES is set
## can't rely on DebugLevel for this, as we're not yet connected
if ($ENV{KOHA_BACKTRACES}) {
=cut
sub read_config_file { # Pass argument naming config file to read
- my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
+ my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo'], suppressempty => '');
return $koha; # Return value: ref-to-hash holding the configuration
}
%sysprefs = ();
}
+=item set_preference
+
+ C4::Context->set_preference( $variable, $value );
+
+ This updates a preference's value both in the systempreferences table and in
+ the sysprefs cache.
+
+=cut
+
+sub set_preference {
+ my $self = shift;
+ my $var = shift;
+ my $value = shift;
+
+ my $dbh = C4::Context->dbh or return 0;
+
+ my $type = $dbh->selectrow_array( "SELECT type FROM systempreferences WHERE variable = ?", {}, $var );
+
+ $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' );
+
+ my $sth = $dbh->prepare( "
+ INSERT INTO systempreferences
+ ( variable, value )
+ VALUES( ?, ? )
+ ON DUPLICATE KEY UPDATE value = VALUES(value)
+ " );
+
+ $sth->execute( $var, $value );
+ $sth->finish;
+}
+
# AUTOLOAD
# This implements C4::Config->foo, and simply returns
# C4::Context->config("foo"), as described in the documentation for
my $sth = $dbh->prepare("select word from stopwords");
$sth->execute;
while (my $stopword = $sth->fetchrow_array) {
- my $retval = {};
$stopwordlist->{$stopword} = uc($stopword);
}
$stopwordlist->{A} = "A" unless $stopwordlist;
C4::Context->userenv;
-Builds a hash for user environment variables.
+Retrieves a hash for user environment variables.
This hash shall be cached for future use: if you call
C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
-set_userenv is called in Auth.pm
-
=cut
#'
-sub userenv
-{
+sub userenv {
my $var = $context->{"activeuser"};
return $context->{"userenv"}->{$var} if (defined $var and defined $context->{"userenv"}->{$var});
# insecure=1 management
C4::Context->set_userenv($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags, $emailaddress);
-Informs a hash for user environment variables.
-
-This hash shall be cached for future use: if you call
-C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
+Establish a hash of user environment variables.
set_userenv is called in Auth.pm
=cut
#'
-sub set_userenv{
+sub set_userenv {
my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
my $var=$context->{"activeuser"};
my $cell = {
=item _new_userenv
- C4::Context->_new_userenv($session);
+ C4::Context->_new_userenv($session); # FIXME: This calling style is wrong for what looks like an _internal function
Builds a hash for user environment variables.
#'
sub _new_userenv
{
- shift;
+ shift; # Useless except it compensates for bad calling style
my ($sessionID)= @_;
$context->{"activeuser"}=$sessionID;
}