Bug 6379: Remove link from unapproved tags
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 25 Mar 2015 12:44:25 +0000 (13:44 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 5 Oct 2015 15:27:44 +0000 (12:27 -0300)
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 <bgkriegel@gmail.com>
works as described, no errors

For the (approved) link to work I need to install YAML::XS

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt
opac/opac-tags.pl

index 1065c09..295c32d 100644 (file)
                                         <tr>
                                             <td class="tagterm">
                                                 <span class="tdlabel">Tag:</span>
-                                                <a href="/cgi-bin/koha/opac-search.pl?tag=[% MY_TAG.term |url %]&amp;q=[% MY_TAG.term |url %]">
-                                            [% MY_TAG.term |html %]</a></td>
+                                                [% IF MY_TAG.approved == 1 %]
+                                                    <a href="/cgi-bin/koha/opac-search.pl?tag=[% MY_TAG.term |url %]&amp;q=[% MY_TAG.term |url %]">[% MY_TAG.term |html %]</a>
+                                                [% ELSE %]
+                                                    [% MY_TAG.term |html %] (not approved)
+                                                [% END %]
+                                            </td>
+
                                             <td>
                                                 [% IF ( MY_TAG.XSLTBloc ) %]
                                                     [% MY_TAG.XSLTBloc %]
index f41fae7..19994d1 100755 (executable)
@@ -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);