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 607-613 OPAC: Link Here
607
              class: integer
607
              class: integer
608
            - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions"
608
            - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions"
609
        -
609
        -
610
            - Keep accepted or rejected purchase suggestions for a period of [   ] days.
610
            - Keep accepted or rejected purchase suggestions for a period of
611
            - pref: PurgeSuggestionsOlderThan
611
            - pref: PurgeSuggestionsOlderThan
612
              class: integer
612
              class: integer
613
            - days.
613
            - days.
(-)a/misc/cronjobs/purge_suggestions.pl (-20 / +18 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;
22
use utf8;
21
use utf8;
23
22
24
BEGIN {
23
BEGIN {
Lines 35-45 use C4::Suggestions; Link Here
35
use C4::Log;
34
use C4::Log;
36
use C4::Context;
35
use C4::Context;
37
36
38
my ($help, $days);
37
my ( $help, $days );
39
38
40
GetOptions(
39
GetOptions(
41
    'help|?'         => \$help,
40
    'help|?' => \$help,
42
    'days=s'         => \$days,
41
    'days=s' => \$days,
43
);
42
);
44
43
45
my $usage = << 'ENDUSAGE';
44
my $usage = << 'ENDUSAGE';
Lines 49-82 Parameters: Link Here
49
-days TTT to define the age of suggestions to delete
48
-days TTT to define the age of suggestions to delete
50
49
51
Example:
50
Example:
52
$PERL5LIB/misc/cronjobs/purge_suggestions.pl -days 30
53
ENDUSAGE
51
ENDUSAGE
52
$usage .= $0 . " -days 30\n";
54
53
55
# If this script is called without the 'days' parameter, we use the system preferences value instead.
54
# If this script is called without the 'days' parameter, we use the system preferences value instead.
56
if ( ! defined($days) and not $help) {
55
if ( !defined($days) && !$help ) {
57
    my $purge_sugg_days = C4::Context->preference('PurgeSuggestionsOlderThan') || '';
56
    my $purge_sugg_days =
58
    if($purge_sugg_days ne '' and $purge_sugg_days >= 0) {
57
      C4::Context->preference('PurgeSuggestionsOlderThan') || q{};
58
    if ( $purge_sugg_days ne q{} and $purge_sugg_days >= 0 ) {
59
        $days = $purge_sugg_days;
59
        $days = $purge_sugg_days;
60
    }
60
    }
61
}
61
}
62
62
# 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 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) {
64
if ($help) {
64
    print $usage;
65
    print $usage;
65
    exit;
66
    exit;
66
}
67
}
67
68
68
if(defined($days) && $days > 0 && $days ne ''){
69
if ( defined($days) && $days ne q{} && $days > 0 ) {
69
    cronlogaction();
70
    cronlogaction();
70
    DelSuggestionsOlderThan($days);
71
    DelSuggestionsOlderThan($days);
71
}
72
}
72
73
elsif (!defined($days)){
73
elsif(defined($days) && $days == 0) {
74
    print $usage;
74
    print << 'ERROR';
75
}
75
    This script is not executed with 0 days. Aborted.
76
elsif ( $days == 0 ) {
76
ERROR
77
    warn "This script is not executed with 0 days. Aborted.\n";
77
}
78
}
78
else {
79
else {
79
    print << 'ERROR';
80
    warn "This script requires a positive number of days. Aborted.\n";
80
    This script requires a positive number of days. Aborted.
81
}
81
ERROR
82
}
83
- 

Return to bug 13287