From 8e92a7882955d02d5cc2640231c2872ad6dba6ed Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 24 May 2013 06:56:50 -0400 Subject: [PATCH] Bug 10325 - Allow system preferences to be overridable from koha-httpd.conf For Koha installations with multiple OPAC URLs, It would be nice to be able to override systeprefs from the http conf file. Case in point, a library wants to have two separate opacs, one the is only viewable from within the library that allows patrons to place holds, and a second public one that does not. In this case, overriding the system preference RequestOnOpac would accomplish this simply, and with no ill affects. This feature would of course be should only be used to override cosmetic effects on the system, and should not be used for system preferences such as CircControl, but would be great for preferences such as OpacStarRatings, opacuserjs, OpacHighlightedWords and many others! Test Plan: 1) Apply this patch 2) Disable the system pref OpacHighlightedWords 3) Do a seach in the OPAC, not the term is not highlighted 4) Edit your koha-http.conf file, add the line SetEnv OVERRIDE_SYSPREF_OpacHighlightedWords "1" to your koha-http.conf file's OPAC section. 5) Restart your web server, or just reload it's config 6) Do a seach, now your search term should be highlighted! --- C4/Context.pm | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 7709f7e..7bc7097 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -540,7 +540,7 @@ my $use_syspref_cache = 1; sub preference { my $self = shift; - my $var = lc(shift); # The system preference to return + my $var = shift; # The system preference to return if ($use_syspref_cache && exists $sysprefs{$var}) { return $sysprefs{$var}; @@ -548,15 +548,22 @@ sub preference { my $dbh = C4::Context->dbh or return 0; - # Look up systempreferences.variable==$var - my $sql = <<'END_SQL'; - SELECT value - FROM systempreferences - WHERE variable=? - LIMIT 1 -END_SQL - $sysprefs{$var} = $dbh->selectrow_array( $sql, {}, $var ); - return $sysprefs{$var}; + my $value; + if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { + $value = $ENV{"OVERRIDE_SYSPREF_$var"}; + } else { + # Look up systempreferences.variable==$var + my $sql = q{ + SELECT value + FROM systempreferences + WHERE variable = ? + LIMIT 1 + }; + $value = $dbh->selectrow_array( $sql, {}, $var ); + } + + $sysprefs{$var} = $value; + return $value; } sub boolean_preference { -- 1.7.2.5