Bugzilla – Attachment 83176 Details for
Bug 21988
Add SMSSendFrom system preference for specifying a source number for SMS messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21988: (follow-up) Provide more open params
Bug-21988-follow-up-Provide-more-open-params.patch (text/plain), 5.72 KB, created by
Kyle M Hall (khall)
on 2018-12-13 14:48:36 UTC
(
hide
)
Description:
Bug 21988: (follow-up) Provide more open params
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-12-13 14:48:36 UTC
Size:
5.72 KB
patch
obsolete
>From 51a852c094e9b6f0438967f5352c7d2ad2084dd9 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Thu, 13 Dec 2018 14:24:19 +0000 >Subject: [PATCH] Bug 21988: (follow-up) Provide more open params > >Rather than specifying a very specific additional parameter to be passed >to the provider, we now provide the ability for the user to specify a >JSON object containing arbitrary additional parameters, which are then >combined with the core parameters that are sent to the provider. > >Test plan: > >- Apply the patch and do the database update >- Navigate to the SMS preferences >- TEST => Observe that a new "Provide additional parameters to be passed >to the SMS provider (as a JSON object)" preference is displayed >- Enter a JSON object in to the preference >- Navigate away from the preferences >- Navigate back to the SMS preferences >- TEST => Observe that the value entered is preserved > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/SMS.pm | 19 ++++++++++++++++--- > .../bug_21988-add-syspref-SMSSendFrom.sql | 2 +- > installer/data/mysql/sysprefs.sql | 2 +- > .../en/modules/admin/preferences/patrons.pref | 6 ++++-- > t/SMS.t | 2 +- > 5 files changed, 23 insertions(+), 8 deletions(-) > >diff --git a/C4/SMS.pm b/C4/SMS.pm >index f8d10e0211..81d708570f 100644 >--- a/C4/SMS.pm >+++ b/C4/SMS.pm >@@ -55,6 +55,7 @@ use warnings; > > use C4::Context; > use File::Spec; >+use JSON qw( decode_json ); > > > >@@ -107,13 +108,25 @@ sub send_sms { > %args = map { q{_} . $_ => $conf->{$_} } keys %$conf; > } > >+ my $params_to_send = { >+ _login => C4::Context->preference('SMSSendUsername'), >+ _password => C4::Context->preference('SMSSendPassword'), >+ }; >+ # We may need to pass arbitrary additional parameters specified in >+ # SMSSendParams syspref >+ my $additional_params = C4::Context->preference('SMSSendParams'); >+ if ($additional_params && length $additional_params > 0) { >+ my $decoded = decode_json($additional_params); >+ if ($decoded) { >+ $params_to_send = { %$params_to_send, %$decoded }; >+ } >+ } >+ > eval { > # Create a sender > $sender = SMS::Send->new( > $driver, >- _login => C4::Context->preference('SMSSendUsername'), >- _password => C4::Context->preference('SMSSendPassword'), >- _from => C4::Context->preference('SMSSendFrom'), >+ %{$params_to_send}, > %args, > ); > >diff --git a/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql b/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql >index 6d974347b9..0d1543def3 100644 >--- a/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql >+++ b/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql >@@ -1 +1 @@ >-INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('SMSSendFrom', '', '', '"From" number used to send SMS messages', 'Free'); >+INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('SMSSendParams', '', '70|10', 'Additional parameters to be passed to the provider (as a JSON object)', 'Textarea'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index d248fc9485..24a8faa75d 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -530,7 +530,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'), > ('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'), > ('SMSSendUsername', '', '', 'Username/Login used to send SMS messages', 'free'), >-('SMSSendFrom', '', '', '"From" number used to send SMS messages', 'free'), >+('SMSSendParams', '', '70|10', 'Additional parameter to be passed to the provider (as a JSON object)', 'Textarea'), > ('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'), > ('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'), > ('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index d865ddff71..4caef35e0d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -142,8 +142,10 @@ Patrons: > - ". Override from address with" > - pref: EmailSMSSendDriverFromAddress > - "for emails sent using \"Email\" send driver." >- - "Define a number from which SMS messages will be sent" >- - pref: SMSSendFrom >+ - "Provide additional parameters to be passed to the SMS provider (as a JSON object)" >+ - pref: SMSSendParams >+ type: textarea >+ class: code > - > - pref: uppercasesurnames > choices: >diff --git a/t/SMS.t b/t/SMS.t >index 7930d2a8b7..3e829b4a95 100755 >--- a/t/SMS.t >+++ b/t/SMS.t >@@ -32,7 +32,7 @@ is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' ); > > t::lib::Mocks::mock_preference('SMSSendUsername', 'username'); > t::lib::Mocks::mock_preference('SMSSendPassword', 'pwd'); >-t::lib::Mocks::mock_preference('SMSSendFrom', '1234567890'); >+t::lib::Mocks::mock_preference('SMSSendParams', '{"_this":"that","_here":"there"}'); > > my $send_sms = C4::SMS->send_sms(); > is( $send_sms, undef, 'send_sms without arguments returns undef' ); >-- >2.17.2 (Apple Git-113)
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 21988
:
83132
|
83170
|
83175
| 83176