Bug 25826: Add a warning to the about page
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 22 Jul 2020 14:43:38 +0000 (16:43 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 7 Aug 2020 07:55:50 +0000 (09:55 +0200)
This patch adds a warning to the about page if the biblionumber field is
hidden at the OPAC or staff interface.

Test plan:
Hide the biblionumber to some framework
Confirm that there is a warning on the about page

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

about.pl
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

index b44e531..029bd94 100755 (executable)
--- a/about.pl
+++ b/about.pl
@@ -43,6 +43,7 @@ use C4::Installer::PerlModules;
 use Koha;
 use Koha::DateUtils qw(dt_from_string output_pref);
 use Koha::Acquisition::Currencies;
+use Koha::BiblioFrameworks;
 use Koha::Patron::Categories;
 use Koha::Patrons;
 use Koha::Caches;
@@ -50,6 +51,7 @@ use Koha::Config::SysPrefs;
 use Koha::Illrequest::Config;
 use Koha::SearchEngine::Elasticsearch;
 use Koha::Logger;
+use Koha::Filter::MARC::ViewPolicy;
 
 use C4::Members::Statistics;
 
@@ -525,6 +527,32 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
       and not C4::Context->config('bcrypt_settings');
 }
 
+{
+    my @frameworkcodes = Koha::BiblioFrameworks->search->get_column('frameworkcode');
+    my @hidden_biblionumbers;
+    push @frameworkcodes, ""; # it's not in the biblio_frameworks table!
+    for my $frameworkcode ( @frameworkcodes ) {
+        my $shouldhidemarc_opac = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
+            {
+                frameworkcode => $frameworkcode,
+                interface     => "opac"
+            }
+        );
+        push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'opac' }
+          if $shouldhidemarc_opac->{biblionumber};
+
+        my $shouldhidemarc_intranet = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
+            {
+                frameworkcode => $frameworkcode,
+                interface     => "intranet"
+            }
+        );
+        push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'intranet' }
+          if $shouldhidemarc_intranet->{biblionumber};
+    }
+    $template->param( warnHiddenBiblionumbers => \@hidden_biblionumbers );
+}
+
 my %versions = C4::Context::get_versions();
 
 $template->param(
index 70ed9b1..e4402d3 100644 (file)
         </div>
 
         <div id="sysinfo">
-    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set %]
+    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size %]
         [% IF (warnIsRootUser) %]
             <h2>Warning regarding current user</h2>
             <p>You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.</p>
             [% END %]
         [% END %]
 
-        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set %]
+        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size %]
             <h2>Warnings regarding the system configuration</h2>
             <table>
                 <caption>Preferences and parameters</caption>
                     System preference 'Pseudonymization' is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file.
                     </td></tr>
                 [% END %]
+                [% IF config_bcrypt_settings_no_set %]
+                    <tr><th scope="row"><b>Warning</b> </th><td>
+                    System preference 'Pseudonymization' is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file.
+                    </td></tr>
+                [% END %]
+                [% IF warnHiddenBiblionumbers.size %]
+                    <tr><th scope="row"><b>Warning</b> </th><td>
+                    [% FOR w IN warnHiddenBiblionumbers %]
+                        Biblio framework "[% w.frameworkcode %]" has the biblionumber field hidden at the interface [% w.interface %]<br/>
+                    [% END %]
+                    </td></tr>
+                [% END %]
             </table>
         [% END %]