View | Details | Raw Unified | Return to bug 41919
Collapse All | Expand All

(-)a/debian/templates/koha-conf-site.xml.in (+1 lines)
Lines 342-347 __END_SRU_PUBLICSERVER__ Link Here
342
342
343
 <!-- SQL report limits, 0 means the feature is disabled -->
343
 <!-- SQL report limits, 0 means the feature is disabled -->
344
 <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
344
 <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
345
 <total_running_reports_per_user_limit>0</total_running_reports_per_user_limit>
345
346
346
 <!-- Configuration for X-Forwarded-For -->
347
 <!-- Configuration for X-Forwarded-For -->
347
 <!--
348
 <!--
(-)a/etc/koha-conf.xml (+1 lines)
Lines 159-164 Link Here
159
159
160
 <!-- SQL report limits, 0 means the feature is disabled -->
160
 <!-- SQL report limits, 0 means the feature is disabled -->
161
 <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
161
 <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
162
 <total_running_reports_per_user_limit>0</total_running_reports_per_user_limit>
162
163
163
 <!-- Configuration for X-Forwarded-For -->
164
 <!-- Configuration for X-Forwarded-For -->
164
 <!--
165
 <!--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (+2 lines)
Lines 1619-1624 Link Here
1619
                            [% FOREACH error IN errors %]
1619
                            [% FOREACH error IN errors %]
1620
                                [% IF ( error.duplicate_running_report_ids ) %]
1620
                                [% IF ( error.duplicate_running_report_ids ) %]
1621
                                    This report is already running. Please wait for it to finish before running it again.
1621
                                    This report is already running. Please wait for it to finish before running it again.
1622
                                [% ELSIF ( error.total_running_reports_per_user_limit_exceeded ) %]
1623
                                    You have too many reports running at the moment. Please wait for some of them to finish before running this report again.
1622
                                [% ELSIF ( error.sqlerr ) %]
1624
                                [% ELSIF ( error.sqlerr ) %]
1623
                                    This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1625
                                    This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1624
                                    Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1626
                                    Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
(-)a/reports/guided_reports.pl (-6 / +28 lines)
Lines 789-800 if ( $op eq 'run' ) { Link Here
789
    my $template_id     = $input->param('template');
789
    my $template_id     = $input->param('template');
790
    my $want_full_chart = $input->param('want_full_chart') || 0;
790
    my $want_full_chart = $input->param('want_full_chart') || 0;
791
791
792
    # Determine if the user is running this report too many times
792
    my @duplicate_running_report_ids;
793
    my @duplicate_running_report_ids;
793
    my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit');
794
    my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit');
794
    if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) {
795
    if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) {
795
        my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef;
796
        my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef;
796
        @duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } );
797
        @duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } );
797
    }
798
    }
799
    my $duplicate_running_reports_per_user_limit_exceeded =
800
        $duplicate_running_reports_per_user_limit
801
        ? scalar(@duplicate_running_report_ids) >= $duplicate_running_reports_per_user_limit
802
        : 0;
803
804
    # Determine if the user is running too many reports in total
805
    my @total_running_report_ids;
806
    my $total_running_reports_per_user_limit = C4::Context->config('total_running_reports_per_user_limit');
807
    if ( $total_running_reports_per_user_limit && C4::Context->userenv ) {
808
        my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef;
809
        @total_running_report_ids = Koha::Reports->running( { user_id => $user_id } );
810
    }
811
    my $total_running_reports_per_user_limit_exceeded =
812
        $total_running_reports_per_user_limit
813
        ? scalar(@total_running_report_ids) >= $total_running_reports_per_user_limit
814
        : 0;
798
815
799
    # offset algorithm
816
    # offset algorithm
800
    if ( $input->param('page') ) {
817
    if ( $input->param('page') ) {
Lines 980-987 if ( $op eq 'run' ) { Link Here
980
                'id'              => $report_id,
997
                'id'              => $report_id,
981
                'template_id'     => $template_id,
998
                'template_id'     => $template_id,
982
            );
999
            );
983
        } elsif ( $duplicate_running_reports_per_user_limit
1000
        } elsif ( $duplicate_running_reports_per_user_limit_exceeded || $total_running_reports_per_user_limit_exceeded )
984
            && ( scalar @duplicate_running_report_ids >= $duplicate_running_reports_per_user_limit ) )
985
        {
1001
        {
986
            $template->param(
1002
            $template->param(
987
                'sql'          => $sql,
1003
                'sql'          => $sql,
Lines 990-998 if ( $op eq 'run' ) { Link Here
990
                'execute'      => 1,
1006
                'execute'      => 1,
991
                'name'         => $name,
1007
                'name'         => $name,
992
                'notes'        => $notes,
1008
                'notes'        => $notes,
993
                'errors'       => [ { duplicate_running_report_ids => \@duplicate_running_report_ids } ],
1009
                'errors'       => [
994
                'sql_params'   => \@sql_params,
1010
                    $duplicate_running_reports_per_user_limit_exceeded
995
                'param_names'  => \@param_names,
1011
                    ? { duplicate_running_report_ids => \@duplicate_running_report_ids }
1012
                    : (),
1013
                    $total_running_reports_per_user_limit_exceeded
1014
                    ? { total_running_reports_per_user_limit_exceeded => \@total_running_report_ids }
1015
                    : ()
1016
                ],
1017
                'sql_params'  => \@sql_params,
1018
                'param_names' => \@param_names,
996
            );
1019
            );
997
        } else {
1020
        } else {
998
            my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params );
1021
            my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params );
999
- 

Return to bug 41919