Bugzilla – Attachment 161819 Details for
Bug 36022
Add default recipient phone number country code syspref for SMS::Send driver
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36022: Add default recipient SMS number country code
Bug-36022-Add-default-recipient-SMS-number-country.patch (text/plain), 4.68 KB, created by
David Gustafsson
on 2024-02-07 16:18:48 UTC
(
hide
)
Description:
Bug 36022: Add default recipient SMS number country code
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-02-07 16:18:48 UTC
Size:
4.68 KB
patch
obsolete
>From 97d81e859e2c6ad5134c32b7ce34aa71b2e5046e Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Wed, 7 Feb 2024 17:11:58 +0100 >Subject: [PATCH] Bug 36022: Add default recipient SMS number country code > >Add SMSSendDefaultCountryCode syspref to prepend country >code to non international SMS numbers. > >To test: TODO >--- > C4/SMS.pm | 15 ++++++++++++++- > ...36022-add-SMSSendDefaultCountryCode-syspref.pl | 14 ++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/patrons.pref | 5 +++++ > 4 files changed, 34 insertions(+), 1 deletion(-) > create mode 100755 installer/data/mysql/atomicupdate/bug-36022-add-SMSSendDefaultCountryCode-syspref.pl > >diff --git a/C4/SMS.pm b/C4/SMS.pm >index ce3358f66ab..6a9ac750d9a 100644 >--- a/C4/SMS.pm >+++ b/C4/SMS.pm >@@ -116,9 +116,22 @@ sub send_sms { > %args, > ); > >+ my $default_country_code = C4::Context->preference("SMSSendDefaultCountryCode"); >+ my $destination = $params->{destination}; >+ >+ # Default country code set and is local phone number >+ if ($default_country_code && $destination =~ /^[^+]/) { >+ # Ensure country code has leading '+' >+ $default_country_code =~ s/^[^+]/+$&/; >+ # Strip leading zeroes >+ $destination =~ s/^0+//; >+ # Prepend default country code >+ $destination = $default_country_code . $destination; >+ } >+ > # Send a message > $sent = $sender->send_sms( >- to => $params->{destination}, >+ to => $destination, > text => $params->{message}, > ); > }; >diff --git a/installer/data/mysql/atomicupdate/bug-36022-add-SMSSendDefaultCountryCode-syspref.pl b/installer/data/mysql/atomicupdate/bug-36022-add-SMSSendDefaultCountryCode-syspref.pl >new file mode 100755 >index 00000000000..95f742d3917 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-36022-add-SMSSendDefaultCountryCode-syspref.pl >@@ -0,0 +1,14 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "BUG_NUMBER", >+ description => "Add SMSSendDefaultCountryCode system preference", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ $dbh->do(q{ INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('SMSSendDefaultCountryCode ', NULL, NULL, 'Default SMS::Send driver recipient phone number country code', 'Integer') }); >+ # sysprefs >+ say $out "Added new system preference 'SMSSendDefaultCountryCode'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index fad32d896e5..684f02a71ed 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -680,6 +680,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'), >+('SMSSendDefaultCountryCode ',NULL,NULL,'Default SMS::Send driver recipient phone number country code','Integer'), > ('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 0adb1ae1d7b..5140f7ceaeb 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 >@@ -217,6 +217,11 @@ Patrons: > - driver to send SMS messages. > - "<br>If you would prefer to send SMS via E-mail, set SMSSendDriver to: Email" > - "<br><strong>NOTE:</strong> Many mobile providers have deprecated support for this feature and it is not recommended for use unless you have a dedicated SMS to Email gateway." >+ - >+ - "Prepend the country code" >+ - pref: SMSSendDefaultCountryCode >+ - class: integer >+ - "for SMS::Driver recipient phone numbers. The country code shound not include a leading \"+\"." > - > - "Define a username/login" > - pref: SMSSendUsername >-- >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 36022
:
161819
|
161820
|
161946
|
161947
|
161948
|
161949