Bug 23075: Report if mana-kb server is not found
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 17 Jun 2019 17:24:04 +0000 (18:24 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 6 Nov 2019 17:04:57 +0000 (17:04 +0000)
This patch adds a status check into the mana configuration page and
prompts the user to ask an adminstrator to check the configured mana
service url.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

admin/share_content.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt

index 46f270e..7bfa3c8 100755 (executable)
@@ -39,6 +39,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 );
 
 my $op = $query->param('op') || q{};
+my $mana_base = C4::Context->config('mana_config') || '';
+# Check the mana server actually exists at the other end
+my $bad_url;
+if ($mana_base) {
+    my $request = HTTP::Request->new( GET => $mana_base );
+    my $result = Koha::SharedContent::process_request($request);
+    $bad_url = 1 unless (exists($result->{version}));
+}
 
 if ( $op eq 'save' ) {
     my $auto_share = $query->param('autosharewithmana') || q{};
@@ -64,8 +72,7 @@ if ( $op eq 'send' ) {
     my $content = to_json({name => $name,
                            email => $email});
 
-    my $mana_ip = C4::Context->config('mana_config');
-    my $url = "$mana_ip/getsecuritytoken";
+    my $url = "$mana_base/getsecuritytoken";
     my $request = HTTP::Request->new( POST => $url );
     $request->content($content);
     my $result = Koha::SharedContent::process_request($request);
@@ -78,10 +85,9 @@ if ( $op eq 'send' ) {
 }
 
 
-my $mana_url = C4::Context->config('mana_config') || q{};
-
 $template->param(
-    mana_url    => $mana_url,
+    mana_url    => $mana_base,
+    bad_url     => $bad_url,
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;
index 1a3bcd8..d441b06 100644 (file)
                     <div class="dialog alert" role="alert">
                         Mana configuration is currently empty. This feature will not work. Please contact your site administrator.
                     </div>
+                [% ELSIF (bad_url) %]
+                    <div class="dialog alert" role="alert">
+                        Cannot detect mana server at <strong>[% mana_url | url %]</strong>, please ask an administrator to check your configuration.
+                    </div>
                 [% END %]
 
                 <h1>Share content with the Koha community using Mana KB</h1>