@@ -, +, @@ parameter for proxying --- opac/tracklinks.pl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/opac/tracklinks.pl +++ a/opac/tracklinks.pl @@ -23,20 +23,27 @@ use C4::Context; use C4::Auth qw(checkauth); use Koha::Linktracker; use CGI qw ( -utf8 ); +use C4::Biblio; my $cgi = new CGI; my $uri = $cgi->param('uri') || ''; +my $biblionumber = $cgi->param('biblionumber') || undef ; +my $record = GetMarcBiblio({ + biblionumber => $biblionumber, +}) || undef ; + + my $tracker = Koha::Linktracker->new( { trackingmethod => C4::Context->preference('TrackClicks') } ); -if ($uri) { - if ( $tracker->trackingmethod() eq 'track' - || $tracker->trackingmethod() eq 'anonymous' ) - { +# we want to make sure we have a url and biblio to go with it +if ( ($uri && $record) && ( $tracker->trackingmethod() eq 'track' + || $tracker->trackingmethod() eq 'anonymous' ) ) +{ my $borrowernumber = 0; - # we have a uri and we want to track + # we want to track if ( $tracker->trackingmethod() eq 'track' ) { my ( $user, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' ); @@ -63,14 +70,7 @@ if ($uri) { } ); print $cgi->redirect($uri); - } - else { - - # We have a valid url, but we shouldn't track it, just redirect - print $cgi->redirect($uri); - } -} -else { +} else { # we shouldn't be here, bail out print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early --