Koha/opac/opac-idref.pl
Jonathan Druart c4eabeda0b Bug 16447: Remove occurrence of the borrow permission which does no longer exist
Bug 7976 has removed this permission, but other patches re-added it...
Note that the occurrences in sendbasket.pl, edithelp.pl, opac/svc/login should
have been removed by bug 7976.

Test plan:
  git grep 'borrow.*=> 1'
should not return any results.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Brendan Gallagher <bredan@bywatersolutions.com>
2016-05-05 21:28:14 +00:00

101 lines
2.7 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright (C) 2014 BibLibre
#
# 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 <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
use Encode;
use C4::Auth;
use C4::Context;
use C4::Search;
use C4::Output;
my $cgi = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-idref.tt",
query => $cgi,
type => "opac",
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
}
);
my $ua = LWP::UserAgent->new;
my $base = 'http://www.idref.fr/services/biblio/';
my $unimarc3 = $cgi->param('unimarc3');
my $request = HTTP::Request->new(
'GET',
$base . $unimarc3 . ".json",
);
$request->protocol('HTTP/1.1');
my $response = $ua->request($request);
if ( not $response->is_success) {
$template->param(error => $base.$unimarc3.'.json');
output_html_with_http_headers $cgi, $cookie, $template->output;
exit;
}
my $content = Encode::decode("utf8", $response->content);
my $json = from_json( $content );
my $r;
my $role_name;
my @unimarc3;
my @results = ref $json->{sudoc}{result} eq "ARRAY"
? @{ $json->{sudoc}{result} }
: ($json->{sudoc}{result});
for my $role_node ( @results ) {
while ( my ( $k, $v ) = each %$role_node ) {
next unless $k eq "role";
my $role_name;
my $count = 0;
my $role_data = {};
my @nodes = ref $v eq "ARRAY"
? @$v
: ($v);
for my $node ( @nodes ) {
while ( ( $k, $v ) = each %$node ) {
if ( $k eq 'roleName' ) {
$role_name = $v;
$role_data->{role_name} = $role_name;
}
elsif ( $k eq 'count' ) {
$role_data->{count} = $v;
}
elsif ( $k eq 'doc' ) {
push @{ $role_data->{docs} }, $v;
}
}
}
push @$r, $role_data;
}
}
$template->param(
content => $r,
unimarc3 => $unimarc3,
);
output_html_with_http_headers $cgi, $cookie, $template->output;