-my $borrower = GetMemberDetails( $borrowernumber );
-
-my $messaging_options = C4::Members::Messaging::GetMessagingOptions();
-my $messaging_preferences;
-
-if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) {
-
- # If they've modified the SMS number, record it.
- if ( ( defined $query->param('SMSnumber') ) && ( $query->param('SMSnumber') ne $borrower->{'mobile'} ) ) {
- ModMember( borrowernumber => $borrowernumber,
- smsalertnumber => $query->param('SMSnumber') );
- $borrower = GetMemberDetails( $borrowernumber );
- }
-
- # TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box
-
- # warn( Data::Dumper->Dump( [ $messaging_options ], [ 'messaging_options' ] ) );
- OPTION: foreach my $option ( @$messaging_options ) {
- # warn( Data::Dumper->Dump( [ $option ], [ 'option' ] ) );
- my $updater = { borrowernumber => $borrower->{'borrowernumber'},
- message_attribute_id => $option->{'message_attribute_id'} };
-
- # find the desired transports
- @{$updater->{'message_transport_types'}} = $query->param( $option->{'message_attribute_id'} );
- next OPTION unless $updater->{'message_transport_types'};
-
- if ( $option->{'has_digest'} ) {
- if ( List::Util::first { $_ == $option->{'message_attribute_id'} } $query->param( 'digest' ) ) {
- $updater->{'wants_digest'} = 1;
- }
- }
-
- if ( $option->{'takes_days'} ) {
- if ( defined $query->param( $option->{'message_attribute_id'} . '-DAYS' ) ) {
- $updater->{'days_in_advance'} = $query->param( $option->{'message_attribute_id'} . '-DAYS' );
- }
- }
-
- warn( 'calling SetMessaginPreferencse with ' . Data::Dumper->Dump( [ $updater ], [ 'updater' ] ) );
- C4::Members::Messaging::SetMessagingPreference( $updater );
- }