Bug 21911: Fix OPAC scoping to work with new group system
authorNick Clemens <nick@bywatersolutions.com>
Thu, 29 Nov 2018 14:17:37 +0000 (14:17 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 11 Dec 2018 19:12:39 +0000 (19:12 +0000)
To test:

0 - Apply patch
1 - Create a library group enabled for opac search limits and add some
libraries
2 - Check the DB (or advanced search dropdown) to get the id of the
group (using 7 as example below)
3 - Add to apache configuration (OPAC virtualhost)
   SetEnv OPAC_SEARCH_LIMIT branch:multibranchlimit-7
   SetEnv OPAC_LIMIT_OVERRIDE 1
   RequestHeader add X-Koha-SetEnv "OPAC_SEARCH_LIMIT
   branch:multibranchlimit-7"
   RequestHeader add X-Koha-SetEnv "OPAC_LIMIT_OVERRIDE 1"
4 - Ensure OpacAddMastheadLibraryPulldown is disabled
5 - Restart all the things
6 - Visit the opac
7 - Perform a search, confirm it is scoped to the branches in the group

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/Auth.pm
koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc

index 2435e734d3518b0a7babd84c1124925667dc4d1b..b19197b35b798f7d81f8f291d84a05508bde86ca 100644 (file)
@@ -533,8 +533,8 @@ sub get_template_and_user {
         my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
         my $opac_name           = '';
         if (
-            ( $opac_limit_override && $opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ ) ||
-            ( $in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/ ) ||
+            ( $opac_limit_override && $opac_search_limit && $opac_search_limit =~ /branch:([\w-]+)/ ) ||
+            ( $in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:([\w-]+)/ ) ||
             ( $in->{'query'}->param('multibranchlimit') && $in->{'query'}->param('multibranchlimit') =~ /multibranchlimit-(\w+)/ )
           ) {
             $opac_name = $1;    # opac_search_limit is a branch, so we use it.
index e9e42b28be5b433af9411e9215de1109917ebe06..9466c2d9c6391f6a878c7d65143f80e359168e09 100644 (file)
                                 [% ELSE %]
                                     [% IF ( opac_limit_override ) %]
                                         [% IF ( opac_search_limit ) %]
-                                            <input name="limit" value="[% opac_search_limit | html %]" type="hidden" />
+                                            [% IF ( multibranchlimit = opac_search_limit.match( 'branch:(multibranchlimit-\d+)' ) ) %]
+                                                <input name="branch_group_limit" value="[% multibranchlimit.0 | html %]" type="hidden" />
+                                            [% ELSE %]
+                                                <input name="limit" value="[% opac_search_limit | html %]" type="hidden" />
+                                            [% END %]
                                         [% END %]
                                     [% ELSE %]
                                         [% IF ( mylibraryfirst ) %]