From 294eebd02787e4deaba800f7f5d5085673282eff Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 2 Sep 2020 11:17:15 +0200
Subject: [PATCH] Bug 22417: Add rabbitmq status indicator on the about page

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 about.pl                                      | 12 ++++++++++
 .../intranet-tmpl/prog/en/modules/about.tt    | 22 ++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/about.pl b/about.pl
index 56037c8aa5..14f555ecd9 100755
--- 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::BackgroundJob;
 use Koha::BiblioFrameworks;
 use Koha::Patron::Categories;
 use Koha::Patrons;
@@ -552,6 +553,17 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
     $template->param( warnHiddenBiblionumbers => \@hidden_biblionumbers );
 }
 
+{
+    # BackgroundJob - test connection to message broker
+    eval {
+        Koha::BackgroundJob->connect;
+    };
+    if ( $@ ) {
+        warn $@;
+        $template->param( warnConnectBroker => $@ );
+    }
+}
+
 my %versions = C4::Context::get_versions();
 
 $template->param(
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
index cc4ef76dec..7ab369b0e4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
@@ -113,6 +113,17 @@
             [% ELSIF (errZebraConnection) %]
             <tr><th scope="row"><strong>Warning</strong> </th><td>Error message from Zebra: [% ( errZebraConnection ) | html %] </td></tr>
             [% END %]
+            <tr>
+                <th scope="row">Message broker: </th>
+                <td>
+                    Status:
+                    [% IF warnConnectBroker %]
+                        <span class="status_warn">connection failed</span>
+                    [% ELSE %]
+                        <span class="status_ok">running</span>
+                    [% END %]
+                </td>
+            </tr>
             <tr>
               <th scope="row">Date and time: </th>
               <td>[% current_date_and_time | $KohaDates  with_hours => 1 %]</td>
@@ -184,7 +195,7 @@
         </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 || warnHiddenBiblionumbers.size %]
+    [% 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 || warnConnectBroker%]
         [% 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>
@@ -259,6 +270,15 @@
             [% END %]
         [% END %]
 
+        [% IF warnConnectBroker %]
+            <h2>Impossible to connect to the message broker</h2>
+            There is an error when trying to connect to the message broker (RabbitMQ), check the Koha log files.
+            <br/>
+            Maybe it is not installed and configured correctly?
+            <br/>
+            Contact your system administrator.
+        [% 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 || warnHiddenBiblionumbers.size %]
             <h2>Warnings regarding the system configuration</h2>
             <table>
-- 
2.24.1 (Apple Git-126)