Bug 28692: Get from storage before log actions
[koha-ffzg.git] / tags / review.pl
index 5e77c28..1810081 100755 (executable)
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
-use Data::Dumper;
-use POSIX;
+use POSIX qw( ceil exit );
 use CGI qw ( -utf8 );
 use CGI::Cookie;     # need to check cookies before having CGI parse the POST request
-use URI::Escape;
-use C4::Auth qw(:DEFAULT check_cookie_auth);
+use URI::Escape qw( uri_escape_utf8 );
+use C4::Auth qw( check_cookie_auth get_template_and_user );
 use C4::Context;
-use Koha::DateUtils;
-# use C4::Koha;
-use C4::Output qw(:html :ajax pagination_bar);
-use C4::Debug;
-use C4::Tags qw(get_tags get_approval_rows approval_counts whitelist blacklist is_approved);
+use Koha::DateUtils qw( dt_from_string output_pref );
+use C4::Output qw( output_with_http_headers is_ajax pagination_bar output_html_with_http_headers );
+use C4::Tags qw(
+    approval_counts
+    blacklist
+    get_approval_rows
+    is_approved
+    whitelist
+);
 
 my $script_name = "/cgi-bin/koha/tags/review.pl";
 my $needed_flags = { tools => 'moderate_tags' };    # FIXME: replace when more specific permission is created.
@@ -41,24 +44,19 @@ sub ajax_auth_cgi { # returns CGI object
     my %cookies = CGI::Cookie->fetch;
     my $input = CGI->new;
     my $sessid = $cookies{'CGISESSID'}->value;
-    my ($auth_status, $auth_sessid) = check_cookie_auth($sessid, $needed_flags);
-    $debug and
-    print STDERR "($auth_status, $auth_sessid) = check_cookie_auth($sessid," . Dumper($needed_flags) . ")\n";
+    my ($auth_status) = check_cookie_auth($sessid, $needed_flags);
     if ($auth_status ne "ok") {
         output_with_http_headers $input, undef,
             "window.alert('Your CGI session cookie ($sessid) is not current.  " .
             "Please refresh the page and try again.');\n", 'js';
         exit 0;
     }
-    $debug and print STDERR "AJAX request: " . Dumper($input),
-        "\n(\$auth_status,\$auth_sessid) = ($auth_status,$auth_sessid)\n";
     return $input;
 }
 
 if (is_ajax()) {
     my $input = &ajax_auth_cgi($needed_flags);
     my $operator = C4::Context->userenv->{'number'};  # must occur AFTER auth
-    $debug and print STDERR "op: " . Dumper($operator) . "\n";
     my ($tag, $js_reply);
     if ($tag = $input->param('test')) {
         my $check = is_approved($tag);
@@ -200,13 +198,11 @@ if ($filter = $input->param('approved_by')) {   # borrowernumber from link
         push @errors, {approved_by=>$filter};
     }
 }
-$debug and print STDERR "filters: " . Dumper(\%filters);
 my $tagloop = get_approval_rows(\%filters);
 my $qstring = $input->query_string;
 $qstring =~ s/([&;])*\blimit=\d+//;         # remove pagination var
 $qstring =~ s/^;+//;                        # remove leading delims
 $qstring = "limit=$pagesize" . ($qstring ? '&amp;' . $qstring : '');
-$debug and print STDERR "number of approval_rows: " . scalar(@$tagloop) . "rows\n";
 (scalar @errors) and $template->param(message_loop=>\@errors);
 $template->param(
     offset => $offset,  # req'd for EXPR