X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Ftracklinks.pl;h=b5743fe69949e1c022de424c57f594973621b10c;hb=0eb7bf0caf286e4503f94de869b64f48cc020a24;hp=d64b00bd526243f2fe282e138b61d2eef3aab22c;hpb=e20270fec4f6d34f01050bea4c5765d5b3c4ed33;p=srvgit diff --git a/opac/tracklinks.pl b/opac/tracklinks.pl index d64b00bd52..b5743fe699 100755 --- a/opac/tracklinks.pl +++ b/opac/tracklinks.pl @@ -5,22 +5,23 @@ # Copyright 2012 Catalyst IT # 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 2 of the License, or (at your option) any later -# version. +# 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. +# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; use C4::Context; use C4::Auth qw(checkauth); +use C4::Biblio; use Koha::Linktracker; use CGI qw ( -utf8 ); @@ -54,25 +55,28 @@ if ($uri) { my $biblionumber = $cgi->param('biblionumber') || 0; my $itemnumber = $cgi->param('itemnumber') || 0; - $tracker->trackclick( - { - uri => $uri, - biblionumber => $biblionumber, - borrowernumber => $borrowernumber, - itemnumber => $itemnumber - } - ); - print $cgi->redirect($uri); + my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); + my $marc_urls = C4::Biblio::GetMarcUrls($record, C4::Context->preference('marcflavour')); + if ( grep { $_ eq $uri } map { $_->{MARCURL} } @$marc_urls ) { + $tracker->trackclick( + { + uri => $uri, + biblionumber => $biblionumber, + borrowernumber => $borrowernumber, + itemnumber => $itemnumber + } + ); + print $cgi->redirect($uri); + exit; + } } else { # We have a valid url, but we shouldn't track it, just redirect print $cgi->redirect($uri); + exit; } } -else { - # we shouldn't be here, bail out - print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early - exit; -} +print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early +exit;