From 1489bb7342f3e4391b598b80ea368cb03ff325a5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 25 Mar 2015 13:44:25 +0100 Subject: [PATCH] Bug 6379: Remove link from unapproved tags At the OPAC, if the tag is not approved, the tag's link did not return any result. This patch removes the link. Test plan: 1/ Set TagsModeration to 'Require' 2/ Create tags at the OPAC 3/ Approve a couple 4/ Confirm that unapproved tags does not have links. Signed-off-by: Bernardo Gonzalez Kriegel works as described, no errors For the (approved) link to work I need to install YAML::XS Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/modules/opac-tags.tt | 9 +++++-- opac/opac-tags.pl | 26 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt index 1065c0980a..295c32dfce 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -122,8 +122,13 @@ Tag: - - [% MY_TAG.term |html %] + [% IF MY_TAG.approved == 1 %] + [% MY_TAG.term |html %] + [% ELSE %] + [% MY_TAG.term |html %] (not approved) + [% END %] + + [% IF ( MY_TAG.XSLTBloc ) %] [% MY_TAG.XSLTBloc %] diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index f41fae7a4c..19994d1d48 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -226,20 +226,22 @@ my $results = []; my $my_tags = []; if ($loggedinuser) { - $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); - foreach (@$my_tags) { - my $biblio = GetBiblioData($_->{biblionumber}); - my $record = &GetMarcBiblio( $_->{biblionumber} ); - $_->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $_->{biblionumber} ) ); - $_->{title} = $biblio->{title}; - $_->{author} = $biblio->{author}; + $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); + my $my_approved_tags = get_approval_rows({borrowernumber => $loggedinuser, approved => 1}); + foreach my $tag (@$my_tags) { + my $biblio = GetBiblioData($tag->{biblionumber}); + my $record = &GetMarcBiblio( $tag->{biblionumber} ); + $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) ); + $tag->{title} = $biblio->{title}; + $tag->{author} = $biblio->{author}; if (C4::Context->preference("OPACXSLTResultsDisplay")) { - $_->{XSLTBloc} = XSLTParse4Display($_->{biblionumber}, $record, "OPACXSLTResultsDisplay"); + $tag->{XSLTBloc} = XSLTParse4Display($tag->{biblionumber}, $record, "OPACXSLTResultsDisplay"); } - my $date = $_->{date_created} || ''; - $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/; - $_->{time_created_display} = $1; - } + my $date = $tag->{date_created} || ''; + $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/; + $tag->{time_created_display} = $1; + $tag->{approved} = ( grep { $_->{term} eq $tag->{term} and $_->{approved} } @$my_approved_tags ); + } } $template->param(tagsview => 1); -- 2.39.5