@@ -, +, @@ and types --- C4/Letters.pm | 18 ++++++++++++++---- misc/cronjobs/process_message_queue.pl | 12 ++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -1262,8 +1262,10 @@ sub _add_attachments { This function's parameter hash reference takes the following optional named parameters: message_transport_type: method of message sending (e.g. email, sms, etc.) + Can be a single string, or an arrayref of strings borrowernumber : who the message is to be sent letter_code : type of message being sent (e.g. PASSWORD_RESET) + Can be a single string, or an arrayref of strings limit : maximum number of messages to send This function returns an array of matching hash referenced rows from @@ -1293,12 +1295,20 @@ sub _get_unsent_messages { push @query_params, $params->{'borrowernumber'}; } if ( $params->{'letter_code'} ) { - $statement .= ' AND mq.letter_code = ? '; - push @query_params, $params->{'letter_code'}; + my @letter_codes = ref $params->{'letter_code'} eq "ARRAY" ? @{$params->{'letter_code'}} : $params->{'letter_code'}; + if ( @letter_codes ) { + my $q = join( ",", "?" x @letter_codes ); + $statement .= " AND mq.letter_code IN ( $q ) "; + push @query_params, @letter_codes; + } } if ( $params->{'type'} ) { - $statement .= ' AND message_transport_type = ? '; - push @query_params, $params->{'type'}; + my @types = ref $params->{'type'} eq "ARRAY" ? @{$params->{'type'}} : $params->{'type'}; + if ( @types ) { + my $q = join( ",", "?" x @types ); + $statement .= " AND message_transport_type IN ($q) "; + push @query_params, @types; + } } if ( $params->{'limit'} ) { $statement .= ' limit ? '; --- a/misc/cronjobs/process_message_queue.pl +++ a/misc/cronjobs/process_message_queue.pl @@ -37,8 +37,8 @@ my $limit = undef; my $method = 'LOGIN'; my $help = 0; my $verbose = 0; -my $type = q{}; -my $letter_code; +my @type; +my @letter_code; GetOptions( 'u|username:s' => \$username, @@ -47,8 +47,8 @@ GetOptions( 'm|method:s' => \$method, 'h|help|?' => \$help, 'v|verbose' => \$verbose, - 't|type:s' => \$type, - 'c|code:s' => \$letter_code, + 't|type:s' => \@type, + 'c|code:s' => \@letter_code, ); my $usage = << 'ENDUSAGE'; @@ -97,8 +97,8 @@ C4::Letters::SendQueuedMessages( password => $password, method => $method, limit => $limit, - type => $type, - letter_code => $letter_code, + type => \@type, + letter_code => \@letter_code, } ); --