From 6740f9d10806b2e082a3983bdf8652f62dccdc5f Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Wed, 12 Dec 2018 15:48:24 +0000 Subject: [PATCH] Bug 21988: Add support for SMSSendFrom syspref This patch adds a SMSSendFrom syspref which allows a "from" number to be provided to SMS drivers that support it. It is passed to the driver as a "_from" parameter, in line with the formatting of the _username and _password parameters. Testing: Since this work depends on an SMS driver that supports it, it is virtually impossible to test. I have added the mocking of the SMSSendFrom preference to t/SMS.t, but can't really take it beyond that. Other than the adding of the syspref, a very tiny modification is made to C4/SMS.pm, but I don't anticipate this having an adverse effect. SMS drivers that do not support the _from paramter will simple ignore it. Signed-off-by: Kyle M Hall --- C4/SMS.pm | 1 + .../mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 2 ++ t/SMS.t | 1 + 5 files changed, 6 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql diff --git a/C4/SMS.pm b/C4/SMS.pm index eff72b358c..f8d10e0211 100644 --- a/C4/SMS.pm +++ b/C4/SMS.pm @@ -113,6 +113,7 @@ sub send_sms { $driver, _login => C4::Context->preference('SMSSendUsername'), _password => C4::Context->preference('SMSSendPassword'), + _from => C4::Context->preference('SMSSendFrom'), %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 new file mode 100644 index 0000000000..6d974347b9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('SMSSendFrom', '', '', '"From" number used to send SMS messages', 'Free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 1e36c306c6..d248fc9485 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -530,6 +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'), ('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 ecb1c4e6df..d865ddff71 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,6 +142,8 @@ 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 - - pref: uppercasesurnames choices: diff --git a/t/SMS.t b/t/SMS.t index 21dc75bbb8..7930d2a8b7 100755 --- a/t/SMS.t +++ b/t/SMS.t @@ -32,6 +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'); my $send_sms = C4::SMS->send_sms(); is( $send_sms, undef, 'send_sms without arguments returns undef' ); -- 2.17.2 (Apple Git-113)