3 # Bouzid Fergani, 2020 - inLibro
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
29 print $input->header('application/json');
31 # Check the user's permissions
32 my %cookies = CGI::Cookie->fetch;
33 my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
34 my ( $auth_status, $auth_sessid ) =
35 C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1, editcatalogue => 1 } );
36 if ( $auth_status ne "ok" ) {
37 print to_json( { status => 'UNAUTHORIZED' } );
41 # Link the biblio headings to authorities and return a json containing the status of all the links.
42 # Example : {"status":"OK","links":[{"authid":"123","status":"LINK_CHANGED","tag":"650"}]}
44 # tag = the tag number of the field
45 # authid = the value of the $9 subfield for this tag
46 # status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED)
50 my $record = TransformHtmlToMarc($input,1);
52 my ( $headings_changed, $results ) = BiblioAutoLink (
54 $input->param('frameworkcode'),
58 $json->{status} = 'OK';
59 $json->{links} = $results->{details} || '';