From 797c1d55027e124ca3b54a5c8a4aa9dd828001ac Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 3 Jun 2008 09:27:15 -0500 Subject: [PATCH] Bugfix is_approved() to handle the 3-state nature of approval. That is, a term is either approved, or rejected, or neither. Without an external dictionary, most terms will fall into the latter category. Signed-off-by: Joshua Ferraro --- C4/Tags.pm | 8 ++++---- koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl | 5 +++++ tags/review.pl | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/C4/Tags.pm b/C4/Tags.pm index 11046c467b..cfdebb5aa4 100644 --- a/C4/Tags.pm +++ b/C4/Tags.pm @@ -339,9 +339,9 @@ sub is_approved ($) { $sth->execute($term); unless ($sth->rows) { $ext_dict and return (spellcheck($term) ? 0 : 1); # spellcheck returns empty on OK word - return undef; + return 0; } - return $sth->fetch; + return $sth->fetchrow; } sub get_tag_index ($;$) { @@ -550,11 +550,11 @@ sub add_tag ($$;$$) { # biblionumber,term,[borrowernumber,approvernumber] $sth->execute($borrowernumber,$biblionumber,$term); # then - if (@_) { # if an arg remains, it is the borrowernumber of the approver: tag is pre-approved. Note, whitelist unaffected. + if (scalar @_) { # if arg remains, it is the borrowernumber of the approver: tag is pre-approved. my $approver = shift; add_tag_approval($term,$approver); add_tag_index($term,$biblionumber,$approver); - } elsif (is_approved($term)) { + } elsif (is_approved($term) >= 1) { add_tag_approval($term,1); add_tag_index($term,$biblionumber,1); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl index f33907543e..e5cf7505af 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl @@ -63,6 +63,9 @@ var failure_test = function(tag){ $('#verdict').html(tag + ' is prohibited!'); }; + var indeterminate_test = function(tag){ + $('#verdict').html(tag + ' is neither permitted nor prohibited!'); + }; var success_test_call = function() { $('#test_button').removeAttr("disabled"); @@ -350,6 +353,8 @@ Calendar.setup({ "" is permitted. "" is prohibited. + + "" is neither permitted nor prohibited. diff --git a/tags/review.pl b/tags/review.pl index f6e9501dc4..2c8c88d4b6 100755 --- a/tags/review.pl +++ b/tags/review.pl @@ -62,7 +62,9 @@ if (is_ajax()) { $debug and print STDERR "op: " . Dumper($operator) . "\n"; my ($tag, $js_reply); if ($tag = $input->param('test')) { - $js_reply = ( is_approved( $tag) ? 'success' : 'failure') . "_test('$tag');\n"; + my $check = is_approved($tag); + $js_reply = ( $check >= 1 ? 'success' : + $check <= -1 ? 'failure' : 'indeterminate' ) . "_test('$tag');\n"; } if ($tag = $input->param('ok')) { $js_reply = ( whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('$tag');\n"; @@ -102,9 +104,11 @@ $borrowernumber == 0 and push @errors, {op_zero=>1}; } elsif ($op eq 'test' ) { my $tag = $input->param('test'); push @tags, $tag; + my $check = is_approved($tag); $template->param( test_term => $tag, - (is_approved($tag) ? 'verdict_ok' : 'verdict_rej') => 1, + ( $check >= 1 ? 'verdict_ok' : + $check <= -1 ? 'verdict_rej' : 'verdict_indeterminate' ) => 1, ); } -- 2.39.5