From fd8ac0f2435a8523cd1ac1f2039cd4ab54e6d6f4 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 :)
---
installer/data/mysql/atomicupdate/bug_34188.pl | 18 ++++++++++++++++++
installer/data/mysql/mandatory/sysprefs.sql | 1 +
.../en/modules/admin/preferences/admin.pref | 7 +++++++
.../intranet-tmpl/prog/en/modules/auth.tt | 15 ++++++++++++---
4 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 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 100644
index 0000000000..e5ad546635
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_34188.pl
@@ -0,0 +1,18 @@
+use Modern::Perl;
+
+return {
+ bug_number => "BUG_NUMBER",
+ description => "A single line description",
+ up => sub {
+ my ($args) = @_;
+ my ($dbh, $out) = @$args{qw(dbh out)};
+ # Do you stuffs here
+ $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 38a756f817..f83b76b175 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -255,6 +255,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 23b70b29b4..2bacd6ea5c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
@@ -115,14 +115,23 @@