Bugzilla – Attachment 42613 Details for
Bug 6810
Send membership expiry reminder notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6810: [QA Follow-up] Some minor tidying up of cron script
Bug-6810-QA-Follow-up-Some-minor-tidying-up-of-cro.patch (text/plain), 8.38 KB, created by
Marcel de Rooy
on 2015-09-16 14:56:37 UTC
(
hide
)
Description:
Bug 6810: [QA Follow-up] Some minor tidying up of cron script
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-09-16 14:56:37 UTC
Size:
8.38 KB
patch
obsolete
>From d1273ba88bc1cc5f5a427882e54d93e23b3bd17b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 16 Sep 2015 16:26:14 +0200 >Subject: [PATCH] Bug 6810: [QA Follow-up] Some minor tidying up of cron > script >Content-Type: text/plain; charset=utf-8 > >Moved some POD lines and removed some duplicated POD lines. >Corrected some indentation. >Did some minor spelling changes, rewording. >Removed the C4::Dates module. No longer needed. >Removed a label in front of the for statement. >Removed the Do you wish to continue-code. Should not be in a cron job. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > misc/cronjobs/membership_expiry.pl | 165 +++++++++++++----------------------- > 1 file changed, 61 insertions(+), 104 deletions(-) > >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index a846db1..4a0f98b 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -19,7 +19,7 @@ > > =head1 NAME > >-membership_expiry.pl - cron script to put membership expiry reminder into message queues >+membership_expiry.pl - cron script to put membership expiry reminders into the message queue > > =head1 SYNOPSIS > >@@ -35,34 +35,6 @@ This script sends membership expiry reminder notices to patrons. > It queues them in the message queue, which is processed by > the process_message_queue.pl cronjob. > >-=cut >- >- >-use Modern::Perl; >-use Getopt::Long; >-use Pod::Usage; >-use Data::Dumper; >-BEGIN { >- # find Koha's Perl modules >- # test carefully before changing this >- use FindBin; >- eval { require "$FindBin::Bin/../kohalib.pl" }; >-} >- >-use C4::Context; >-use C4::Letters; >-use C4::Dates qw/format_date/; >-use C4::Log; >- >- >-=head1 NAME >- >-membership_expiry.pl - prepare messages to be sent to membership expiry reminder notices to patrons. >- >-=head1 SYNOPSIS >- >-membership_expiry.pl [-c] >- > =head1 OPTIONS > > =over 8 >@@ -91,19 +63,11 @@ statement otherwise. > > =back > >-=head1 DESCRIPTION >- >-This script is designed to alert send membership expire notices >- >-=head2 Configuration >- >-This script pays attention to send the membership expire notices >-The content of the messages is configured in Tools -> Notices and slips. Use the MEMBERSHIP_EXPIRY template >+=head1 CONFIGURATION > >-=head2 Outgoing emails >- >-Typically, messages are prepared for each patron when the memberships are going to expire >+The content of the messages is configured in Tools -> Notices and slips. Use the MEMBERSHIP_EXPIRY notice. > >+Typically, messages are prepared for each patron when the memberships are going to expire. > > These emails are staged in the outgoing message queue, as are messages > produced by other features of Koha. This message queue must be >@@ -114,11 +78,9 @@ In the event that the C<-n> flag is passed to this program, no emails > are sent. Instead, messages are sent on standard output from this > program. > >-=head2 Templates >- >-Templates can contain variables enclosed in double angle brackets like >+Notices can contain variables enclosed in double angle brackets like > E<lt>E<lt>thisE<gt>E<gt>. Those variables will be replaced with values >-specific to the members there membership expiry date is coming. >+specific to the soon expiring members. > Available variables are: > > =over >@@ -133,84 +95,80 @@ any field from the branches table > > =back > >-=head1 SEE ALSO >- >-The F<misc/cronjobs/membership_expiry.pl> program allows you to send >-messages to patrons when the membership are going to expires. > =cut > >-# These are defaults for command line options. >+use Modern::Perl; >+use Getopt::Long; >+use Pod::Usage; >+use Data::Dumper; >+BEGIN { >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/../kohalib.pl" }; >+} > >+use C4::Context; >+use C4::Letters; >+use C4::Log; >+ >+# These are defaults for command line options. > my $confirm; # -c: Confirm that the user has read and configured this script. > my $nomail; # -n: No mail. Will not send any emails. > my $verbose= 0; # -v: verbose >- > my $help = 0; > my $man = 0; > > GetOptions( >- 'help|?' => \$help, >- 'man' => \$man, >- 'c' => \$confirm, >- 'n' => \$nomail, >- 'v' => \$verbose, >- ) or pod2usage(2); >-pod2usage(1) if $help; >-pod2usage( -verbose => 2 ) if $man;; >- >-my $usage = << 'ENDUSAGE'; >-This script prepares for membership expiry reminders to be sent to >-patrons. It queues them in the message queue, which is processed by >-the process_message_queue.pl cronjob. >-See the comments in the script for directions on changing the script. >-This script has the following parameters : >- -c Confirm and remove this help & warning >- -n send No mail. Instead, all mail messages are printed on screen. Useful for testing purposes. >- -v verbose >-ENDUSAGE >- >-unless ($confirm) { >- print $usage; >- print "Do you wish to continue? (y/n)"; >- chomp($_ = <STDIN>); >- exit unless (/^y/i); >-} >+ 'help|?' => \$help, >+ 'man' => \$man, >+ 'c' => \$confirm, >+ 'n' => \$nomail, >+ 'v' => \$verbose, >+) or pod2usage(2); >+ >+pod2usage( -verbose => 2 ) if $man; >+pod2usage(1) if $help || !$confirm; > > cronlogaction(); > > my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); > warn 'getting upcoming membership expires' if $verbose; > my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires(); >-warn 'found ' . scalar( @$upcoming_mem_expires ) . ' issues' if $verbose; >+warn 'found ' . scalar( @$upcoming_mem_expires ) . ' soon expiring members' >+ if $verbose; > >- >-UPCOMINGMEMEXP: foreach my $recent ( @$upcoming_mem_expires ) { >+# main loop >+foreach my $recent ( @$upcoming_mem_expires ) { > my $from_address = $recent->{'branchemail'} || $admin_adress; > my $letter_type = 'MEMBERSHIP_EXPIRY'; >- my $letter = C4::Letters::getletter( 'members', $letter_type, $recent->{'branchcode'} ); >- die "no letter of type '$letter_type' found. Please see sample_notices.sql" unless $letter; >- >- $letter = parse_letter({ letter => $letter, >- borrowernumber => $recent->{'borrowernumber'}, >- firstname => $recent->{'firstname'}, >- categorycode => $recent->{'categorycode'}, >- branchcode => $recent->{'branchcode'}, >- }); >+ my $letter = C4::Letters::getletter( 'members', $letter_type, >+ $recent->{'branchcode'} ); >+ die "no letter of type '$letter_type' found. Please see sample_notices.sql" >+ unless $letter; >+ >+ $letter = parse_letter({ >+ letter => $letter, >+ borrowernumber => $recent->{'borrowernumber'}, >+ firstname => $recent->{'firstname'}, >+ categorycode => $recent->{'categorycode'}, >+ branchcode => $recent->{'branchcode'}, >+ }); > if ($letter) { > if ($nomail) { > print $letter->{'content'}; > } else { >- C4::Letters::EnqueueLetter( { letter => $letter, >- borrowernumber => $recent->{'borrowernumber'}, >- from_address => $from_address, >- message_transport_type => 'email', >- } ); >- } >- } >+ C4::Letters::EnqueueLetter({ >+ letter => $letter, >+ borrowernumber => $recent->{'borrowernumber'}, >+ from_address => $from_address, >+ message_transport_type => 'email', >+ }); >+ } > } >+} > >- >-=head1 METHODS >+=head1 SUBROUTINES > > =head2 parse_letter > >@@ -222,12 +180,11 @@ sub parse_letter { > return unless exists $params->{$required}; > } > my $letter = C4::Letters::GetPreparedLetter ( >- module => 'members', >- letter_code => 'MEMBERSHIP_EXPIRY', >- tables => {'borrowers', $params->{'borrowernumber'}, 'branches', $params->{'branchcode'}}, >+ module => 'members', >+ letter_code => 'MEMBERSHIP_EXPIRY', >+ tables => { >+ 'borrowers', $params->{'borrowernumber'}, >+ 'branches', $params->{'branchcode'} >+ }, > ); > } >- >-1; >- >-__END__ >-- >1.7.10.4
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 6810
:
5375
|
9751
|
21870
|
21871
|
21872
|
22459
|
32683
|
32684
|
32689
|
32692
|
33954
|
40090
|
40091
|
40100
|
40120
|
40121
|
40122
|
40179
|
40180
|
40641
|
40642
|
40643
|
40644
|
40645
|
40646
|
40649
|
40665
|
40666
|
40667
|
40685
|
40686
|
40687
|
40688
|
40689
|
40690
|
40700
|
40701
|
40766
|
41916
|
42609
|
42610
|
42611
|
42612
| 42613 |
42700