From c1ac7b4db9354d3b55ba700f06660a4592cef91e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 26 Oct 2023 14:38:14 +0000 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- Koha/Illrequest.pm | 16 +++++++- ...pyrightClearance-to-additional-contents.pl | 41 +++++++++++++++++++ .../en/includes/html-customization-help.inc | 4 ++ .../en/modules/tools/additional-contents.tt | 2 +- .../bootstrap/en/modules/opac-illrequests.tt | 11 +++-- opac/opac-illrequests.pl | 6 ++- 6 files changed, 73 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-35151-move-ILLModuleCopyrightClearance-to-additional-contents.pl diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 9dfe275eff..980fce5bcd 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -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 => '', diff --git a/installer/data/mysql/atomicupdate/bug-35151-move-ILLModuleCopyrightClearance-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-35151-move-ILLModuleCopyrightClearance-to-additional-contents.pl new file mode 100755 index 0000000000..380e265e4e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35151-move-ILLModuleCopyrightClearance-to-additional-contents.pl @@ -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'"; + + }, +}; 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 a6bb9f3109..2d9399f939 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 @@ -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. +
+ 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. +
+
Include this content in the footer of all pages in the OPAC.
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 ad010de3b2..2edc683570 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 @@ -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' ] %] [% FOREACH l IN opac_available_options.sort %] [% IF l == location %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index bea312b56f..8adb5229df 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -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' %] Your interlibrary loan requests › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] @@ -78,13 +79,17 @@ [% INCLUDE messages %]

- [% Koha.Preference('ILLModuleCopyrightClearance') | $raw %] + [% IF ( ILLModuleCopyrightClearance ) %] +

+ [% PROCESS koha_news_block news => ILLModuleCopyrightClearance %] +
+ [% END %]

[% USE link_url = url('/cgi-bin/koha/opac-illrequests.pl', whole.value.other) %] Yes + class="btn btn-sm btn-primary"> Yes No + class="btn btn-sm btn-danger"> No
[% ELSE %] [% INCLUDE messages %] diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index e47db9bf68..65a8766180 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -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') { -- 2.39.5