Browse Source

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 <jmf@liblime.com>
3.0.x
Joe Atzberger 15 years ago
committed by Joshua Ferraro
parent
commit
797c1d5502
  1. 8
      C4/Tags.pm
  2. 5
      koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tmpl
  3. 8
      tags/review.pl

8
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 {

5
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({
&quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is permitted.
<!-- TMPL_ELSIF NAME="verdict_rej" -->
&quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is prohibited.
<!-- TMPL_ELSIF NAME="verdict_indeterminate" -->
&quot;<!-- TMPL_VAR NAME="test_term" -->&quot; is neither permitted nor prohibited.
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</div>

8
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,
);
}

Loading…
Cancel
Save