Bug 21082: Update OverDrive authentication method
[koha.git] / opac / opac-tags.pl
index 19994d1..267c3c0 100755 (executable)
@@ -30,8 +30,8 @@ C4::Scrubber is used to remove all markup content from the sumitted text.
 
 =cut
 
-use strict;
-use warnings;
+use Modern::Perl;
+
 use CGI qw ( -utf8 );
 use CGI::Cookie; # need to check cookies before having CGI parse the POST request
 
@@ -46,6 +46,8 @@ use C4::XSLT;
 
 use Data::Dumper;
 
+use Koha::Biblios;
+
 my %newtags = ();
 my @deltags = ();
 my %counts  = ();
@@ -57,7 +59,7 @@ my @globalErrorIndexes = ();
 
 sub ajax_auth_cgi {     # returns CGI object
        my $needed_flags = shift;
-       my %cookies = fetch CGI::Cookie;
+    my %cookies = CGI::Cookie->fetch;
        my $input = CGI->new;
     my $sessid = $cookies{'CGISESSID'}->value;
        my ($auth_status, $auth_sessid) = check_cookie_auth($sessid, $needed_flags);
@@ -227,16 +229,25 @@ my $my_tags = [];
 
 if ($loggedinuser) {
     $my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
-    my $my_approved_tags = get_approval_rows({borrowernumber => $loggedinuser, approved => 1});
+    my $my_approved_tags = get_approval_rows({ approved => 1 });
     foreach my $tag (@$my_tags) {
-        my $biblio = GetBiblioData($tag->{biblionumber});
-        my $record = &GetMarcBiblio( $tag->{biblionumber} );
+        my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
+        my $record = &GetMarcBiblio({ biblionumber => $tag->{biblionumber} });
         $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) );
-        $tag->{title} = $biblio->{title};
-        $tag->{author} = $biblio->{author};
-        if (C4::Context->preference("OPACXSLTResultsDisplay")) {
-            $tag->{XSLTBloc} = XSLTParse4Display($tag->{biblionumber}, $record, "OPACXSLTResultsDisplay");
+        $tag->{title} = $biblio->title;
+        $tag->{author} = $biblio->author;
+
+        my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay');
+        my $lang   = $xslfile ? C4::Languages::getlanguage()  : undef;
+        my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
+
+        if ( $xslfile ) {
+            $tag->{XSLTBloc} = XSLTParse4Display(
+                    $tag->{ biblionumber }, $record, "OPACXSLTResultsDisplay",
+                    1, undef, $sysxml, $xslfile, $lang
+            );
         }
+
         my $date = $tag->{date_created} || '';
         $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/;
         $tag->{time_created_display} = $1;