From 0f308f2a5f16023641ee51bcad8987a26c7ee063 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 937e1741128..c0ff1e66cf0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc @@ -66,6 +66,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 00000000000..896885c6ad2 --- /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 5b74b30dae7..759ee0c68bf 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -57,6 +57,27 @@ if ( !$output_directory || !-d $output_directory || !-w $output_directory ) { } ); } +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