From 10cd2fa3ee82b956da66b5a5ba76d62b0d485fa5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 23 May 2024 10:54:08 +0100 Subject: [PATCH] Bug 26176: (QA follow-up) Also rename StaffLoginBranchBasedOnIP This patch also renames StaffLoginBranchBasedOnIP to StaffLoginLibraryBasedOnIP to be consistent with our terminology guidelines Signed-off-by: Martin Renvoize --- C4/Auth.pm | 61 ++++++++++--------- .../data/mysql/atomicupdate/bug_26176.pl | 17 +++++- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../en/modules/admin/preferences/admin.pref | 4 +- .../intranet-tmpl/prog/en/modules/auth.tt | 2 +- t/db_dependent/Auth.t | 10 +-- 6 files changed, 55 insertions(+), 41 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 3d4c46ec7b3..bc1f2c945e2 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -495,35 +495,35 @@ sub get_template_and_user { if ( $in->{'type'} eq "intranet" ) { $template->param( - advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), - AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), - AmazonCoverImages => C4::Context->preference("AmazonCoverImages"), + advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), + AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), + AmazonCoverImages => C4::Context->preference("AmazonCoverImages"), StaffLoginRestrictLibraryByIP => C4::Context->preference("StaffLoginRestrictLibraryByIP"), - can_see_cataloguing_module => haspermission( $user, get_cataloguing_page_permissions() ) ? 1 : 0, - canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), - EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), - EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), - FRBRizeEditions => C4::Context->preference("FRBRizeEditions"), - IndependentBranches => C4::Context->preference("IndependentBranches"), - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - IntranetFavicon => C4::Context->preference("IntranetFavicon"), - IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), - IntranetNav => C4::Context->preference("IntranetNav"), - intranetreadinghistory => C4::Context->preference("intranetreadinghistory"), - IntranetReadingHistoryHolds => C4::Context->preference("IntranetReadingHistoryHolds"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetUserCSS => C4::Context->preference("IntranetUserCSS"), - IntranetUserJS => C4::Context->preference("IntranetUserJS"), - LibraryName => C4::Context->preference("LibraryName"), - LocalCoverImages => C4::Context->preference('LocalCoverImages'), - OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), - PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), - pending_checkout_notes => Koha::Checkouts->search( { noteseen => 0 } ), - plugins_enabled => C4::Context->config("enable_plugins"), - StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"), - UseCourseReserves => C4::Context->preference("UseCourseReserves"), - useDischarge => C4::Context->preference('useDischarge'), - virtualshelves => C4::Context->preference("virtualshelves"), + can_see_cataloguing_module => haspermission( $user, get_cataloguing_page_permissions() ) ? 1 : 0, + canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), + EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), + EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), + FRBRizeEditions => C4::Context->preference("FRBRizeEditions"), + IndependentBranches => C4::Context->preference("IndependentBranches"), + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + IntranetFavicon => C4::Context->preference("IntranetFavicon"), + IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), + IntranetNav => C4::Context->preference("IntranetNav"), + intranetreadinghistory => C4::Context->preference("intranetreadinghistory"), + IntranetReadingHistoryHolds => C4::Context->preference("IntranetReadingHistoryHolds"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetUserCSS => C4::Context->preference("IntranetUserCSS"), + IntranetUserJS => C4::Context->preference("IntranetUserJS"), + LibraryName => C4::Context->preference("LibraryName"), + LocalCoverImages => C4::Context->preference('LocalCoverImages'), + OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), + PatronAutoComplete => C4::Context->preference("PatronAutoComplete"), + pending_checkout_notes => Koha::Checkouts->search( { noteseen => 0 } ), + plugins_enabled => C4::Context->config("enable_plugins"), + StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"), + UseCourseReserves => C4::Context->preference("UseCourseReserves"), + useDischarge => C4::Context->preference('useDischarge'), + virtualshelves => C4::Context->preference("virtualshelves"), ); } else { @@ -1235,12 +1235,13 @@ sub checkauth { } if ( - # If StaffLoginBranchBasedOnIP is enabled we will try to find a branch + # If StaffLoginLibraryBasedOnIP is enabled we will try to find a branch # matching your ip, regardless of the choice you have passed in ( !C4::Context->preference('StaffLoginRestrictLibraryByIP') - && C4::Context->preference('StaffLoginBranchBasedOnIP') + && C4::Context->preference('StaffLoginLibraryBasedOnIP') ) + # When StaffLoginRestrictLibraryByIP is enabled we will not choose a branch matching IP # if your selected branch has no IP set || ( C4::Context->preference('StaffLoginRestrictLibraryByIP') diff --git a/installer/data/mysql/atomicupdate/bug_26176.pl b/installer/data/mysql/atomicupdate/bug_26176.pl index 784c569351e..cc7fb4e5a7b 100755 --- a/installer/data/mysql/atomicupdate/bug_26176.pl +++ b/installer/data/mysql/atomicupdate/bug_26176.pl @@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_failure say_success say_info); return { bug_number => "26176", - description => "Rename AutoLocation to StaffLoginRestrictLibraryByIP", + description => "Rename AutoLocation and StaffLoginBranchBasedOnIP", up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; @@ -15,6 +15,19 @@ return { } ); - say $out "Renamed system preference 'AutoLocation' to 'StaffLoginRestrictLibraryByIP'"; + say_success( $out, "Renamed system preference 'AutoLocation' to 'StaffLoginRestrictLibraryByIP'" ); + + $dbh->do( + q{ + UPDATE systempreferences SET variable = "StaffLoginRestrictLibraryByIP" + WHERE variable = "StaffLoginLibraryBasedOnIP" + } + ); + + say_success( + $out, + "Renamed system preference 'StaffLoginLibraryBasedOnIP' to 'StaffLoginRestrictLibraryByIP'" + ); + }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 186a9388a78..45601eec564 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -735,8 +735,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'), ('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'), ('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff interface','Choice'), -('StaffLoginBranchBasedOnIP', '0','', 'Set the logged in library for the user based on their current IP','YesNo'), ('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'), +('StaffLoginLibraryBasedOnIP', '0','', 'Set the logged in library for the user based on their current IP','YesNo'), ('StaffLoginRestrictLibraryByIP','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses based on branch','YesNo'), ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the staff interface','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 84e9439bd6b..60c68e11c96 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -98,7 +98,7 @@ Administration: 1: "Yes" 0: "No" - Link to library administration - - 'Staff can only choose their library at login if they have the "loggedinlibrary" permission. This setting will override the StaffLoginBranchBasedOnIP system preference. In the event of multiple libraries with matching IPs, branchcode (alphabetically) will be the tie breaker.' + - 'Staff can only choose their library at login if they have the "loggedinlibrary" permission. This setting will override the StaffLoginLibraryBasedOnIP system preference. In the event of multiple libraries with matching IPs, branchcode (alphabetically) will be the tie breaker.' - - "Enable check for change in remote IP address for session security: " - pref: SessionRestrictionByIP @@ -109,7 +109,7 @@ Administration: - (Disable only when remote IP address changes frequently.) - - "Set logged in library for staff by matching their current IP to the library configuration: " - - pref: StaffLoginBranchBasedOnIP + - pref: StaffLoginLibraryBasedOnIP default: 0 choices: 1: "Yes" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt index f50740e1897..c0f4fc5ae7b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -158,7 +158,7 @@ [% IF Koha.Preference('ForceLibrarySelection') %] Required [% END %] - [% IF Koha.Preference('StaffLoginBranchBasedOnIP')%] + [% IF Koha.Preference('StaffLoginLibraryBasedOnIP')%] Note: Your selection may be overridden if your current IP matches a specified IP for a branch in Koha [% END %]

diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index e9cb9790856..ce7c7cffa9c 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -1292,14 +1292,14 @@ subtest 'checkpw() return values tests' => sub { }; }; -subtest 'StaffLoginBranchBasedOnIP' => sub { +subtest 'StaffLoginLibraryBasedOnIP' => sub { plan tests => 7; $schema->storage->txn_begin; t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 ); - t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP', 0 ); + t::lib::Mocks::mock_preference( 'StaffLoginLibraryBasedOnIP', 0 ); my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); my $branch = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => "127.0.0.1" } } ); @@ -1324,20 +1324,20 @@ subtest 'StaffLoginBranchBasedOnIP' => sub { is( $session->param('branch'), $patron->branchcode, "Logged in branch is set to the patron's branchcode" ); my $template; - t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP', 1 ); + t::lib::Mocks::mock_preference( 'StaffLoginLibraryBasedOnIP', 1 ); ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); is( $userid, $patron->userid, "User successfully logged in" ); $session = C4::Auth::get_session($sessionID); is( $session->param('branch'), $branch->branchcode, "Logged in branch is set based on the IP from REMOTE_ADDR " ); - # StaffLoginRestrictLibraryByIP overrides StaffLoginBranchBasedOnIP + # StaffLoginRestrictLibraryByIP overrides StaffLoginLibraryBasedOnIP t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 1 ); ( $userid, $cookie, $sessionID, $flags, $template ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); is( $template->{VARS}->{wrongip}, 1, - "StaffLoginRestrictLibraryByIP prevents StaffLoginBranchBasedOnIP from logging user in to another branch" + "StaffLoginRestrictLibraryByIP prevents StaffLoginLibraryBasedOnIP from logging user in to another branch" ); t::lib::Mocks::mock_preference( 'StaffLoginRestrictLibraryByIP', 0 ); -- 2.45.1