From 6480515f6ab99a6e09a92e10c5b3eba529606536 Mon Sep 17 00:00:00 2001 From: Imani Thomas Date: Fri, 10 Jan 2025 14:18:12 +0000 Subject: [PATCH] Bug 21627: Add option to set emails for send_print_notices cronjob To test: 1. Apply Patch, updatedatabase, restart_all 2. go to misc/cronjobs/gather_print_notices.pl and uncomment line 77 which says `say $_ for @emails;` 3. from the misc/cronjobs folder run `perl gather_print_notices.pl -e dev@null.org -e any@other.email` 1. the emails you entered in the command line should be printed and nothing else 4. Search for the system preference 'SendPrintNoticesEmails' and set its value to a comma separated list of values 5. run gather_print_notices again and you should see the values you entered in the system preference instead of the ones you enter at the command line 6. search for the system preference SendPrintNoticesCombineEmails and set its value to 'in addition to' 7. run gather_print_notices again and you should see a combination of the command line emails and the emails you set in the SendPrintNoticesEmails system preference. 8. recomment line 77 in gather_print_notices.pl --- .../prog/en/includes/prefs-menu.inc | 9 ++++++++ .../en/modules/admin/preferences/cron.pref | 10 +++++++++ misc/cronjobs/gather_print_notices.pl | 21 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cron.pref diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc index 021b8f7bf7..33adb87208 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc @@ -59,6 +59,15 @@ [% END %] + [% IF ( cron ) %] +
  • + Cronjobs + [% PROCESS subtabs %] + [% END %] +
  • + Cronjobs +
  • + [% IF ( enhanced_content ) %]
  • Enhanced content diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cron.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cron.pref new file mode 100644 index 0000000000..d967c0fab2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cron.pref @@ -0,0 +1,10 @@ +Cronjobs: + Gather Print Notices: + - + - Send gathered print notice emails to + - pref: SendPrintNoticesEmails + - pref: SendPrintNoticesCombineEmails + choices: + 0: instead of + 1: in addition to + - any email addresses set in the cron diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index 8cd325e904..f5b265d95a 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -54,6 +54,27 @@ if ( !$output_directory || !-d $output_directory || !-w $output_directory ) { -msg => qq{\nError: You must specify a valid and writeable directory to dump the print notices in.\n}, }); } +my $sys_pref_emails = C4::Context->preference("SendPrintNoticesEmails"); +if($sys_pref_emails) +{ + my @split_pref_emails = split(/,/, $sys_pref_emails); + my $sys_pref_combine = C4::Context->preference("SendPrintNoticesCombineEmails"); + if($sys_pref_combine) + { + @emails = (@emails, @split_pref_emails); + } + else + { + @emails = @split_pref_emails; + } +} +else +{ + cronlogaction({info => "SendPrintNotices system pref ignored because it was null or empty."}); +} + +# uncomment the line below to test the system pref even if you have no files to send +# say $_ for @emails; # Default value is html $html = 1 if not $html and not $csv and not $ods; -- 2.39.5