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 1226-1232
ENDSQL
Link Here
|
1226 |
|
1226 |
|
1227 |
sub _send_message_by_email { |
1227 |
sub _send_message_by_email { |
1228 |
my $message = shift or return; |
1228 |
my $message = shift or return; |
1229 |
my ($username, $password, $method) = @_; |
1229 |
my ( $username, $password, $method, $test_mode, $test_email ) = @_; |
1230 |
|
1230 |
|
1231 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1231 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1232 |
my $to_address = $message->{'to_address'}; |
1232 |
my $to_address = $message->{'to_address'}; |
Lines 1282-1296
sub _send_message_by_email {
Link Here
|
1282 |
|
1282 |
|
1283 |
_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 |
1283 |
_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 |
1284 |
|
1284 |
|
1285 |
if ( sendmail( %sendmail_params ) ) { |
1285 |
$sendmail_params{to} = $test_email if ( $test_mode && $test_email ); |
1286 |
_set_message_status( { message_id => $message->{'message_id'}, |
1286 |
|
1287 |
status => 'sent' } ); |
1287 |
if ( !$test_mode || ( $test_mode && $test_email ) ) { |
1288 |
return 1; |
1288 |
if ( sendmail(%sendmail_params) ) { |
1289 |
} else { |
1289 |
_set_message_status( |
1290 |
_set_message_status( { message_id => $message->{'message_id'}, |
1290 |
{ |
1291 |
status => 'failed' } ); |
1291 |
message_id => $message->{'message_id'}, |
1292 |
carp $Mail::Sendmail::error; |
1292 |
status => 'sent' |
1293 |
return; |
1293 |
} |
|
|
1294 |
); |
1295 |
return 1; |
1296 |
} |
1297 |
else { |
1298 |
_set_message_status( |
1299 |
{ |
1300 |
message_id => $message->{'message_id'}, |
1301 |
status => 'failed' |
1302 |
} |
1303 |
); |
1304 |
carp $Mail::Sendmail::error; |
1305 |
return; |
1306 |
} |
1294 |
} |
1307 |
} |
1295 |
} |
1308 |
} |
1296 |
|
1309 |
|
Lines 1333-1338
sub _is_duplicate {
Link Here
|
1333 |
|
1346 |
|
1334 |
sub _send_message_by_sms { |
1347 |
sub _send_message_by_sms { |
1335 |
my $message = shift or return; |
1348 |
my $message = shift or return; |
|
|
1349 |
my $test_mode = shift; |
1350 |
my $test_sms = shift; |
1351 |
|
1336 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1352 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1337 |
|
1353 |
|
1338 |
unless ( $member->{smsalertnumber} ) { |
1354 |
unless ( $member->{smsalertnumber} ) { |
Lines 1347-1357
sub _send_message_by_sms {
Link Here
|
1347 |
return; |
1363 |
return; |
1348 |
} |
1364 |
} |
1349 |
|
1365 |
|
1350 |
my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'}, |
1366 |
my $success; |
1351 |
message => $message->{'content'}, |
1367 |
if ($test_mode) { |
1352 |
} ); |
1368 |
if ( $test_sms ) { |
1353 |
_set_message_status( { message_id => $message->{'message_id'}, |
1369 |
$success = C4::SMS->send_sms( |
1354 |
status => ($success ? 'sent' : 'failed') } ); |
1370 |
{ |
|
|
1371 |
destination => $test_sms, |
1372 |
message => $message->{'content'}, |
1373 |
} |
1374 |
); |
1375 |
} |
1376 |
} |
1377 |
else { |
1378 |
$success = C4::SMS->send_sms( |
1379 |
{ |
1380 |
destination => $member->{'smsalertnumber'}, |
1381 |
message => $message->{'content'}, |
1382 |
} |
1383 |
); |
1384 |
} |
1385 |
|
1386 |
_set_message_status( |
1387 |
{ |
1388 |
message_id => $message->{'message_id'}, |
1389 |
status => ( $success ? 'sent' : 'failed' ) |
1390 |
} |
1391 |
); |
1392 |
|
1355 |
return $success; |
1393 |
return $success; |
1356 |
} |
1394 |
} |
1357 |
|
1395 |
|