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.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2025-01-10 20:13:48 +00:00 committed by Katrin Fischer
parent d32a1b7063
commit 30a2d78d53
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
6 changed files with 59 additions and 9 deletions

View File

@ -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'";
},
};

View File

@ -754,7 +754,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'),
('StaffInterfaceLanguages','en',NULL,'Set the default language in the staff interface.','Languages'),
('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'),
('StaffLoginLibraryBasedOnIP', '1','', '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'),

View File

@ -118,6 +118,10 @@
Show this content on the lists home page in the staff interface.
</div>
<div id="StaffLoginInstructions_notes" class="hint customization_note">
Show this content on the staff interface login page.
</div>
<div id="StaffPatronsHome_notes" class="hint customization_note">
Show this content on the patrons home page in the staff interface.
</div>

View File

@ -119,12 +119,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

View File

@ -6,6 +6,7 @@
[% USE Categories %]
[% USE Registers %]
[% USE AuthClient %]
[% USE AdditionalContents %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
@ -48,7 +49,19 @@
<div id="login">
<h1><a href="http://koha-community.org">Koha</a></h1>
[% IF (Koha.Preference('StaffLoginInstructions')) %]<div id="login_instructions">[% Koha.Preference('StaffLoginInstructions') | $raw %]</div>[% END %]
[% SET StaffLoginInstructions = AdditionalContents.get( location => "StaffLoginInstructions", lang => lang ) %]
[% IF ( StaffLoginInstructions.content && StaffLoginInstructions.content.count > 0 ) %]
<div id="[% StaffLoginInstructions.location | html %]" class="page-section">
[% FOREACH n IN StaffLoginInstructions.content %]
<div class="[% n.lang | html %]_item">
<div class="[% n.lang | html %]_body">[% n.content | $raw %]</div>
</div>
[% END %]
</div> <!-- /#StaffLoginInstructions -->
[% END # /IF StaffLoginInstructions %]
[% IF ( nopermission ) %]
<div id="login_error">
<strong>Error:</strong>

View File

@ -538,7 +538,7 @@
[% END %]
[% END %]
</optgroup>
[% SET staff_available_options = [ 'IntranetmainUserblock', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %]
[% SET staff_available_options = [ 'IntranetmainUserblock', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffLoginInstructions', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %]
<optgroup label="Staff interface">
[% FOREACH l IN staff_available_options.sort %]
[% IF l == location %]