diff --git a/C4/SMS.pm b/C4/SMS.pm index cb65263f98..bcf2e5bbcc 100644 --- a/C4/SMS.pm +++ b/C4/SMS.pm @@ -98,19 +98,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 0000000000..0461900e29 --- /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 ea52eac6e4..8c19ccd127 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -714,6 +714,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 f48ba4c13c..75088bba46 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: