Bug 35151: Convert ILLModuleCopyrightClearance system preference to additional contents

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

To test you should have some content in the ILLModuleCopyrightClearance
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 ILLModuleCopyrightClearance is now stored there.
- The HTML customization entry form should offer
  ILLModuleCopyrightClearance 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 ILLModuleCopyrightClearance HTML customization and add unique
  content to the "fr-FR" tab.

- Enable the "ILLModule" and "ILLModuleUnmediated" system preferences if
  necessary. You must have at least one ILL backend installed.
- Log into the OPAC and click the "Interlibrary loan requests" in the
  sidebar menu on the user summary page.
- Click "Create new request."
- You should be taken to a page with your ILLModuleCopyrightClearance
  content shown along with "Yes" and "No" buttons.
  - Clicking "Yes" should take you to the form for creating a new
    request.
- Switch to your updated translation and confirm that the content
  appears correctly.
- Remove all "ILLModuleCopyrightClearance" html customizations. Test the
  "Create new request" process in the OPAC again.
  - There should be no confirmation step before arriving at the form for
    creating a new ILL request.
- Go to Administration -> System preferences and search for
  "ILLModuleCopyrightClearance." It should return no results.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2023-10-26 14:38:14 +00:00 committed by Katrin Fischer
parent a4855c3ce2
commit c1ac7b4db9
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
6 changed files with 73 additions and 7 deletions

View File

@ -41,6 +41,7 @@ use Koha::Biblios;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::AdditionalContents;
use C4::Circulation qw( CanBookBeIssued AddIssue );
@ -932,9 +933,20 @@ sub backend_create {
my ( $self, $params ) = @_;
# Establish whether we need to do a generic copyright clearance.
if ($params->{opac}) {
if ( $params->{opac} ) {
my $copyright_content = Koha::AdditionalContents->search_for_display(
{
category => 'html_customizations',
location => ['ILLModuleCopyrightClearance'],
lang => $params->{lang},
library_id => $params->{branchcode},
}
);
if ( ( !$params->{stage} || $params->{stage} eq 'init' )
&& C4::Context->preference("ILLModuleCopyrightClearance") ) {
&& $copyright_content->count )
{
return {
error => 0,
status => '',

View File

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

View File

@ -18,6 +18,10 @@
Include this content in the popup message which is displayed in the OPAC when the CookieConsent system preference is enabled and the user clicks the "Your cookies" menu item in the header.
</div>
<div id="ILLModuleCopyrightClearance_notes" class="hint customization_note">
Adding content to this region will enable the copyright clearance stage in request creation. The content will appear on the OPAC during the process of placing an ILL request.
</div>
<div id="opaccredits_notes" class="hint customization_note">
Include this content in the footer of all pages in the OPAC.
</div>

View File

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

View File

@ -6,6 +6,7 @@
[% USE AdditionalContents %]
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET ILLModuleCopyrightClearance = AdditionalContents.get( location => "ILLModuleCopyrightClearance", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Your interlibrary loan requests &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
@ -78,13 +79,17 @@
[% INCLUDE messages %]
<div>
<p>
[% Koha.Preference('ILLModuleCopyrightClearance') | $raw %]
[% IF ( ILLModuleCopyrightClearance ) %]
<div id="ILLModuleCopyrightClearance">
[% PROCESS koha_news_block news => ILLModuleCopyrightClearance %]
</div>
[% END %]
</p>
[% USE link_url = url('/cgi-bin/koha/opac-illrequests.pl', whole.value.other) %]
<a href="[% link_url _ '&amp;stage=copyrightclearance' | $raw %]"
class="btn btn-sm btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Yes</a>
class="btn btn-sm btn-primary"><i class="fa fa-fw fa-check" aria-hidden="true"></i> Yes</a>
<a href="/cgi-bin/koha/opac-illrequests.pl"
class="btn btn-sm btn-danger"><i class="fa fa-times" aria-hidden="true"></i> No</a>
class="btn btn-sm btn-danger"><i class="fa fa-fw fa-times" aria-hidden="true"></i> No</a>
</div>
[% ELSE %]
[% INCLUDE messages %]

View File

@ -147,8 +147,12 @@ if ( $op eq 'list' ) {
exit;
}
my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
$params->{cardnumber} = $patron->cardnumber;
$params->{opac} = 1;
$params->{branchcode} = $patron->branchcode;
$params->{opac} = 1;
$params->{lang} = C4::Languages::getlanguage($query);
my $backend_result = $request->backend_create($params);
if ($backend_result->{stage} eq 'copyrightclearance') {