From f4ef662ec7d6bf6cc830216d4156d202d6939f65 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 22 Aug 2022 11:03:20 +0100
Subject: [PATCH] Bug 31028: Use additional_contents for help block

This patch updates the modal to use the additional_contents system for
the modals help block
---
 installer/data/mysql/atomicupdate/bug_31028.pl        |  6 ++++++
 installer/data/mysql/en/optional/sample_news.yml      | 11 +++++++++++
 .../prog/en/includes/modals/add_catalog_concern.inc   |  8 +++++++-
 .../prog/en/modules/tools/additional-contents.tt      |  2 +-
 .../bootstrap/en/includes/modals/catalog_concern.inc  |  8 +++++++-
 5 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl
index 6be890a4de..d26427eede 100644
--- a/installer/data/mysql/atomicupdate/bug_31028.pl
+++ b/installer/data/mysql/atomicupdate/bug_31028.pl
@@ -62,5 +62,11 @@ return {
             }
         );
 
+        $dbh->do(
+            q{
+                INSERT INTO additional_contents ( category, code, location, title, content, lang, published_on ) VALUES ('html_customizations', 'CatalogConcernHelp_1', 'CatalogConcernHelp', '', 'Please describe your concern clearly and the library will try to deal with it as quickly as possible', 'default', CAST(NOW() AS date) )
+            }
+        );
+
     },
 }
diff --git a/installer/data/mysql/en/optional/sample_news.yml b/installer/data/mysql/en/optional/sample_news.yml
index 7023d8c02a..543e9faf87 100644
--- a/installer/data/mysql/en/optional/sample_news.yml
+++ b/installer/data/mysql/en/optional/sample_news.yml
@@ -55,3 +55,14 @@ tables:
           published_on: "2007-10-29 05:34:45"
           expirationdate: "2099-01-10"
           number: 2
+
+        - title: ""
+          category: "html_customizations"
+          location: "CatalogConcernHelp"
+          code: "CatalogConcernHelp_1"
+          content:
+              - "Please describe your concern clearly and the library will try to deal with it as quickly as possible"
+          lang: "default"
+          published_on: "2007-10-29 05:25:58"
+          expirationdate: "2099-01-10"
+          number: 1
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/add_catalog_concern.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/add_catalog_concern.inc
index 10bf54c9bb..87174fe594 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/add_catalog_concern.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/add_catalog_concern.inc
@@ -1,3 +1,5 @@
+[% USE AdditionalContents %]
+[% SET CatalogConcernHelp = AdditionalContents.get( location => "CatalogConcernHelp", lang => lang, library => logged_in_user.branchcode ) %]
 <!-- Add concern modal -->
 <div class="modal" id="addConcernModal" tabindex="-1" role="dialog" aria-labelledby="addConcernLabel">
     <div class="modal-dialog" role="document">
@@ -22,7 +24,11 @@
                             <label class="required" for="message">Please describe your concern: </label>
                             <textarea id="message_add" name="message" required="required"></textarea>
                             <span class="required">Required</span>
-                            <p id="helpBlock" class="help-block">A short summary of what the library policy is for dealing with such concerns and what constitutes a valid concern</p>
+                            [%- IF CatalogConcernHelp && CatalogConcernHelp.content && CatalogConcernHelp.content.count > 0 -%]
+                            [% FOREACH help IN CatalogConcernHelp.content %]
+                            <p id="helpBlock" class="help-block">[% help.content | $raw %]</p>
+                            [%- END -%]
+                            [%- END -%]
                         </li>
                     </ol>
                 </fieldset>
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 466ea280b2..bbca89edb9 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
@@ -484,7 +484,7 @@
             [% END %]
         [% END %]
     [% ELSE %]
-        [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo' ] %]
+        [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp' ] %]
         [% FOREACH l IN available_options.sort %]
             [% IF l == location %]
                 <option value="[% l | html %]" selected="selected">[% l | html %]</option>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc
index 5b0ff09627..e62800effb 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc
@@ -1,3 +1,5 @@
+[% USE AdditionalContents %]
+[% SET CatalogConcernHelp = AdditionalContents.get( location => "CatalogConcernHelp", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
 <!-- Add concern modal -->
 <div class="modal" id="addConcernModal" tabindex="-1" role="dialog" aria-labelledby="addConcernModalLabel" aria-hidden="true">
     <div class="modal-dialog">
@@ -13,7 +15,11 @@
                     <div class="form-group">
                         <label for="message">Please decribe your concerns: </label>
                         <textarea class="form-control" name="message" id="message_add" aria-describedby="helpBlock" required="required"></textarea>
-                        <p id="helpBlock" class="help-block">A short summary of what the library policy is for dealing with such concerns and what constitutes a valid concern</p>
+                        [%- IF CatalogConcernHelp && CatalogConcernHelp.content && CatalogConcernHelp.content.count > 0 -%]
+                        [% FOREACH help IN CatalogConcernHelp.content %]
+                        <p id="helpBlock" class="help-block">[% help.content | $raw %]</p>
+                        [%- END -%]
+                        [%- END -%]
                     </div>
                 </fieldset>
             </div>
-- 
2.20.1