@@ -, +, @@ library --- C4/Auth.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -635,6 +635,18 @@ sub get_template_and_user { ); $template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") ); + + # guess the branch by ip if it isn't set already + if ( C4::Context->preference("SearchMyLibraryFirst") && ! $template->param('mylibraryfirst') ) { + my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search }; + my $ip = $ENV{'REMOTE_ADDR'}; + foreach my $br ( keys %$branches ) { + my $domain = $branches->{$br}->{'branchip'}; + if ( in_iprange($domain) ) { + $template->param( mylibraryfirst => $branches->{$br}->{'branchcode'} ); + } + } + } } # Check if we were asked using parameters to force a specific language --