From a183d9ed2ca0d67bf00c3d77d127150843b2e004 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 17 Feb 2012 12:35:41 -0500 Subject: [PATCH] Bug 7401 - Shelving Location facet - Part II - Deprecate singelBranchMode * Removes the use of the SingleBranchMode system pref from all perl files. * C4::Auth now enables SingleBranchMode automatically if only 1 branch exists. --- C4/Auth.pm | 2 +- C4/Branch.pm | 14 ++++++++++++++ C4/Koha.pm | 5 +++-- C4/Search.pm | 2 +- installer/data/mysql/sysprefs.sql | 1 - 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a855818..72fa3dc 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -352,7 +352,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 => ( C4::Branch::GetBranchesCount() == 1 ), XSLTDetailsDisplay => C4::Context->preference("XSLTDetailsDisplay"), XSLTResultsDisplay => C4::Context->preference("XSLTResultsDisplay"), using_https => $in->{'query'}->https() ? 1 : 0, diff --git a/C4/Branch.pm b/C4/Branch.pm index 7bd0326..6f5b2eb 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -33,6 +33,7 @@ BEGIN { &GetBranch &GetBranches &GetBranchesLoop + &GetBranchesCount &GetBranchDetail &get_branchinfos_of &ModBranch @@ -169,6 +170,19 @@ sub GetBranchesLoop (;$$) { # since this is what most pages want anyway return \@loop; } +=head2 GetBranchesCount + +=cut + +sub GetBranchesCount() { + my $dbh = C4::Context->dbh; + my $sth; + $sth = $dbh->prepare("SELECT COUNT(*) as count FROM branches"); + my $count = $sth->fetchrow_array; + $sth->finish; + return ( $count ); +} + =head2 GetBranchName =cut diff --git a/C4/Koha.pm b/C4/Koha.pm index 70cb915..a0f8d46 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -675,6 +675,7 @@ sub getallthemes { sub getFacets { my $facets; + my $singleBranchMode = ( C4::Branch::GetBranchesCount() == 1 ); if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { $facets = [ { @@ -711,7 +712,7 @@ sub getFacets { ]; my $library_facet; - unless ( C4::Context->preference("singleBranchMode") ) { + unless ( $singleBranchMode ) { $library_facet = { link_value => 'branch', label_value => 'Libraries', @@ -772,7 +773,7 @@ sub getFacets { ]; my $library_facet; - unless ( C4::Context->preference("singleBranchMode") ) { + unless ( $singleBranchMode ) { $library_facet = { link_value => 'branch', label_value => 'Libraries', diff --git a/C4/Search.pm b/C4/Search.pm index 09a5134..592408d 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -593,7 +593,7 @@ sub getRecords { facets => \@this_facets_array, expandable => $expandable, expand => $link_value, - } unless ( ($facets_info->{$link_value}->{'label_value'} =~ /Libraries/) and (C4::Context->preference('singleBranchMode')) ); + } unless ( ($facets_info->{$link_value}->{'label_value'} =~ /Libraries/) and ( C4::Branch::GetBranchesCount() == 1 ) ); } } } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 0cc79b2..411b215 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -164,7 +164,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numReturnedItemsToShow','20','Number of returned items to show on the check-in page',NULL,'Integer'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, \'off\', \'test\' (emails admin report) or \'production\' (accrue overdue fines). Requires accruefines cronjob.','off|test|production','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','whitespace|T-prefix|cuecat|libsuite8','Choice'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACViewOthersSuggestions',0,'If ON, allows all suggestions to be displayed in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACURLOpenInNewWindow',0,'If ON, URLs in the OPAC open in a new window',NULL,'YesNo'); -- 1.7.2.5