Lines 989-997
sub SendQueuedMessages {
Link Here
|
989 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
989 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
990 |
my $sms_provider = Koha::SMS::Providers->find( $member->{'sms_provider_id'} ); |
990 |
my $sms_provider = Koha::SMS::Providers->find( $member->{'sms_provider_id'} ); |
991 |
$message->{to_address} .= '@' . $sms_provider->domain(); |
991 |
$message->{to_address} .= '@' . $sms_provider->domain(); |
992 |
_send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} ); |
992 |
_send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'}, $params->('test_mode'), $params->{'test_email'} ); |
993 |
} else { |
993 |
} else { |
994 |
_send_message_by_sms( $message ); |
994 |
_send_message_by_sms( $message, $params->{'test_mode'}, $params->{test_sms} ); |
995 |
} |
995 |
} |
996 |
} |
996 |
} |
997 |
} |
997 |
} |
Lines 1176-1182
ENDSQL
Link Here
|
1176 |
|
1176 |
|
1177 |
sub _send_message_by_email { |
1177 |
sub _send_message_by_email { |
1178 |
my $message = shift or return; |
1178 |
my $message = shift or return; |
1179 |
my ($username, $password, $method) = @_; |
1179 |
my ( $username, $password, $method, $test_mode, $test_email ) = @_; |
1180 |
|
1180 |
|
1181 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1181 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1182 |
my $to_address = $message->{'to_address'}; |
1182 |
my $to_address = $message->{'to_address'}; |
Lines 1232-1246
sub _send_message_by_email {
Link Here
|
1232 |
|
1232 |
|
1233 |
_update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated |
1233 |
_update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated |
1234 |
|
1234 |
|
1235 |
if ( sendmail( %sendmail_params ) ) { |
1235 |
$sendmail_params{to} = $test_email if ( $test_mode && $test_email ) |
1236 |
_set_message_status( { message_id => $message->{'message_id'}, |
1236 |
|
1237 |
status => 'sent' } ); |
1237 |
if ( !$test_mode || ( $test_mode && $test_email ) ) { |
1238 |
return 1; |
1238 |
if ( sendmail(%sendmail_params) ) { |
1239 |
} else { |
1239 |
_set_message_status( |
1240 |
_set_message_status( { message_id => $message->{'message_id'}, |
1240 |
{ |
1241 |
status => 'failed' } ); |
1241 |
message_id => $message->{'message_id'}, |
1242 |
carp $Mail::Sendmail::error; |
1242 |
status => 'sent' |
1243 |
return; |
1243 |
} |
|
|
1244 |
); |
1245 |
return 1; |
1246 |
} |
1247 |
else { |
1248 |
_set_message_status( |
1249 |
{ |
1250 |
message_id => $message->{'message_id'}, |
1251 |
status => 'failed' |
1252 |
} |
1253 |
); |
1254 |
carp $Mail::Sendmail::error; |
1255 |
return; |
1256 |
} |
1244 |
} |
1257 |
} |
1245 |
} |
1258 |
} |
1246 |
|
1259 |
|
Lines 1283-1288
sub _is_duplicate {
Link Here
|
1283 |
|
1296 |
|
1284 |
sub _send_message_by_sms { |
1297 |
sub _send_message_by_sms { |
1285 |
my $message = shift or return; |
1298 |
my $message = shift or return; |
|
|
1299 |
my $test_mode = shift; |
1300 |
my $test_sms = shift; |
1301 |
|
1286 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1302 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1287 |
|
1303 |
|
1288 |
unless ( $member->{smsalertnumber} ) { |
1304 |
unless ( $member->{smsalertnumber} ) { |
Lines 1297-1307
sub _send_message_by_sms {
Link Here
|
1297 |
return; |
1313 |
return; |
1298 |
} |
1314 |
} |
1299 |
|
1315 |
|
1300 |
my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'}, |
1316 |
my $success; |
1301 |
message => $message->{'content'}, |
1317 |
if ($test_mode) { |
1302 |
} ); |
1318 |
if ( $test_sms ) { |
1303 |
_set_message_status( { message_id => $message->{'message_id'}, |
1319 |
$success = C4::SMS->send_sms( |
1304 |
status => ($success ? 'sent' : 'failed') } ); |
1320 |
{ |
|
|
1321 |
destination => $test_sms, |
1322 |
message => $message->{'content'}, |
1323 |
} |
1324 |
); |
1325 |
} |
1326 |
} |
1327 |
else { |
1328 |
$success = C4::SMS->send_sms( |
1329 |
{ |
1330 |
destination => $member->{'smsalertnumber'}, |
1331 |
message => $message->{'content'}, |
1332 |
} |
1333 |
); |
1334 |
} |
1335 |
|
1336 |
_set_message_status( |
1337 |
{ |
1338 |
message_id => $message->{'message_id'}, |
1339 |
status => ( $success ? 'sent' : 'failed' ) |
1340 |
} |
1341 |
); |
1342 |
|
1305 |
return $success; |
1343 |
return $success; |
1306 |
} |
1344 |
} |
1307 |
|
1345 |
|