Bug 35048: Convert SCOMainUserBlock system preference to HTML customization

This patch moves the SCOMainUserBlock system preference into HTML
customizations, making it possible to have language- and
library-specific content.

The patch also makes a minor fix to CSS in order to get the "Back to
top" link to show up correctly in self-checkout and self-checkin.

To test you should have some content in the SCOMainUserBlock
system preference before applying the patch. Apply the patch, run the
database update process, and rebuild the OPAC CSS.

- In the staff client, go to Tools -> HTML customizations and verify
  that the content from SCOMainUserBlock is now stored there.
- The HTML customization entry form should offer SCOMainUserBlock
  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.
- Enable the "opaclanguagesdisplay" preference if necessary.
- Edit the SCOMainUserBlock HTML customization and add unique
  content to the "fr-FR" tab.

- Log into the self checkout system and confirm that the
  SCOMainUserBlock content is shown there.
- 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
  "SCOMainUserBlock." It should return no results.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2023-10-12 18:01:04 +00:00 committed by Tomas Cohen Arazi
parent 6815af3feb
commit c873859423
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
7 changed files with 59 additions and 19 deletions

View file

@ -0,0 +1,41 @@
use Modern::Perl;
return {
bug_number => "35048",
description => "Move SCOMainUserBlock to additional contents",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Get any existing value from the SCOMainUserBlock system preference
my ($scomainuserblock) = $dbh->selectrow_array(
q|
SELECT value FROM systempreferences WHERE variable='SCOMainUserBlock';
|
);
if ($scomainuserblock) {
# Insert any values found from system preference into additional_contents
$dbh->do(
"INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'SCOMainUserBlock', 'SCOMainUserBlock', NULL, CAST(NOW() AS date) )"
);
my ($insert_id) = $dbh->selectrow_array(
"SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'SCOMainUserBlock' AND location = 'SCOMainUserBlock' LIMIT 1",
{}
);
$dbh->do(
"INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'SCOMainUserBlock default', ?, 'default' )",
undef, $insert_id, $scomainuserblock
);
say $out "Added 'SCOMainUserBlock' HTML customization";
}
# Remove old system preference
$dbh->do("DELETE FROM systempreferences WHERE variable='SCOMainUserBlock'");
say $out "Removed system preference 'SCOMainUserBlock'";
},
};

View file

@ -656,7 +656,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'),
('SCOAllowCheckin','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'),
('SCOLoadCheckoutsByDefault','1','','If enabled, load the list of a patrons checkouts when they log in to the Self Checkout','YesNo'),
('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'),
('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'),
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),

View file

@ -1149,12 +1149,6 @@ Circulation:
type: textarea
syntax: javascript
class: code
-
- "Include the following HTML on the the web-based self checkout screen:"
- pref: SCOMainUserBlock
type: textarea
syntax: text/html
class: code
-
- "Include the following CSS on all pages in the web-based self checkout:"
- pref: SCOUserCSS

View file

@ -524,7 +524,7 @@
[% END %]
[% END %]
[% ELSE %]
[% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'OpacSuppressionMessage', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions' ] %]
[% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'OpacSuppressionMessage', 'SCOMainUserBlock', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions' ] %]
<optgroup label="OPAC">
[% FOREACH l IN opac_available_options.sort %]
[% IF l == location %]

View file

@ -848,6 +848,16 @@ button {
}
}
#backtotop {
bottom: 40px;
display: inline-block;
font-size: 120%;
position: fixed;
right: 40px;
text-align: center;
z-index: 1000;
}
#logo {
background: transparent url( "../images/koha-green-logo.svg" ) no-repeat scroll 0%;
border: 0;

View file

@ -245,16 +245,6 @@ th {
}
}
#backtotop {
bottom: 40px;
display: inline-block;
font-size: 120%;
position: fixed;
right: 40px;
text-align: center;
z-index: 1000;
}
#booleansearch {
width: 80%;
}

View file

@ -5,6 +5,8 @@
[% USE AudioAlerts %]
[% USE To %]
[% USE Price %]
[% USE AdditionalContents %]
[% SET SCOMainUserBlock = AdditionalContents.get( location => "SCOMainUserBlock", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Self checkout &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %]</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -476,7 +478,11 @@
</div> <!-- / .sco_entry -->
[% END # / IF validuser %]
[% END # / UNLESS ( hide_main %]
[% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
[% IF ( SCOMainUserBlock ) %]
<div id="scomainuserblock">
[% PROCESS koha_news_block news => SCOMainUserBlock %]
</div>
[% END %]
</div> <!-- / .span12 -->
</div> <!-- / .row -->
</div> <!-- / .container-fluid -->