From 321eed98334bac3564b0b11abf3fb6fe34074f0d Mon Sep 17 00:00:00 2001 From: ByWater Solutions Date: Sat, 30 Oct 2010 09:50:29 -0400 Subject: [PATCH] Bug 4254 - adding new patron advanced notice doesn't save This was due to poorly constructed SQL which returned duplicate values for certain fields. This patch corrects that SQL. NOTE: There is also a formatting problem with the message prefs display table when it is displayed in moremember.pl. This is due to there being no logic to tell the table in that context to display checkboxes as appropriate. This patch does not fix that. Bug 5328 has been opened for this problem. Signed-off-by: Chris Cormack --- C4/Form/MessagingPreferences.pm | 3 +-- C4/Members/Messaging.pm | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/C4/Form/MessagingPreferences.pm b/C4/Form/MessagingPreferences.pm index bad3aa6682..22b2048bfd 100644 --- a/C4/Form/MessagingPreferences.pm +++ b/C4/Form/MessagingPreferences.pm @@ -121,8 +121,7 @@ sub set_form_values { # walk through the options and update them with these borrower_preferences my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); PREF: foreach my $option ( @$messaging_options ) { - my $pref = C4::Members::Messaging::GetMessagingPreferences( { %{ $target_params }, - message_name => $option->{'message_name'} } ); + my $pref = C4::Members::Messaging::GetMessagingPreferences( { %{ $target_params }, message_name => $option->{'message_name'} } ); # make a hashref of the days, selecting one. if ( $option->{'takes_days'} ) { my $days_in_advance = $pref->{'days_in_advance'} ? $pref->{'days_in_advance'} : 0; diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm index 13b91fede8..f5530e97c7 100644 --- a/C4/Members/Messaging.pm +++ b/C4/Members/Messaging.pm @@ -61,21 +61,23 @@ sub GetMessagingPreferences { return unless exists $params->{message_name}; return unless exists $params->{borrowernumber} xor exists $params->{categorycode}; # yes, xor - my $sql = <<'END_SQL'; SELECT borrower_message_preferences.*, borrower_message_transport_preferences.message_transport_type, - message_attributes.*, - message_transports.* - FROM borrower_message_preferences - LEFT JOIN borrower_message_transport_preferences - ON borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id - LEFT JOIN message_attributes - ON message_attributes.message_attribute_id = borrower_message_preferences.message_attribute_id - LEFT JOIN message_transports - ON message_transports.message_attribute_id = message_attributes.message_attribute_id - AND message_transports.message_transport_type = borrower_message_transport_preferences.message_transport_type - WHERE message_attributes.message_name = ? + message_attributes.message_name, + message_attributes.takes_days, + message_transports.is_digest, + message_transports.letter_module, + message_transports.letter_code +FROM borrower_message_preferences +LEFT JOIN borrower_message_transport_preferences +ON borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id +LEFT JOIN message_attributes +ON message_attributes.message_attribute_id = borrower_message_preferences.message_attribute_id +LEFT JOIN message_transports +ON message_transports.message_attribute_id = message_attributes.message_attribute_id +AND message_transports.message_transport_type = borrower_message_transport_preferences.message_transport_type +WHERE message_attributes.message_name = ? END_SQL my @bind_params = ( $params->{'message_name'} ); @@ -93,10 +95,9 @@ END_SQL my %transports; # helps build a list of unique message_transport_types ROW: while ( my $row = $sth->fetchrow_hashref() ) { next ROW unless $row->{'message_attribute_id'}; - # warn( Data::Dumper->Dump( [ $row ], [ 'row' ] ) ); $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'}; $return->{'wants_digest'} = $row->{'wants_digest'} if defined $row->{'wants_digest'}; - $return->{'letter_code'} = $row->{'letter_code'}; + $return->{'letter_code'} = $row->{'letter_code'}; $transports{$row->{'message_transport_type'}} = 1; } @{$return->{'transports'}} = keys %transports; -- 2.39.5