|
Lines 36-41
use strict;
Link Here
|
| 36 |
use warnings; |
36 |
use warnings; |
| 37 |
|
37 |
|
| 38 |
use C4::Context; |
38 |
use C4::Context; |
|
|
39 |
use File::Spec; |
| 39 |
|
40 |
|
| 40 |
use vars qw( $VERSION ); |
41 |
use vars qw( $VERSION ); |
| 41 |
|
42 |
|
|
Lines 74-87
sub send_sms {
Link Here
|
| 74 |
my $driver = exists $params->{'driver'} ? $params->{'driver'} : $self->driver(); |
75 |
my $driver = exists $params->{'driver'} ? $params->{'driver'} : $self->driver(); |
| 75 |
return unless $driver; |
76 |
return unless $driver; |
| 76 |
|
77 |
|
| 77 |
# warn "using driver: $driver to send message to $params->{'destination'}"; |
78 |
|
| 78 |
|
79 |
my $subpath = $driver; |
|
|
80 |
$subpath =~ s|::|/|; |
| 81 |
|
| 82 |
my $conf_file = File::Spec->catfile( |
| 83 |
C4::Context->config('installdir'), |
| 84 |
'etc', 'sms', 'driver', $subpath |
| 85 |
) . q{.yaml}; |
| 86 |
my %args; |
| 87 |
if ( -f $conf_file ) { |
| 88 |
require YAML; |
| 89 |
my $conf = YAML::LoadFile( $conf_file ); |
| 90 |
%args = map { q{_} . $_ => $conf->{$_} } keys %$conf; |
| 91 |
} |
| 92 |
|
| 79 |
# Create a sender |
93 |
# Create a sender |
| 80 |
my $sender = SMS::Send->new( $driver, |
94 |
my $sender = SMS::Send->new( |
| 81 |
_login => C4::Context->preference('SMSSendUsername'), |
95 |
$driver, |
| 82 |
_password => C4::Context->preference('SMSSendPassword'), |
96 |
_login => C4::Context->preference('SMSSendUsername'), |
| 83 |
); |
97 |
_password => C4::Context->preference('SMSSendPassword'), |
| 84 |
|
98 |
%args, |
|
|
99 |
); |
| 100 |
|
| 85 |
# Send a message |
101 |
# Send a message |
| 86 |
my $sent = $sender->send_sms( to => $params->{'destination'}, |
102 |
my $sent = $sender->send_sms( to => $params->{'destination'}, |
| 87 |
text => $params->{'message'}, |
103 |
text => $params->{'message'}, |
| 88 |
- |
|
|