Bug 12264: Correct tiny typo in t/db_dependent/Items.t
[koha.git] / admin / didyoumean.pl
blob434d0e9a31c3671b8dcbbb929f05d7e3cc0842e1
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use CGI;
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;