@@ -, +, @@ * 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(-) --- a/C4/Auth.pm +++ a/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, --- a/C4/Branch.pm +++ a/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 --- a/C4/Koha.pm +++ a/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', --- a/C4/Search.pm +++ a/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 ) ); } } } --- a/installer/data/mysql/sysprefs.sql +++ a/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'); --