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

(-)a/installer/data/mysql/atomicupdate/bug_13287_AddPurgeSuggestionsOlderThan_SystemPreference.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('PurgeSuggestionsOlderThan', '', NULL, 'If this script is called without the days parameter', 'Integer');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 569-575 OPAC: Link Here
569
            - expired patrons from OPAC actions such as placing a hold or renewing.  Note that the setting for a patron category takes priority over this system preference.
569
            - expired patrons from OPAC actions such as placing a hold or renewing.  Note that the setting for a patron category takes priority over this system preference.
570
570
571
        -
571
        -
572
            - Keep accepted or rejected purchase suggestions for a period of [   ] days.
572
            - Keep accepted or rejected purchase suggestions for a period of
573
            - pref: PurgeSuggestionsOlderThan
573
            - pref: PurgeSuggestionsOlderThan
574
              class: integer
574
              class: integer
575
            - days.
575
            - days.
(-)a/misc/cronjobs/purge_suggestions.pl (-19 / +16 lines)
Lines 17-24 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
21
use English qw( -no_match_vars );
22
use utf8;
22
use utf8;
23
23
24
BEGIN {
24
BEGIN {
Lines 35-45 use C4::Suggestions; Link Here
35
use C4::Log;
35
use C4::Log;
36
use C4::Context;
36
use C4::Context;
37
37
38
my ($help, $days);
38
my ( $help, $days );
39
39
40
GetOptions(
40
GetOptions(
41
    'help|?'         => \$help,
41
    'help|?' => \$help,
42
    'days=s'         => \$days,
42
    'days=s' => \$days,
43
);
43
);
44
44
45
my $usage = << 'ENDUSAGE';
45
my $usage = << 'ENDUSAGE';
Lines 49-82 Parameters: Link Here
49
-days TTT to define the age of suggestions to delete
49
-days TTT to define the age of suggestions to delete
50
50
51
Example:
51
Example:
52
$PERL5LIB/misc/cronjobs/purge_suggestions.pl -days 30
53
ENDUSAGE
52
ENDUSAGE
53
$usage .= $PROGRAM_NAME . " -days 30\n";
54
54
55
# If this script is called without the 'days' parameter, we use the system preferences value instead.
55
# If this script is called without the 'days' parameter, we use the system preferences value instead.
56
if ( ! defined($days) and not $help) {
56
if ( !defined($days) && !$help ) {
57
    my $purge_sugg_days = C4::Context->preference('PurgeSuggestionsOlderThan') || '';
57
    my $purge_sugg_days =
58
    if($purge_sugg_days ne '' and $purge_sugg_days >= 0) {
58
      C4::Context->preference('PurgeSuggestionsOlderThan') || q{};
59
    if ( $purge_sugg_days ne q{} and $purge_sugg_days >= 0 ) {
59
        $days = $purge_sugg_days;
60
        $days = $purge_sugg_days;
60
    }
61
    }
61
}
62
}
63
62
# If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything.
64
# If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything.
63
if ($help) {
65
if ($help) {
64
    print $usage;
66
    print $usage;
65
    exit;
67
    exit;
66
}
68
}
67
69
68
if(defined($days) && $days > 0 && $days ne ''){
70
if ( defined($days) && $days ne q{} && $days > 0 ) {
69
    cronlogaction();
71
    cronlogaction();
70
    DelSuggestionsOlderThan($days);
72
    DelSuggestionsOlderThan($days);
71
}
73
}
72
74
73
elsif(defined($days) && $days == 0) {
75
elsif ( defined($days) && $days == 0 ) {
74
    print << 'ERROR';
76
    warn "This script is not executed with 0 days. Aborted.\n";
75
    This script is not executed with 0 days. Aborted.
76
ERROR
77
}
77
}
78
else {
78
else {
79
    print << 'ERROR';
79
    warn "This script requires a positive number of days. Aborted.\n";
80
    This script requires a positive number of days. Aborted.
80
}
81
ERROR
82
}
83
- 

Return to bug 13287