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/acquisitions.pref (+8 lines)
Lines 76-81 Acquisitions: Link Here
76
                yes: Send
76
                yes: Send
77
                no: Don't send
77
                no: Don't send
78
            - blind copy (BCC) to logged in user when sending serial or acquisitions claims notices.
78
            - blind copy (BCC) to logged in user when sending serial or acquisitions claims notices.
79
        -
80
            - Keep accepted or rejected purchase suggestions for a period of
81
            - pref: PurgeSuggestionsOlderThan
82
              class: integer
83
            - days.
84
            - <br>WARNING - Leave this field empty if you don't want to activate this automatic feature.
85
            - "<br>Example: [30] Sets purgation of suggestions for those older than 30 days."
86
            - <br>(Used when the cronjob purge_suggestions.pl is active and called without a specific number of days)
79
87
80
    Printing:
88
    Printing:
81
        -
89
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-8 lines)
Lines 614-627 OPAC: Link Here
614
            - pref: MaxOpenSuggestions
614
            - pref: MaxOpenSuggestions
615
              class: integer
615
              class: integer
616
            - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions"
616
            - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions"
617
        -
618
            - Keep accepted or rejected purchase suggestions for a period of [   ] days.
619
            - pref: PurgeSuggestionsOlderThan
620
              class: integer
621
            - days.
622
            - <br>WARNING - Leave this field empty if you don't want to activate this automatic feature.
623
            - "<br>Example: [30] Sets purgation of suggestions for those older than 30 days."
624
            - <br>(Used when the cronjob purge_suggestions.pl is active and called without a specific number of days)
625
    Privacy:
617
    Privacy:
626
        -
618
        -
627
            - pref: StoreLastBorrower
619
            - pref: StoreLastBorrower
(-)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