From 7cde4dcf432fcafffe906aaad7b88228c4d5fd5f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 20 Nov 2023 13:51:22 +0000 Subject: [PATCH] Bug 35153: Convert IntranetmainUserblock system preference to additional contents This patch moves the IntranetmainUserblock system preference into HTML customizations, making it possible to have language- and library-specific content. To test you should have some content in the IntranetmainUserblock 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 IntranetmainUserblock is now stored there. - The HTML customization entry form should offer IntranetmainUserblock 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 IntranetmainUserblock HTML customization and add unique content to the "fr-FR" tab. - Go to the staff client home page. You should see the content you added to the IntranetmainUserblock 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 "IntranetmainUserblock." It should return no results. Signed-off-by: David Nind Signed-off-by: Kyle M Hall --- ...netmainUserblock-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 --- .../prog/en/modules/intranet-main.tt | 23 ++++++----- .../en/modules/tools/additional-contents.tt | 2 +- 6 files changed, 59 insertions(+), 17 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-35153-move-IntranetmainUserblock-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-35153-move-IntranetmainUserblock-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-35153-move-IntranetmainUserblock-to-additional-contents.pl new file mode 100755 index 00000000000..e50c7ba5e90 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35153-move-IntranetmainUserblock-to-additional-contents.pl @@ -0,0 +1,40 @@ +use Modern::Perl; + +return { + bug_number => "35153", + description => "Move IntranetmainUserblock to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the IntranetmainUserblock system preference + my ($intranetmainuserblock) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='IntranetmainUserblock'; + | + ); + if ($intranetmainuserblock) { + + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'IntranetmainUserblock', 'IntranetmainUserblock', NULL, CAST(NOW() AS date) )" + ); + + my ($insert_id) = $dbh->selectrow_array( + "SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'IntranetmainUserblock' AND location = 'IntranetmainUserblock' LIMIT 1", + {} + ); + + $dbh->do( + "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'IntranetmainUserblock default', ?, 'default' )", + undef, $insert_id, $intranetmainuserblock + ); + + say $out "Added 'IntranetmainUserblock' HTML customization"; + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='IntranetmainUserblock'"); + say $out "Removed system preference 'IntranetmainUserblock'"; + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 76caf691ce1..47f2066e76f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -330,7 +330,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('IntranetCoce','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff interface', 'YesNo'), ('intranetcolorstylesheet','','50','Define the color stylesheet to use in the staff interface','free'), ('IntranetFavicon','','','Enter a complete URL to an image to replace the default Koha favicon on the staff interface','free'), -('IntranetmainUserblock','','70|10','Add a block of HTML that will display on the intranet home page','Textarea'), ('IntranetNav','','70|10','Use HTML tabs to add navigational links to the top-hand navigational bar in the staff interface','Textarea'), ('IntranetNumbersPreferPhrase','0',NULL,'Control the use of phr operator in callnumber and standard number staff interface searches','YesNo'), ('intranetreadinghistory','1','','If ON, Checkout history is enabled for all patrons','YesNo'), 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 1327adf2c4e..15bf876fc68 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 @@ -22,6 +22,10 @@ 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 its own section on the main page of the staff interface +
+
Include this content in the footer of all pages in the OPAC.
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 62dca5a673e..97f0298614c 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 @@ -49,12 +49,6 @@ Staff interface: - pref: intranet_includes class: file - directory in the template directory, instead of includes/. (Leave blank to disable) - - - - "Show the following HTML in its own column on the main page of the staff interface:" - - pref: IntranetmainUserblock - type: textarea - syntax: text/html - class: code - - "Show the following HTML to the left of the More menu at the top of each page on the staff interface (should be a list of links or blank):" - pref: IntranetNav diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 856d9fb0c38..a1fb26970cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -3,6 +3,7 @@ [% USE Koha %] [% USE Branches %] [% USE KohaDates %] +[% USE AdditionalContents %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -276,17 +277,21 @@ - [% IF ( IntranetmainUserblock ) %] + [% SET IntranetmainUserblock = AdditionalContents.get( location => "IntranetmainUserblock", lang => lang, library => logged_in_user.branchcode || default_branch ) %] + + [% IF ( IntranetmainUserblock.content && IntranetmainUserblock.content.count > 0 ) %]
-
- -
-
-
- [% END %] +
+ [% FOREACH n IN IntranetmainUserblock.content %] +
+
[% n.content | $raw %]
+
+ [% END %] +
+ + + [% END # /IF IntranetmainUserblock %]
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 c3bc9971f88..560ea475f7e 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 @@ -536,7 +536,7 @@ [% END %] [% END %] - [% SET staff_available_options = [ 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] + [% SET staff_available_options = [ 'IntranetmainUserblock', 'RoutingListNote', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] [% FOREACH l IN staff_available_options.sort %] [% IF l == location %] -- 2.30.2