From 0528d42f711bb091b19ba7880d74b806b8377820 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Nov 2019 15:40:10 +0100 Subject: [PATCH] Bug 23276: Do not display tag if pref TagsEnabled is off If the pref TagsEnabled is off we should not display the tags at the OPAC. There is a message to tell that tags system is disabled, but the tags are displayed. We should redirect to 404 like we do in opac-topissues.pl and opac-suggestions.pl. Test plan: - Turn TagsEnabled on - Add some tags - Turn TagsEnabled off - Hit /cgi-bin/koha/opac-tags.pl => Without this patch you see a warning messaging saying that the tag system is disabled, but the tags are displayed => With this patch you get a 404 redirect Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 6fc316d2eef5945b20a14bec81e2daa57696dd81) Signed-off-by: Lucas Gass (cherry picked from commit 9893fb4ec5a480b7adcbb27f321f7387a4f38f45) Signed-off-by: Aleisha Amohia (cherry picked from commit d0336378897e33bdd31975c2c126a4ce36ac79a9) Signed-off-by: Victor Grousset/tuxayo --- .../bootstrap/en/modules/opac-tags.tt | 4 +- opac/opac-tags.pl | 38 +++++++++---------- 2 files changed, 20 insertions(+), 22 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 08b5528ba0..df73d6f645 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -54,9 +54,7 @@ [% FOREACH ERROR IN ERRORS %]
There was a problem with this operation: - [% IF ( ERROR.tagsdisabled ) %] - Sorry, tags are not enabled on this system. - [% ELSIF ( ERROR.badparam ) %] + [% IF ( ERROR.badparam ) %] ERROR: illegal parameter [% ERROR.badparam | html %] [% ELSIF ( ERROR.login ) %] ERROR: You must log in to complete that action. diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index d9c5add813..c5a466a927 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -38,7 +38,7 @@ use CGI::Cookie; # need to check cookies before having CGI parse the POST reques use C4::Auth qw(:DEFAULT check_cookie_auth); use C4::Context; use C4::Debug; -use C4::Output qw(:html :ajax pagination_bar); +use C4::Output qw(:html :ajax ); use C4::Scrubber; use C4::Biblio; use C4::Items qw(GetItemsInfo GetHiddenItemnumbers); @@ -86,24 +86,19 @@ sub ajax_auth_cgi { # returns CGI object my $is_ajax = is_ajax(); my $openadds = C4::Context->preference('TagsModeration') ? 0 : 1; my $query = ($is_ajax) ? &ajax_auth_cgi({}) : CGI->new(); -unless (C4::Context->preference('TagsEnabled')) { - push @errors, {+ tagsdisabled=>1 }; - push @globalErrorIndexes, $#errors; -} else { - foreach ($query->param) { - if (/^newtag(.*)/) { - my $biblionumber = $1; - unless ($biblionumber =~ /^\d+$/) { - $debug and warn "$_ references non numerical biblionumber '$biblionumber'"; - push @errors, {+'badparam' => $_ }; - push @globalErrorIndexes, $#errors; - next; - } - $newtags{$biblionumber} = $query->param($_); - } elsif (/^del(\d+)$/) { - push @deltags, $1; - } - } +foreach ($query->param) { + if (/^newtag(.*)/) { + my $biblionumber = $1; + unless ($biblionumber =~ /^\d+$/) { + $debug and warn "$_ references non numerical biblionumber '$biblionumber'"; + push @errors, {+'badparam' => $_ }; + push @globalErrorIndexes, $#errors; + next; + } + $newtags{$biblionumber} = $query->param($_); + } elsif (/^del(\d+)$/) { + push @deltags, $1; + } } my $add_op = (scalar(keys %newtags) + scalar(@deltags)) ? 1 : 0; @@ -121,6 +116,11 @@ if ($is_ajax) { }); } +unless ( C4::Context->preference('TagsEnabled') ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + if ($add_op) { unless ($loggedinuser) { push @errors, {+'login' => 1 }; -- 2.39.5