Bugzilla – Attachment 56113 Details for
Bug 13029
Allow to pass additional parameters to SMS::Send drivers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 13029: Allow to pass additional parameters to SMS::Send drivers
SIGNED-OFF-Bug-13029-Allow-to-pass-additional-para.patch (text/plain), 2.70 KB, created by
Magnus Enger
on 2016-10-10 14:13:53 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 13029: Allow to pass additional parameters to SMS::Send drivers
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2016-10-10 14:13:53 UTC
Size:
2.70 KB
patch
obsolete
>From 8b6e3d5bc6f802ad5c0d60b2fa3cdd8ea2210d69 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 6 Oct 2014 15:04:12 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 13029: Allow to pass additional parameters > to SMS::Send drivers > >C4::SMS::send_sms now reads a YAML file and pass all parameters in the >file to SMS::Send::new. > >The config file is read in <installdir>/etc/sms/driver/<driver>.yaml. >For instance, if the driver used is SMS::Send::UK::Kapow, the config >file has to be in <installdir>/etc/sms/driver/UK/Kapow.yaml > >A underscore character is prepended to all parameter names so they are >treated as driver-specific options (leading underscore must not appear >in config file). > >Signed-off-by: Magnus Enger <magnus@libriotech.no> >--- > C4/SMS.pm | 37 ++++++++++++++++++++++++++++--------- > 1 file changed, 28 insertions(+), 9 deletions(-) > >diff --git a/C4/SMS.pm b/C4/SMS.pm >index 41407e3..d011f5f 100644 >--- a/C4/SMS.pm >+++ b/C4/SMS.pm >@@ -36,6 +36,7 @@ use strict; > use warnings; > > use C4::Context; >+use File::Spec; > > > >@@ -70,21 +71,39 @@ sub send_sms { > my $driver = exists $params->{'driver'} ? $params->{'driver'} : $self->driver(); > return unless $driver; > >- # warn "using driver: $driver to send message to $params->{'destination'}"; > > my ($sent, $sender); >+ >+ my $subpath = $driver; >+ $subpath =~ s|::|/|; >+ >+ my $conf_file = File::Spec->catfile( >+ C4::Context->config('installdir'), >+ 'etc', 'sms', 'driver', $subpath >+ ) . q{.yaml}; >+ my %args; >+ if ( -f $conf_file ) { >+ require YAML; >+ my $conf = YAML::LoadFile( $conf_file ); >+ %args = map { q{_} . $_ => $conf->{$_} } keys %$conf; >+ } >+ > eval { > # Create a sender >- $sender = SMS::Send->new( $driver, >- _login => C4::Context->preference('SMSSendUsername'), >- _password => C4::Context->preference('SMSSendPassword'), >- ); >- >+ $sender = SMS::Send->new( >+ $driver, >+ _login => C4::Context->preference('SMSSendUsername'), >+ _password => C4::Context->preference('SMSSendPassword'), >+ %args, >+ ); >+ > # Send a message >- $sent = $sender->send_sms( to => $params->{'destination'}, >- text => $params->{'message'}, >- ); >+ $sent = $sender->send_sms( >+ to => $params->{destination}, >+ text => $params->{message}, >+ ); > }; >+ > #We might die because SMS::Send $driver is not defined or the sms-number has a bad format > #Catch those errors and fail the sms-sending gracefully. > if ($@) { >-- >2.1.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 13029
:
32011
|
32013
|
34403
|
55942
|
55943
|
56102
|
56103
|
56104
|
56111
|
56112
|
56113
|
56116
|
58170
|
58172