Fix for Bug 2682 ("Approving Multiple Tags - Doesn't Work"). Processing based on...
[koha_gimpoz] / tags / review.pl
index f6e9501..c687034 100755 (executable)
@@ -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";
@@ -91,20 +93,22 @@ $op   = $input->param('op') || 'none';
 @tags = $input->param('tags');
 
 $borrowernumber == 0 and push @errors, {op_zero=>1};
-     if ($op eq 'approve') {
+     if (lc($op) eq 'approve') {
        foreach (@tags) {
                whitelist($borrowernumber,$_) or push @errors, {failed_ok=>$_};
        }
-} elsif ($op eq 'reject' ) {
+} elsif (lc($op) eq 'reject' ) {
        foreach (@tags) {
                blacklist($borrowernumber,$_) or push @errors, {failed_rej=>$_};
        }
-} elsif ($op eq 'test'   ) {
+} elsif (lc($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,
        );
 }
 
@@ -201,7 +205,7 @@ $debug and print STDERR "number of approval_rows: " . scalar(@$tagloop) . "rows\
 $template->param(
        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
        offset => $offset,      # req'd for EXPR
-       op => $op,
+       op => lc($op),
        op_count => scalar(@tags),
        script_name => $script_name,
        approved => 0,          # dummy value (also EXPR)