Bugzilla – Attachment 162116 Details for
Bug 36051
Add option to specify SMS::Send driver parameters in a system preference instead of a file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36051: Add option to specify SMS::Send driver parameters in a system preference
Bug-36051-Add-option-to-specify-SMSSend-driver-par.patch (text/plain), 5.65 KB, created by
Martin Renvoize (ashimema)
on 2024-02-13 16:31:33 UTC
(
hide
)
Description:
Bug 36051: Add option to specify SMS::Send driver parameters in a system preference
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-02-13 16:31:33 UTC
Size:
5.65 KB
patch
obsolete
>From 6bd1f509033ac1cc7424053759d3b21124bfe966 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 8 Feb 2024 12:44:28 -0500 >Subject: [PATCH] Bug 36051: Add option to specify SMS::Send driver parameters > in a system preference > >If an SMS::Send driver ( such as Twilio ) requires additional parameters, those >parameters have to be placed in a yaml file named after the SMS::Send driver, >and the path to that file specified in the Koha conf file. > >It would be good if we had the option to specify those parameters in a YAML >system preference instead. This would be less complicated and avoid requiring >an administrator to update that data from the backend. > >Test Plan: >1) Set up an SMS::Send driver that requires additional options; > a Twilio account meets these requirements and can be created for > free. Set this up using the traditional file based system. >2) Verify you can send SMS messages >3) Move the contents of that file into the new system preference > SMSSendAdditionalOptions >4) Verify you can still send SMS messages >5) Delete the file >6) Verify yet again you can still send SMS messages! > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/SMS.pm | 16 ++++++++++++++- > .../data/mysql/atomicupdate/bug_36051.pl | 20 +++++++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/patrons.pref | 4 ++++ > 4 files changed, 40 insertions(+), 1 deletion(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_36051.pl > >diff --git a/C4/SMS.pm b/C4/SMS.pm >index ce3358f66ab..e3ecae3c167 100644 >--- a/C4/SMS.pm >+++ b/C4/SMS.pm >@@ -94,19 +94,33 @@ sub send_sms { > my $subpath = $driver; > $subpath =~ s|::|/|g; > >+ # Extract additional SMS::Send arguments from file > my $sms_send_config = C4::Context->config('sms_send_config'); > my $conf_file = defined $sms_send_config > ? File::Spec->catfile( $sms_send_config, $subpath ) > : $subpath; > $conf_file .= q{.yaml}; > >- my %args; >+ my %args = (); > if ( -f $conf_file ) { > require YAML::XS; > my $conf = YAML::XS::LoadFile( $conf_file ); > %args = map { q{_} . $_ => $conf->{$_} } keys %$conf; > } > >+ # Extract additional SMS::Send arguments from the syspref >+ # Merge with any arguments from file with syspref taking precedence >+ my $sms_send_config_syspref = C4::Context->preference('SMSSendAdditionalOptions'); >+ if ( $sms_send_config_syspref ) { >+ require YAML::XS; >+ >+ $sms_send_config_syspref = "$sms_send_config_syspref\n\n"; >+ my $yaml; >+ eval { $yaml = YAML::XS::Load(Encode::encode_utf8($yaml)); }; >+ my %syspref_args = map { q{_} . $_ => $conf->{$_} } keys %$conf; >+ %args = ( %args, %syspref_args ); >+ } >+ > eval { > # Create a sender > $sender = SMS::Send->new( >diff --git a/installer/data/mysql/atomicupdate/bug_36051.pl b/installer/data/mysql/atomicupdate/bug_36051.pl >new file mode 100755 >index 00000000000..0461900e296 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_36051.pl >@@ -0,0 +1,20 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "36051", >+ description => "Add option to specify SMS::Send driver parameters in a system preference instead of a file", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Do you stuffs here >+ $dbh->do( >+ q{ >+ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('SMSSendAdditionalOptions', '', '', 'Additional SMS::Send parameters used to send SMS messages', 'free'); >+ } >+ ); >+ >+ say $out "Added new system preference 'SMSSendAdditionalOptions'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 669074aa506..7a4e0d253d0 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -709,6 +709,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'), > ('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'), > ('SlipCSS','',NULL,'Slips CSS url.','free'), >+('SMSSendAdditionalOptions', '', '', 'Additional SMS::Send parameters used to send SMS messages', 'free'), > ('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'), >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 09991d64b44..2414a348851 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 >@@ -238,6 +238,10 @@ Patrons: > - pref: EmailSMSSendDriverFromAddress > class: email > - "for emails sent using \"Email\" send driver." >+ - "If the SMS::Send driver requires more options that just username/login and password, entire them here as YAML key/value pairs:" >+ - pref: SMSSendAdditionalOptions >+ type: textarea >+ syntax: text/x-yaml > - > - pref: FallbackToSMSIfNoEmail > choices: >-- >2.43.0
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 36051
:
161945
|
162115
| 162116 |
162117
|
162118