|
Lines 6-12
Link Here
|
| 6 |
# |
6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it under the |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 8 |
# terms of the GNU General Public License as published by the Free Software |
8 |
# terms of the GNU General Public License as published by the Free Software |
| 9 |
# Foundation; either version 2 of the License, or (at your option) any later |
9 |
# Foundation; either version 3 of the License, or (at your option) any later |
| 10 |
# version. |
10 |
# version. |
| 11 |
# |
11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
|
Lines 17-24
Link Here
|
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
19 |
|
| 20 |
use strict; |
20 |
use Modern::Perl; |
| 21 |
use warnings; |
|
|
| 22 |
use CGI; |
21 |
use CGI; |
| 23 |
use CGI::Cookie; |
22 |
use CGI::Cookie; |
| 24 |
use JSON; |
23 |
use JSON; |
|
Lines 26-40
use C4::Auth;
Link Here
|
| 26 |
use C4::Biblio; |
25 |
use C4::Biblio; |
| 27 |
use C4::Context; |
26 |
use C4::Context; |
| 28 |
|
27 |
|
| 29 |
my $input = new CGI; |
28 |
my $input = new CGI; |
| 30 |
print $input->header('application/json'); |
29 |
print $input->header('application/json'); |
| 31 |
|
30 |
|
| 32 |
# Check the user's permissions |
31 |
# Check the user's permissions |
| 33 |
my %cookies = fetch CGI::Cookie; |
32 |
my %cookies = fetch CGI::Cookie; |
| 34 |
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID'); |
33 |
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID'); |
| 35 |
my ($auth_status, $auth_sessid) = C4::Auth::check_cookie_auth($sessid, {catalogue => 1}); |
34 |
my ( $auth_status, $auth_sessid ) = |
| 36 |
if ($auth_status ne "ok") { |
35 |
C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1 } ); |
| 37 |
print to_json({status => 'UNAUTHORIZED'}); |
36 |
if ( $auth_status ne "ok" ) { |
|
|
37 |
print to_json( { status => 'UNAUTHORIZED' } ); |
| 38 |
exit 0; |
38 |
exit 0; |
| 39 |
} |
39 |
} |
| 40 |
|
40 |
|
|
Lines 47-56
if ($auth_status ne "ok") {
Link Here
|
| 47 |
|
47 |
|
| 48 |
my $json; |
48 |
my $json; |
| 49 |
|
49 |
|
| 50 |
my $record = TransformHtmlToMarc( $input ); |
50 |
my $record = TransformHtmlToMarc($input); |
| 51 |
|
51 |
|
| 52 |
|
52 |
my $linker_module = |
| 53 |
my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); |
53 |
"C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); |
| 54 |
eval { eval "require $linker_module"; }; |
54 |
eval { eval "require $linker_module"; }; |
| 55 |
if ($@) { |
55 |
if ($@) { |
| 56 |
$linker_module = 'C4::Linker::Default'; |
56 |
$linker_module = 'C4::Linker::Default'; |
|
Lines 59-67
if ($@) {
Link Here
|
| 59 |
if ($@) { |
59 |
if ($@) { |
| 60 |
return 0, 0; |
60 |
return 0, 0; |
| 61 |
} |
61 |
} |
| 62 |
my $linker = $linker_module->new( { 'options' => C4::Context->preference("LinkerOptions") } ); |
62 |
my $linker = $linker_module->new( |
|
|
63 |
{ 'options' => C4::Context->preference("LinkerOptions") } ); |
| 63 |
|
64 |
|
| 64 |
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $record, $input->param('frameworkcode'), C4::Context->preference("CatalogModuleRelink") || '', 1 ); |
65 |
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities( |
|
|
66 |
$linker, $record, |
| 67 |
$input->param('frameworkcode'), |
| 68 |
C4::Context->preference("CatalogModuleRelink") || '', 1 |
| 69 |
); |
| 65 |
|
70 |
|
| 66 |
$json->{status} = 'OK'; |
71 |
$json->{status} = 'OK'; |
| 67 |
$json->{links} = $results->{details} || ''; |
72 |
$json->{links} = $results->{details} || ''; |