Lines 20-25
package C4::Form::MessagingPreferences;
Link Here
|
20 |
use strict; |
20 |
use strict; |
21 |
use warnings; |
21 |
use warnings; |
22 |
|
22 |
|
|
|
23 |
use Data::Dumper; |
23 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
24 |
use C4::Context; |
25 |
use C4::Context; |
25 |
use C4::Debug; |
26 |
use C4::Debug; |
Lines 77-85
sub handle_form_action {
Link Here
|
77 |
my $messaging_options = Koha::Patron::Message::Preferences->get_options; |
78 |
my $messaging_options = Koha::Patron::Message::Preferences->get_options; |
78 |
# TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box |
79 |
# TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box |
79 |
my $prefs_set = 0; |
80 |
my $prefs_set = 0; |
|
|
81 |
my $borrowernumber; |
82 |
my $logEntries = []; |
80 |
OPTION: foreach my $option ( @$messaging_options ) { |
83 |
OPTION: foreach my $option ( @$messaging_options ) { |
81 |
my $updater = { %{ $target_params }, |
84 |
my $updater = { %{ $target_params }, |
82 |
message_attribute_id => $option->{'message_attribute_id'} }; |
85 |
message_attribute_id => $option->{'message_attribute_id'} }; |
|
|
86 |
$borrowernumber = $target_params->{borrowernumber} unless $borrowernumber; |
83 |
|
87 |
|
84 |
# find the desired transports |
88 |
# find the desired transports |
85 |
@{$updater->{'message_transport_types'}} = $query->multi_param( $option->{'message_attribute_id'} ); |
89 |
@{$updater->{'message_transport_types'}} = $query->multi_param( $option->{'message_attribute_id'} ); |
Lines 110-115
sub handle_form_action {
Link Here
|
110 |
$preference->set($updater)->store; |
114 |
$preference->set($updater)->store; |
111 |
} |
115 |
} |
112 |
|
116 |
|
|
|
117 |
_pushToActionLogBuffer($logEntries, $updater, $option); |
118 |
|
113 |
if ($query->param( $option->{'message_attribute_id'})){ |
119 |
if ($query->param( $option->{'message_attribute_id'})){ |
114 |
$prefs_set = 1; |
120 |
$prefs_set = 1; |
115 |
} |
121 |
} |
Lines 122-127
sub handle_form_action {
Link Here
|
122 |
} |
128 |
} |
123 |
# show the success message |
129 |
# show the success message |
124 |
$template->param( settings_updated => 1 ); |
130 |
$template->param( settings_updated => 1 ); |
|
|
131 |
|
132 |
_writeActionLogBuffer($logEntries, $borrowernumber); |
125 |
} |
133 |
} |
126 |
|
134 |
|
127 |
=head2 set_form_values |
135 |
=head2 set_form_values |
Lines 163-168
sub set_form_values {
Link Here
|
163 |
$template->param(messaging_preferences => $messaging_options); |
171 |
$template->param(messaging_preferences => $messaging_options); |
164 |
} |
172 |
} |
165 |
|
173 |
|
|
|
174 |
sub _pushToActionLogBuffer { |
175 |
return unless C4::Context->preference("BorrowersLog"); |
176 |
my ($logEntries, $updater, $option) = @_; |
177 |
|
178 |
if ($updater->{message_transport_types} && scalar(@{$updater->{message_transport_types}})) { |
179 |
my $entry = {}; |
180 |
$entry->{cc} = $updater->{categorycode} if $updater->{categorycode}; |
181 |
$entry->{dig} = $updater->{wants_digest} if $updater->{wants_digest}; |
182 |
$entry->{da} = $updater->{days_in_advance} if $updater->{days_in_advance}; |
183 |
$entry->{mtt} = $updater->{message_transport_types}; |
184 |
$entry->{_name} = $option->{message_name}; |
185 |
push(@$logEntries, $entry); |
186 |
} |
187 |
} |
188 |
|
189 |
sub _writeActionLogBuffer { |
190 |
return unless C4::Context->preference("BorrowersLog"); |
191 |
my ($logEntries, $borrowernumber) = @_; |
192 |
|
193 |
if (scalar(@$logEntries)) { |
194 |
my $d = Data::Dumper->new([$logEntries]); |
195 |
$d->Indent(0); |
196 |
$d->Purity(0); |
197 |
$d->Terse(1); |
198 |
C4::Log::logaction('MEMBERS', 'MOD MTT', $borrowernumber, $d->Dump($logEntries)); |
199 |
} |
200 |
else { |
201 |
C4::Log::logaction('MEMBERS', 'MOD MTT', $borrowernumber, 'All message_transports removed') |
202 |
} |
203 |
} |
204 |
|
166 |
=head1 TODO |
205 |
=head1 TODO |
167 |
|
206 |
|
168 |
=over 4 |
207 |
=over 4 |
169 |
- |
|
|