diff --git a/Koha/SuggestionEngine/Plugin/LibrisSpellcheck.pm b/Koha/SuggestionEngine/Plugin/LibrisSpellcheck.pm deleted file mode 100644 index 75ab26dfc3..0000000000 --- a/Koha/SuggestionEngine/Plugin/LibrisSpellcheck.pm +++ /dev/null @@ -1,102 +0,0 @@ -package Koha::SuggestionEngine::Plugin::LibrisSpellcheck; - -# Copyright (C) 2015 Eivin Giske Skaaren -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . - -use Modern::Perl; -use LWP::UserAgent; -use XML::Simple qw( XMLin ); -use C4::Context; -use base qw(Koha::SuggestionEngine::Base); - -sub NAME { - return 'LibrisSpellcheck'; -} - -sub get_suggestions { - my ( $self, $query ) = @_; - my $key = C4::Context->preference('LibrisKey'); - my $base = C4::Context->preference('LibrisURL'); - my $search = $query->{'search'}; - my $response = LWP::UserAgent->new->get( $base . "spell?query={$search}&key=$key" ); - my $xml = XMLin( $response->content, NoAttr => 1, ForceArray => qr/term/ ); - - my @terms; - my $label; - - if ( $xml->{suggestion}->{term} ) { - for ( @{ $xml->{suggestion}->{term} } ) { - push @terms, $_; - } - $label = join( ' ', @terms ); - } else { - return; # No result from LIBRIS - } - - my @results; - push @results, - { - 'search' => $label, #$thissearch, - relevance => 100, - - # FIXME: it'd be nice to have some empirical measure of - # "relevance" in this case, but we don't. - label => $label - }; - return \@results; -} - -1; -__END__ - -=head1 NAME - -Koha::SuggestionEngine::Plugin::LibrisSpellcheck - -=head2 FUNCTIONS - -This module provides facilities for using the LIBRIS spell checker API - -=over - -=item NAME - -my $name = $plugin->NAME; - -=back - -=over - -=item get_suggestions(query) - -Sends in the search query and gets an XML with a suggestion - -my $suggestions = $plugin->get_suggestions(\%query); - -=back - -=cut - -=head1 NOTES - -=cut - -=head1 AUTHOR - -Eivin Giske Skaaren - -=cut diff --git a/installer/data/mysql/atomicupdate/bug_43336.pl b/installer/data/mysql/atomicupdate/bug_43336.pl new file mode 100755 index 0000000000..2db4f7479a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_43336.pl @@ -0,0 +1,66 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); +use JSON qw( to_json from_json ); + +return { + bug_number => "43336", + description => "Clean up sysprefs related to Libris spellcheck", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # LibrisKey + my $deleted_key = $dbh->do(q{DELETE FROM systempreferences WHERE variable='LibrisKey'}); + if ( $deleted_key && $deleted_key > 0 ) { + say_success( $out, "Removed system preference 'LibrisKey'" ); + } else { + say_warning( $out, "'LibrisKey' syspref already removed" ); + } + + # LibrisURL + my $deleted_url = $dbh->do(q{DELETE FROM systempreferences WHERE variable='LibrisURL'}); + if ( $deleted_url && $deleted_url > 0 ) { + say_success( $out, "Removed system preference 'LibrisURL'" ); + } else { + say_warning( $out, "'LibrisURL' syspref already removed" ); + } + + # OPACdidyoumean + use Data::Dumper; + my $clean_data; + my $found_unwanted_setting = 0; + + # Get the current value of OPACdidyoumean + my ($result) = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'OPACdidyoumean'"); + if ($result) { + my $json_data = from_json($result); + + # Loop over all the elements in the syspref + foreach my $element ( @{$json_data} ) { + if ( $element->{'name'} && $element->{'name'} ne 'LibrisSpellcheck' ) { + + # Save the elements we are not interested in so we can save it back to the DB + push @{$clean_data}, $element; + } else { + + # Do not save the setting for LibrisSpellcheck + $found_unwanted_setting = 1; + } + } + if ( $found_unwanted_setting == 0 ) { + + # We did not find a setting for LibrisSpellcheck, so we can leave the OPACdidyoumean as it was + say_warning( $out, "'OPACdidyoumean' syspref does not contain a setting for 'LibrisSpellcheck'" ); + } else { + + # Update OPACdidyoumean, but without the setting for LibrisSpellcheck + my $new_json_data = to_json($clean_data); + $dbh->do("UPDATE systempreferences SET value = '$new_json_data' WHERE variable='OPACdidyoumean'"); + say_success( $out, "'LibrisSpellcheck' was removed from the OPACdidyoumean syspref" ); + } + } else { + say_warning( $out, "'OPACdidyoumean' is not set" ); + } + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 4bdc353f6a..05c07c7e91 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -408,8 +408,6 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('LibraryThingForLibrariesEnabled','0'), ('LibraryThingForLibrariesID',''), ('LibraryThingForLibrariesTabbedView','0'), -('LibrisKey', ''), -('LibrisURL', 'http://api.libris.kb.se/bibspell/'), ('LimitReportsByLibrary','0'), ('LinkerConsiderDiacritics', '0'), ('LinkerConsiderThesaurus','0'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt index cd8fa9359b..b30238d39f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt @@ -21,8 +21,6 @@ Suggest authorities which are relevant to the term the user searched for. [% CASE 'ExplodedTerms' %] Suggest that patrons expand their searches to include broader/narrower/related terms. - [% CASE 'LibrisSpellcheck' %] - Use the LIBRIS spellcheck API. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index a70a9c7cfe..93fd84f361 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -398,15 +398,3 @@ Searching: 1: Redirect 0: "Don't redirect" - to the result if a catalog search via the OPAC or staff interface returns only one record. - - Did you mean/spell checking: - - - - "Swedish service for spellchecking.
" - - LIBRIS spellchecking API key - - pref: LibrisKey - - . Can be obtained from LIBRIS. - - - - LIBRIS base URL - - pref: LibrisURL - class: url - - "Please only change this if you are sure it needs changing."