Bug 18349: [QA Follow-up] Add four missing error messages
[koha.git] / admin / didyoumean.pl
blob52ebeaa4877d560c6602534b15c76f6d1d7fee33
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use CGI qw ( -utf8 );
6 use C4::Context;
7 use C4::Auth;
8 use C4::Output;
9 use Koha::SuggestionEngine;
10 use Module::Load::Conditional qw(can_load);
11 use JSON;
13 my $input = new CGI;
15 my ($template, $loggedinuser, $cookie)
16 = get_template_and_user({template_name => "admin/didyoumean.tt",
17 query => $input,
18 type => "intranet",
19 authnotrequired => 0,
20 flagsrequired => {parameters => 'parameters_remaining_permissions'},
21 debug => 1,
22 });
24 my $opacplugins = from_json(C4::Context->preference('OPACdidyoumean') || '[]');
26 my $intraplugins = from_json(C4::Context->preference('INTRAdidyoumean') || '[]');
28 my @pluginlist = Koha::SuggestionEngine::AvailablePlugins();
29 foreach my $plugin (@pluginlist) {
30 next if $plugin eq 'Koha::SuggestionEngine::Plugin::Null';
31 next unless (can_load( modules => { "$plugin" => undef } ));
32 push @$opacplugins, { name => $plugin->NAME } unless grep { $_->{name} eq $plugin->NAME } @$opacplugins;
33 push @$intraplugins, { name => $plugin->NAME } unless grep { $_->{name} eq $plugin->NAME } @$intraplugins;
35 $template->{VARS}->{OPACpluginlist} = $opacplugins;
36 $template->{VARS}->{INTRApluginlist} = $intraplugins;
37 output_html_with_http_headers $input, $cookie, $template->output;