Bugzilla – Attachment 44312 Details for
Bug 13287
Add a system preference to define the number of days used in purge_suggestions.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug13287 - Add a system preference to define the number of days used in purge_suggestions.pl
Bug13287---Add-a-system-preference-to-define-the-n.patch (text/plain), 5.33 KB, created by
Liz Rea
on 2015-11-03 01:05:21 UTC
(
hide
)
Description:
Bug13287 - Add a system preference to define the number of days used in purge_suggestions.pl
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2015-11-03 01:05:21 UTC
Size:
5.33 KB
patch
obsolete
>From e59d40d2ede016557457c321e6a58728d74d1408 Mon Sep 17 00:00:00 2001 >From: remi <remi.mayrand-provencher@inLibro.com> >Date: Tue, 28 Jul 2015 12:10:59 -0400 >Subject: [PATCH] Bug13287 - Add a system preference to define the number of > days used in purge_suggestions.pl > > The system preferences value is used whenever purge_suggestions.pl is called without the 'days' parameter. > This patch uses the preference description suggested by comment #9. > This version should now be cleanly applicable. > > I Apply the patch > II Run updatedatabase.pl > > a) Run purge_suggestions.pl without the days parameter > - validate that there is an error message > b) Run purge_suggestions.pl with the days parameter > - validate that there is no error message > c) Insert a number of days in the system variable PurgeSuggestionsOlderThan > d) Run purge_suggestions.pl without the days parameter > - validate that there is no error message > >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >Tested per plan, all tests pass. >--- > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 9 +++++ > misc/cronjobs/purge_suggestions.pl | 44 ++++++++++++++++------ > 3 files changed, 42 insertions(+), 12 deletions(-) > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index cb77b7d..50e0423 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -357,6 +357,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), > ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), > ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), >+('PurgeSuggestionsOlderThan', '', NULL, 'If this script is called without the days parameter', 'Integer'), > ('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'), > ('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'), > ('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 17d0b1a..84f6a8d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -561,6 +561,15 @@ OPAC: > no: "Don't block" > - 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. > >+ - >+ - Keep accepted or rejected purchase suggestions for a period of [ ] days. >+ - pref: PurgeSuggestionsOlderThan >+ class: integer >+ - days. >+ - <br>WARNING - Leave this field empty if you don't want to activate this automatic feature. >+ - "<br>Example: [30] Sets purgation of suggestions for those older than 30 days." >+ - <br>(Used when the cronjob purge_suggestions.pl is active and called without a specific number of days) >+ > Privacy: > - > - pref: AnonSuggestions >diff --git a/misc/cronjobs/purge_suggestions.pl b/misc/cronjobs/purge_suggestions.pl >index ee3da2e..2b69170 100755 >--- a/misc/cronjobs/purge_suggestions.pl >+++ b/misc/cronjobs/purge_suggestions.pl >@@ -33,6 +33,7 @@ use Getopt::Long; > use Pod::Usage; > use C4::Suggestions; > use C4::Log; >+use C4::Context; > > my ($help, $days); > >@@ -41,22 +42,41 @@ GetOptions( > 'days=s' => \$days, > ); > >-if($help or not $days){ >- print <<EOF >- This script delete olds suggestions >- Parameters : >- -help|? This message >- -days TTT to define the age of suggestions to delete >- >- example : >- export PERL5LIB=/path/to/koha;export KOHA_CONF=/etc/koha/koha-conf.xml;./purge_suggestions.pl -days 30 >-EOF >-; >+my $usage = << 'ENDUSAGE'; >+This script delete old suggestions >+Parameters: >+-help|? This message >+-days TTT to define the age of suggestions to delete >+ >+Example: >+$PERL5LIB/misc/cronjobs/purge_suggestions.pl -days 30 >+ENDUSAGE >+ >+# If this script is called without the 'days' parameter, we use the system preferences value instead. >+if ( ! defined($days) and not $help) { >+ my $purge_sugg_days = C4::Context->preference('PurgeSuggestionsOlderThan') || ''; >+ if($purge_sugg_days ne '' and $purge_sugg_days >= 0) { >+ $days = $purge_sugg_days; >+ } >+} >+# If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything. >+if ($help) { >+ print $usage; > exit; > } > >-if($days){ >+if(defined($days) && $days > 0 && $days ne ''){ > cronlogaction(); > DelSuggestionsOlderThan($days); > } > >+elsif(defined($days) && $days == 0) { >+ print << 'ERROR'; >+ This script is not executed with 0 days. Aborted. >+ERROR >+} >+else { >+ print << 'ERROR'; >+ This script requires a positive number of days. Aborted. >+ERROR >+} >\ No newline at end of file >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13287
:
33661
|
41219
|
44312
|
48323
|
48324
|
50296
|
50297
|
60569
|
60570
|
68187
|
69142
|
69143
|
72105
|
72106
|
72107
|
72108
|
72109
|
72217