Lines 21-28
use strict;
Link Here
|
21 |
use warnings; |
21 |
use warnings; |
22 |
use C4::Context; |
22 |
use C4::Context; |
23 |
|
23 |
|
24 |
|
|
|
25 |
|
26 |
=head1 NAME |
24 |
=head1 NAME |
27 |
|
25 |
|
28 |
C4::Members::Messaging - manage patron messaging preferences |
26 |
C4::Members::Messaging - manage patron messaging preferences |
Lines 184-225
END_SQL
Link Here
|
184 |
return; |
182 |
return; |
185 |
} |
183 |
} |
186 |
|
184 |
|
187 |
=head2 GetMessagingOptions |
|
|
188 |
|
189 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions() |
190 |
|
191 |
returns a hashref of messaging options available. |
192 |
|
193 |
=cut |
194 |
|
195 |
sub GetMessagingOptions { |
196 |
|
197 |
my $sql = <<'END_SQL'; |
198 |
select message_attributes.message_attribute_id, takes_days, message_name, message_transport_type, is_digest |
199 |
FROM message_attributes |
200 |
LEFT JOIN message_transports |
201 |
ON message_attributes.message_attribute_id = message_transports.message_attribute_id |
202 |
END_SQL |
203 |
|
204 |
my $sth = C4::Context->dbh->prepare($sql); |
205 |
$sth->execute(); |
206 |
my $choices; |
207 |
while ( my $row = $sth->fetchrow_hashref() ) { |
208 |
$choices->{ $row->{'message_name'} }->{'message_attribute_id'} = $row->{'message_attribute_id'}; |
209 |
$choices->{ $row->{'message_name'} }->{'message_name'} = $row->{'message_name'}; |
210 |
$choices->{ $row->{'message_name'} }->{'takes_days'} = $row->{'takes_days'}; |
211 |
$choices->{ $row->{'message_name'} }->{'has_digest'} = 1 if $row->{'is_digest'}; |
212 |
$choices->{ $row->{'message_name'} }->{'transport_' . $row->{'message_transport_type'}} = ' '; |
213 |
} |
214 |
|
215 |
my @return = values %$choices; |
216 |
|
217 |
@return = sort { $a->{message_attribute_id} <=> $b->{message_attribute_id} } @return; |
218 |
|
219 |
# warn( Data::Dumper->Dump( [ \@return ], [ 'return' ] ) ); |
220 |
return \@return; |
221 |
} |
222 |
|
223 |
=head2 SetMessagingPreferencesFromDefaults |
185 |
=head2 SetMessagingPreferencesFromDefaults |
224 |
|
186 |
|
225 |
C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower->{'borrowernumber'} |
187 |
C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower->{'borrowernumber'} |
Lines 240-246
sub SetMessagingPreferencesFromDefaults {
Link Here
|
240 |
} |
202 |
} |
241 |
} |
203 |
} |
242 |
|
204 |
|
243 |
my $messaging_options = GetMessagingOptions(); |
205 |
my $messaging_options = Koha::Patron::Message::Preferences->get_options; |
244 |
OPTION: foreach my $option ( @$messaging_options ) { |
206 |
OPTION: foreach my $option ( @$messaging_options ) { |
245 |
my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode}, |
207 |
my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode}, |
246 |
message_name => $option->{'message_name'} } ); |
208 |
message_name => $option->{'message_name'} } ); |