From 9603f118837bb8171081da6f892761f2d341726f Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Thu, 6 Jul 2023 19:59:50 +0000 Subject: [PATCH] Bug 34188: Require Library Branch Selection when Logging in This patch adds the ability to force staff to select a library when logging into the staff interface. This is done via a new system preference: 'ForcedLibrarySelection' To test: 1) Apply patch, restart_all, and updatedatabase 2) Log out of the staff interface. Notice the login form looks the same and the "Library:" dropdown has 'My Library" selected as default. Log back into the staff interface. 3) In Administration, search for the system preference "ForcedLibrarySelection". Set it to 'Force' and press save. 4) Log out of the staff interface. Notice that this time, the "Library:" dropdown is required and has a blank selection as the default. 5) Fill in the username and password but do not select a library. Click 'Log in' 6) Notice you cannot log in and are asked to 'Please select an item in the list' 7) Select a library from the drop down and click 'Log in' 8) Notice the login was successful and you were logged in to the library you selected. 9) Try loggin in with some other libraries to verify it works as expected 10) Sign-off :) Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/bug_34188.pl | 17 +++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../en/modules/admin/preferences/admin.pref | 7 +++++++ koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 13 +++++++++++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_34188.pl diff --git a/installer/data/mysql/atomicupdate/bug_34188.pl b/installer/data/mysql/atomicupdate/bug_34188.pl new file mode 100755 index 0000000000..a8dcbd8fd3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_34188.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => "34188", + description => "Force staff to select a library when logging into the staff interface.", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) + VALUES ('ForcedLibrarySelection', '0', NULL,'Force staff to select a library when logging into the staff interface.', 'YesNo')}); + + # sysprefs + say $out "Added new system preference 'ForcedLibrarySelection'"; + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index c006d10cbe..68d1279843 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -265,6 +265,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('FinesIncludeGracePeriod','1',NULL,'If enabled, fines calculations will include the grace period.','YesNo'), ('FinesLog','1',NULL,'If ON, log fines','YesNo'), ('finesMode','off','off|production','Choose the fines mode, \'off\' (no charges), \'production\' (accrue overdue fines). Requires accruefines cronjob.','Choice'), +('ForcedLibrarySelection','0',NULL,'Force staff to select a library when logging into the staff interface.','YesNo'), ('FRBRizeEditions','0','','If ON, Koha will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), ('GenerateAuthorityField667', 'Machine generated authority record', NULL, 'When BiblioAddsAuthorities and AutoCreateAuthorities are enabled, use this as a default value for the 667$a field of MARC21 records', 'free'), ('GenerateAuthorityField670', 'Work cat.', NULL, 'When BiblioAddsAuthorities and AutoCreateAuthorities are enabled, use this as a default value for the 670$a field of MARC21 records', 'free'), 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 c25ee18962..af54800354 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 @@ -138,6 +138,13 @@ Administration: choices: 1: "Yes" 0: "No" + - + - pref: ForcedLibrarySelection + choices: + 1: "Force" + 0: "Don't force" + - "library selection when logging into the staff interface." + CAS authentication: - - "Use CAS for login authentication: " diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt index e7b6e0ac5d..9e2e6e5cb0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -135,13 +135,22 @@ [% UNLESS IndependentBranches %]

- - + + [% ELSE %] + + + [% IF Koha.Preference('ForcedLibrarySelection') %] + Required + [% END %]

[% IF Koha.Preference('UseCirculationDesks') && Desks.all %] -- 2.39.5