View | Details | Raw Unified | Return to bug 21988
Collapse All | Expand All

(-)a/C4/SMS.pm (-3 / +16 lines)
Lines 55-60 use warnings; Link Here
55
55
56
use C4::Context;
56
use C4::Context;
57
use File::Spec;
57
use File::Spec;
58
use JSON qw( decode_json );
58
59
59
60
60
61
Lines 107-119 sub send_sms { Link Here
107
        %args = map { q{_} . $_ => $conf->{$_} } keys %$conf;
108
        %args = map { q{_} . $_ => $conf->{$_} } keys %$conf;
108
    }
109
    }
109
110
111
    my $params_to_send = {
112
        _login    => C4::Context->preference('SMSSendUsername'),
113
        _password => C4::Context->preference('SMSSendPassword'),
114
    };
115
    # We may need to pass arbitrary additional parameters specified in
116
    # SMSSendParams syspref
117
    my $additional_params = C4::Context->preference('SMSSendParams');
118
    if ($additional_params && length $additional_params > 0) {
119
        my $decoded = decode_json($additional_params);
120
        if ($decoded) {
121
            $params_to_send = { %$params_to_send, %$decoded };
122
        }
123
    }
124
110
    eval {
125
    eval {
111
        # Create a sender
126
        # Create a sender
112
        $sender = SMS::Send->new(
127
        $sender = SMS::Send->new(
113
            $driver,
128
            $driver,
114
            _login    => C4::Context->preference('SMSSendUsername'),
129
            %{$params_to_send},
115
            _password => C4::Context->preference('SMSSendPassword'),
116
            _from     => C4::Context->preference('SMSSendFrom'),
117
            %args,
130
            %args,
118
        );
131
        );
119
132
(-)a/installer/data/mysql/atomicupdate/bug_21988-add-syspref-SMSSendFrom.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES  ('SMSSendFrom', '', '', '"From" number used to send SMS messages', 'Free');
1
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');
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 530-536 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
530
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
530
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
531
('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'),
531
('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'),
532
('SMSSendUsername', '', '', 'Username/Login used to send SMS messages', 'free'),
532
('SMSSendUsername', '', '', 'Username/Login used to send SMS messages', 'free'),
533
('SMSSendFrom', '', '', '"From" number used to send SMS messages', 'free'),
533
('SMSSendParams', '', '70|10', 'Additional parameter to be passed to the provider (as a JSON object)', 'Textarea'),
534
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
534
('SocialNetworks','0','','Enable/Disable social networks links in opac detail pages','YesNo'),
535
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
535
('SpecifyDueDate','1','','Define whether to display \"Specify Due Date\" form in Circulation','YesNo'),
536
('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'),
536
('SpecifyReturnDate',1,'','Define whether to display \"Specify Return Date\" form in Circulation','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-2 / +4 lines)
Lines 142-149 Patrons: Link Here
142
         - ". Override from address with"
142
         - ". Override from address with"
143
         - pref: EmailSMSSendDriverFromAddress
143
         - pref: EmailSMSSendDriverFromAddress
144
         - "for emails sent using \"Email\" send driver."
144
         - "for emails sent using \"Email\" send driver."
145
         - "Define a number from which SMS messages will be sent"
145
         - "Provide additional parameters to be passed to the SMS provider (as a JSON object)"
146
         - pref: SMSSendFrom
146
         - pref: SMSSendParams
147
           type: textarea
148
           class: code
147
     -
149
     -
148
         - pref: uppercasesurnames
150
         - pref: uppercasesurnames
149
           choices:
151
           choices:
(-)a/t/SMS.t (-2 / +1 lines)
Lines 32-38 is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' ); Link Here
32
32
33
t::lib::Mocks::mock_preference('SMSSendUsername', 'username');
33
t::lib::Mocks::mock_preference('SMSSendUsername', 'username');
34
t::lib::Mocks::mock_preference('SMSSendPassword', 'pwd');
34
t::lib::Mocks::mock_preference('SMSSendPassword', 'pwd');
35
t::lib::Mocks::mock_preference('SMSSendFrom', '1234567890');
35
t::lib::Mocks::mock_preference('SMSSendParams', '{"this":"that","here":"there"}');
36
36
37
my $send_sms = C4::SMS->send_sms();
37
my $send_sms = C4::SMS->send_sms();
38
is( $send_sms, undef, 'send_sms without arguments returns undef' );
38
is( $send_sms, undef, 'send_sms without arguments returns undef' );
39
- 

Return to bug 21988