From 9755353f029ccf38d5121c75762141bf8ea63901 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 20 Nov 2023 14:33:13 +0000 Subject: [PATCH] Bug 35154: Convert StaffLoginInstructions system preference to additional contents This patch moves the StaffLoginInstructions system preference into HTML customizations, making it possible to have language-specific content. To test you should have some content in the StaffLoginInstructions system preference before applying the patch. Apply the patch and run the database update process. - In the staff client, go to Tools -> HTML customizations and verify that the content from StaffLoginInstructions is now stored there. - The HTML customization entry form should offer StaffLoginInstructions as a choice under "Display location." - Update and reinstall active translations (for instance fr-FR): - perl misc/translator/translate update fr-FR - perl misc/translator/translate install fr-FR - Enable the translation if necessary under Administration -> System preferences -> language. - Edit the StaffLoginInstructions HTML customization and add unique content to the "fr-FR" tab. - View the staff interface login page. You should see the content you added to the StaffLoginInstructions HTML customization. - Switch to your updated translation and confirm that the content you added for your translation shows up correctly. - Go to Administration -> System preferences and search for "StaffLoginInstructions." It should return no results. --- ...oginInstructions-to-additional-contents.pl | 40 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/includes/html-customization-help.inc | 4 ++ .../admin/preferences/staff_interface.pref | 6 --- .../intranet-tmpl/prog/en/modules/auth.tt | 15 ++++++- .../en/modules/tools/additional-contents.tt | 2 +- 6 files changed, 59 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-35154-move-StaffLoginInstructions-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-35154-move-StaffLoginInstructions-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-35154-move-StaffLoginInstructions-to-additional-contents.pl new file mode 100755 index 0000000000..b87c3e6ee5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35154-move-StaffLoginInstructions-to-additional-contents.pl @@ -0,0 +1,40 @@ +use Modern::Perl; + +return { + bug_number => "35154", + description => "Move StaffLoginInstructions to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the StaffLoginInstructions system preference + my ($stafflogininstructions) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='StaffLoginInstructions'; + | + ); + if ($stafflogininstructions) { + + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'StaffLoginInstructions', 'StaffLoginInstructions', NULL, CAST(NOW() AS date) )" + ); + + my ($insert_id) = $dbh->selectrow_array( + "SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'StaffLoginInstructions' AND location = 'StaffLoginInstructions' LIMIT 1", + {} + ); + + $dbh->do( + "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'StaffLoginInstructions default', ?, 'default' )", + undef, $insert_id, $stafflogininstructions + ); + + say $out "Added 'StaffLoginInstructions' HTML customization"; + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='StaffLoginInstructions'"); + say $out "Removed system preference 'StaffLoginInstructions'"; + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 580abfcb4b..02939bc141 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -707,7 +707,6 @@ 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'), -('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'), ('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'), ('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc index a65ff1f2a7..e0fc37f9df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc @@ -122,6 +122,10 @@ Show this content on the lists home page in the staff interface. +
+ Show this content on the staff interface login page. +
+
Show this content on the patrons home page in the staff interface.
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref index 97f0298614..8c21439efb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -113,12 +113,6 @@ Staff interface: type: textarea syntax: text/html class: code - - - - "Show the following HTML on the staff interface login page" - - pref: StaffLoginInstructions - type: textarea - syntax: text/html - class: code - - pref: StaffHighlightedWords type: boolean diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt index 14e30e5e6e..eca510595e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -6,6 +6,7 @@ [% USE Categories %] [% USE Registers %] [% USE AuthClient %] +[% USE AdditionalContents %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -47,7 +48,19 @@

Koha

-[% IF (Koha.Preference('StaffLoginInstructions')) %]
[% Koha.Preference('StaffLoginInstructions') | $raw %]
[% END %] + +[% SET StaffLoginInstructions = AdditionalContents.get( location => "StaffLoginInstructions", lang => lang ) %] + +[% IF ( StaffLoginInstructions.content && StaffLoginInstructions.content.count > 0 ) %] +
+ [% FOREACH n IN StaffLoginInstructions.content %] +
+
[% n.content | $raw %]
+
+ [% END %] +
+[% END # /IF StaffLoginInstructions %] + [% IF ( nopermission ) %]
Error: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 4b01f58268..dfd395b565 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -534,7 +534,7 @@ [% END %] [% END %] - [% SET staff_available_options = [ 'IntranetmainUserblock', 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] + [% SET staff_available_options = [ 'IntranetmainUserblock', 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffLoginInstructions', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] [% FOREACH l IN staff_available_options.sort %] [% IF l == location %] -- 2.30.2