From 8627ec5f6a274e46940bb82c52341e012fc6406d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 6 Jan 2016 10:41:44 +0000 Subject: [PATCH] Bug 4941: Remove the singleBranchMode system preference The singleBranchMode system preference does not make sense. Either the install has only 1 library defined or several. In both case, we can easily guess the behavior to follow. So the idea of this patch is to replace the fetch of this syspref with a call to count the number of libraries defined in DB. Test plan: 1/ From a fresh Koha install, execute the DB entry to remove the pref. 2/ Define only 1 library 3/ Confirm that Koha behaves the same as before (try to change your library, look at the facets) 4/ Create another library (or more) and reinsert the pref and set it: insert into systempreferences (variable, value) values('singleBranchMode', 1); 5/ Execute the DB entry You should get a warning message. 6/ Repeat 3. Signed-off-by: Chris Cormack Does what it says, but will change behaviour for any Koha install that has 2 branches defined, One circulation, and this preference set. If that is an acceptable change, we might need to make sure this is noted well in the release notes. Signed-off-by: Kyle M Hall --- C4/Auth.pm | 3 ++- C4/Koha.pm | 6 ++---- C4/Search.pm | 3 ++- C4/UsageStats.pm | 1 - C4/XSLT.pm | 2 +- installer/data/mysql/sysprefs.sql | 1 - .../intranet-tmpl/prog/en/modules/admin/preferences/opac.pref | 7 ------- opac/opac-reserve.pl | 4 ++-- 8 files changed, 9 insertions(+), 18 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index d891105..332b8c6 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -34,6 +34,7 @@ use C4::Search::History; use Koha; use Koha::AuthUtils qw(hash_password); use Koha::LibraryCategories; +use Koha::Libraries; use POSIX qw/strftime/; use List::MoreUtils qw/ any /; use Encode qw( encode is_utf8); @@ -422,7 +423,7 @@ sub get_template_and_user { hide_marc => C4::Context->preference("hide_marc"), item_level_itypes => C4::Context->preference('item-level_itypes'), patronimages => C4::Context->preference("patronimages"), - singleBranchMode => C4::Context->preference("singleBranchMode"), + singleBranchMode => ( Koha::Libraries->search->count == 1 ), XSLTDetailsDisplay => C4::Context->preference("XSLTDetailsDisplay"), XSLTResultsDisplay => C4::Context->preference("XSLTResultsDisplay"), using_https => $using_https, diff --git a/C4/Koha.pm b/C4/Koha.pm index 84f5e8c..b637cd4 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -756,8 +756,7 @@ sub getFacets { } ]; - unless ( C4::Context->preference("singleBranchMode") - || Koha::Libraries->search->count == 1 ) + unless ( Koha::Libraries->search->count == 1 ) { my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); if ( $DisplayLibraryFacets eq 'both' @@ -838,8 +837,7 @@ sub getFacets { }, ]; - unless ( C4::Context->preference("singleBranchMode") - || Koha::Libraries->search->count == 1 ) + unless ( Koha::Libraries->search->count == 1 ) { my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); if ( $DisplayLibraryFacets eq 'both' diff --git a/C4/Search.pm b/C4/Search.pm index f52e0ee..58ccf84 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -31,6 +31,7 @@ use C4::Branch; use C4::Reserves; # GetReserveStatus use C4::Debug; use C4::Charset; +use Koha::Libraries; use YAML; use URI::Escape; use Business::ISBN; @@ -618,7 +619,7 @@ sub getRecords { $facets_info->{$link_value}->{'label_value'} =~ /Libraries/ ) - and ( C4::Context->preference('singleBranchMode') ) + and ( Koha::Libraries->search->count == 1 ) ); } } diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 47f9827..ba97fef 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -268,7 +268,6 @@ sub BuildReport { OpacRenewalBranch OPACViewOthersSuggestions SearchMyLibraryFirst - singleBranchMode AnonSuggestions EnableOpacSearchHistory OPACPrivacy diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 7a94f2c..d7658a2 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -204,7 +204,7 @@ sub XSLTParse4Display { UseAuthoritiesForTracings TraceSubjectSubdivisions Display856uAsImage OPACDisplay856uAsImage UseControlNumber IntranetBiblioDefaultView BiblioDefaultView - singleBranchMode OPACItemLocation DisplayIconsXSLT + OPACItemLocation DisplayIconsXSLT AlternateHoldingsField AlternateHoldingsSeparator TrackClicks opacthemes IdRef / ) { diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 9f2e02b..bfc8c31 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -423,7 +423,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'), ('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'), ('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'), -('singleBranchMode','0',NULL,'Operate in Single-branch mode, hide branch selection in the OPAC','YesNo'), ('SlipCSS','',NULL,'Slips CSS url.','free'), ('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'), ('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index b4ea23c..3e63f3c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -485,13 +485,6 @@ OPAC: - the acquisition details on OPAC detail pages. Policy: - - - pref: singleBranchMode - default: 0 - choices: - yes: "Don't allow" - no: Allow - - patrons to select their branch on the OPAC or show branch names with callnumbers. - - - pref: SearchMyLibraryFirst choices: yes: Limit diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 277b2fe..c7bc236 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -35,8 +35,8 @@ use C4::Overdues; use C4::Debug; use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Libraries; use Date::Calc qw/Today Date_to_Days/; -# use Data::Dumper; my $maxreserves = C4::Context->preference("maxreserves"); @@ -228,7 +228,7 @@ if ( $query->param('place_reserve') ) { my $canreserve = 0; - my $singleBranchMode = C4::Context->preference("singleBranchMode"); + my $singleBranchMode = Koha::Libraries->search->count == 1; if ( $singleBranchMode || !$OPACChooseBranch ) { # single branch mode or disabled user choosing $branch = $borr->{'branchcode'}; -- 2.1.4