Lines 23-42
use C4::Context;
Link Here
|
23 |
use C4::Auth qw(checkauth); |
23 |
use C4::Auth qw(checkauth); |
24 |
use Koha::Linktracker; |
24 |
use Koha::Linktracker; |
25 |
use CGI qw ( -utf8 ); |
25 |
use CGI qw ( -utf8 ); |
|
|
26 |
use C4::Biblio; |
26 |
|
27 |
|
27 |
my $cgi = new CGI; |
28 |
my $cgi = new CGI; |
28 |
my $uri = $cgi->param('uri') || ''; |
29 |
my $uri = $cgi->param('uri') || ''; |
29 |
|
30 |
|
|
|
31 |
my $biblionumber = $cgi->param('biblionumber') || undef ; |
32 |
my $record = GetMarcBiblio({ |
33 |
biblionumber => $biblionumber, |
34 |
}) || undef ; |
35 |
|
36 |
|
30 |
my $tracker = Koha::Linktracker->new( |
37 |
my $tracker = Koha::Linktracker->new( |
31 |
{ trackingmethod => C4::Context->preference('TrackClicks') } ); |
38 |
{ trackingmethod => C4::Context->preference('TrackClicks') } ); |
32 |
|
39 |
|
33 |
if ($uri) { |
40 |
# we want to make sure we have a url and biblio to go with it |
34 |
if ( $tracker->trackingmethod() eq 'track' |
41 |
if ( ($uri && $record) && ( $tracker->trackingmethod() eq 'track' |
35 |
|| $tracker->trackingmethod() eq 'anonymous' ) |
42 |
|| $tracker->trackingmethod() eq 'anonymous' ) ) |
36 |
{ |
43 |
{ |
37 |
my $borrowernumber = 0; |
44 |
my $borrowernumber = 0; |
38 |
|
45 |
|
39 |
# we have a uri and we want to track |
46 |
# we want to track |
40 |
if ( $tracker->trackingmethod() eq 'track' ) { |
47 |
if ( $tracker->trackingmethod() eq 'track' ) { |
41 |
my ( $user, $cookie, $sessionID, $flags ) = |
48 |
my ( $user, $cookie, $sessionID, $flags ) = |
42 |
checkauth( $cgi, 1, {}, 'opac' ); |
49 |
checkauth( $cgi, 1, {}, 'opac' ); |
Lines 63-76
if ($uri) {
Link Here
|
63 |
} |
70 |
} |
64 |
); |
71 |
); |
65 |
print $cgi->redirect($uri); |
72 |
print $cgi->redirect($uri); |
66 |
} |
73 |
} else { |
67 |
else { |
|
|
68 |
|
69 |
# We have a valid url, but we shouldn't track it, just redirect |
70 |
print $cgi->redirect($uri); |
71 |
} |
72 |
} |
73 |
else { |
74 |
|
74 |
|
75 |
# we shouldn't be here, bail out |
75 |
# we shouldn't be here, bail out |
76 |
print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
76 |
print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
77 |
- |
|
|