X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FContext.pm;h=926c1a5b8bb0386b4e22e3221f031310bace275b;hb=6843f5a346da3d0c0e55b7168750190c9194297b;hp=7ba57fb47d9f2475e226de853dbc1166cfbc6718;hpb=1ddb5df863c3166a20d55c8f852af7c5fd67e204;p=srvgit diff --git a/C4/Context.pm b/C4/Context.pm index 7ba57fb47d..926c1a5b8b 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -12,9 +12,9 @@ package C4::Context; # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; use warnings; @@ -71,7 +71,7 @@ BEGIN { } print ""; } - 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}) { @@ -233,7 +233,7 @@ Returns undef in case of error. =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 } @@ -507,6 +507,37 @@ sub clear_syspref_cache { %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 @@ -588,7 +619,7 @@ sub _new_Zconn { my $tried=0; # first attempt my $Zconn; # connection object $server = "biblioserver" unless $server; - $syntax = "xml" unless $syntax; + $syntax = "usmarc" unless $syntax; my $host = $context->{'listen'}->{$server}->{'content'}; my $servername = $context->{"config"}->{$server};