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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2611-2617 sub SendCirculationAlert { Link Here
2611
    C4::Letters::parseletter($letter, 'biblioitems', $item->{biblionumber});
2611
    C4::Letters::parseletter($letter, 'biblioitems', $item->{biblionumber});
2612
    C4::Letters::parseletter($letter, 'borrowers',   $borrower->{borrowernumber});
2612
    C4::Letters::parseletter($letter, 'borrowers',   $borrower->{borrowernumber});
2613
    C4::Letters::parseletter($letter, 'branches',    $branch);
2613
    C4::Letters::parseletter($letter, 'branches',    $branch);
2614
    my @transports = @{ $borrower_preferences->{transports} };
2614
    my @transports = keys %{ $borrower_preferences->{transports} };
2615
    # warn "no transports" unless @transports;
2615
    # warn "no transports" unless @transports;
2616
    for (@transports) {
2616
    for (@transports) {
2617
        # warn "transport: $_";
2617
        # warn "transport: $_";
(-)a/C4/Form/MessagingPreferences.pm (-1 / +1 lines)
Lines 139-145 sub set_form_values { Link Here
139
                selected   => $_ == $days_in_advance ? 'selected="selected"' :'' } 
139
                selected   => $_ == $days_in_advance ? 'selected="selected"' :'' } 
140
            } ( 0..30 ); # FIXME: 30 is a magic number.
140
            } ( 0..30 ); # FIXME: 30 is a magic number.
141
        }
141
        }
142
        foreach my $transport ( @{$pref->{'transports'}} ) {
142
        foreach my $transport ( keys %{$pref->{'transports'}} ) {
143
            $option->{'transports_'.$transport} = 1;
143
            $option->{'transports_'.$transport} = 1;
144
        }
144
        }
145
        $option->{'digest'} = 1 if $pref->{'wants_digest'};
145
        $option->{'digest'} = 1 if $pref->{'wants_digest'};
(-)a/C4/Members/Messaging.pm (-3 / +3 lines)
Lines 98-106 END_SQL Link Here
98
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
98
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
99
        $return->{'wants_digest'}    = $row->{'wants_digest'}    if defined $row->{'wants_digest'};
99
        $return->{'wants_digest'}    = $row->{'wants_digest'}    if defined $row->{'wants_digest'};
100
        $return->{'letter_code'}     = $row->{'letter_code'};
100
        $return->{'letter_code'}     = $row->{'letter_code'};
101
        $transports{$row->{'message_transport_type'}} = 1;
101
        $return->{'transports'}->{ $row->{'message_transport_type'} } = $row->{'letter_code'};
102
    }
102
    }
103
    @{$return->{'transports'}} = keys %transports;
104
    return $return;
103
    return $return;
105
}
104
}
106
105
Lines 248-255 sub SetMessagingPreferencesFromDefaults { Link Here
248
        # FIXME - except for setting the borrowernumber, it really ought to be possible
247
        # FIXME - except for setting the borrowernumber, it really ought to be possible
249
        # to have the output of GetMessagingPreferences be able to be the input
248
        # to have the output of GetMessagingPreferences be able to be the input
250
        # to SetMessagingPreference
249
        # to SetMessagingPreference
250
        my @message_transport_types = keys %{ $default_pref->{transports} };
251
        $default_pref->{message_attribute_id}    = $option->{'message_attribute_id'};
251
        $default_pref->{message_attribute_id}    = $option->{'message_attribute_id'};
252
        $default_pref->{message_transport_types} = $default_pref->{transports};
252
        $default_pref->{message_transport_types} = \@message_transport_types;
253
        $default_pref->{borrowernumber}          = $params->{borrowernumber};
253
        $default_pref->{borrowernumber}          = $params->{borrowernumber};
254
        SetMessagingPreference( $default_pref );
254
        SetMessagingPreference( $default_pref );
255
    }
255
    }
(-)a/C4/Reserves.pm (-17 / +49 lines)
Lines 1720-1742 sub _koha_notify_reserve { Link Here
1720
1720
1721
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1721
    my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
1722
1722
1723
    my $letter = getletter( 'reserves', $letter_code );
1724
    die "Could not find a letter called '$letter_code' in the 'reserves' module" unless( $letter );
1725
1723
1726
    C4::Letters::parseletter( $letter, 'branches', $reserve->{'branchcode'} );
1724
    if ( $print_mode ) {
1727
    C4::Letters::parseletter( $letter, 'borrowers', $borrowernumber );
1725
        my $letter = getletter( 'reserves', 'HOLD_PRINT' );
1728
    C4::Letters::parseletter( $letter, 'biblio', $biblionumber );
1726
        die "Could not find a letter called '$letter_code' in the 'reserves' module" unless( $letter );
1729
    C4::Letters::parseletter( $letter, 'reserves', $borrowernumber, $biblionumber );
1730
1727
1731
    if ( $reserve->{'itemnumber'} ) {
1728
        C4::Letters::parseletter( $letter, 'branches', $reserve->{'branchcode'} );
1732
        C4::Letters::parseletter( $letter, 'items', $reserve->{'itemnumber'} );
1729
        C4::Letters::parseletter( $letter, 'borrowers', $borrowernumber );
1733
    }
1730
        C4::Letters::parseletter( $letter, 'biblio', $biblionumber );
1734
    my $today = C4::Dates->new()->output();
1731
        C4::Letters::parseletter( $letter, 'reserves', $borrowernumber, $biblionumber );
1735
    $letter->{'title'} =~ s/<<today>>/$today/g;
1732
1736
    $letter->{'content'} =~ s/<<today>>/$today/g;
1733
        if ( $reserve->{'itemnumber'} ) {
1737
    $letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers
1734
            C4::Letters::parseletter( $letter, 'items', $reserve->{'itemnumber'} );
1735
        }
1736
        my $today = C4::Dates->new()->output();
1737
        $letter->{'title'} =~ s/<<today>>/$today/g;
1738
        $letter->{'content'} =~ s/<<today>>/$today/g;
1739
        $letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers
1738
1740
1739
    if ( $print_mode ) {
1740
        C4::Letters::EnqueueLetter( {
1741
        C4::Letters::EnqueueLetter( {
1741
            letter => $letter,
1742
            letter => $letter,
1742
            borrowernumber => $borrowernumber,
1743
            borrowernumber => $borrowernumber,
Lines 1746-1753 sub _koha_notify_reserve { Link Here
1746
        return;
1747
        return;
1747
    }
1748
    }
1748
1749
1749
    if ( grep { $_ eq 'email' } @{$messagingprefs->{transports}} ) {
1750
    if ( defined $messagingprefs->{transports}->{'email'} ) {
1750
        # aka, 'email' in ->{'transports'}
1751
        my $letter = getletter( 'reserves', $messagingprefs->{transports}->{'email'} );
1752
        die "Could not find a letter called '$messagingprefs->{transports}->{'email'}' in the 'reserves' module" unless( $messagingprefs->{transports}->{'email'} );
1753
1754
        C4::Letters::parseletter( $letter, 'branches', $reserve->{'branchcode'} );
1755
        C4::Letters::parseletter( $letter, 'borrowers', $borrowernumber );
1756
        C4::Letters::parseletter( $letter, 'biblio', $biblionumber );
1757
        C4::Letters::parseletter( $letter, 'reserves', $borrowernumber, $biblionumber );
1758
1759
        if ( $reserve->{'itemnumber'} ) {
1760
            C4::Letters::parseletter( $letter, 'items', $reserve->{'itemnumber'} );
1761
        }
1762
        my $today = C4::Dates->new()->output();
1763
        $letter->{'title'} =~ s/<<today>>/$today/g;
1764
        $letter->{'content'} =~ s/<<today>>/$today/g;
1765
        $letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers
1766
1751
        C4::Letters::EnqueueLetter(
1767
        C4::Letters::EnqueueLetter(
1752
            {   letter                 => $letter,
1768
            {   letter                 => $letter,
1753
                borrowernumber         => $borrowernumber,
1769
                borrowernumber         => $borrowernumber,
Lines 1757-1763 sub _koha_notify_reserve { Link Here
1757
        );
1773
        );
1758
    }
1774
    }
1759
1775
1760
    if ( grep { $_ eq 'sms' } @{$messagingprefs->{transports}} ) {
1776
    if ( defined $messagingprefs->{transports}->{'sms'} ) {
1777
        my $letter = getletter( 'reserves', $messagingprefs->{transports}->{'sms'} );
1778
        die "Could not find a letter called '$messagingprefs->{transports}->{'sms'}' in the 'reserves' module" unless( $messagingprefs->{transports}->{'sms'} );
1779
1780
        C4::Letters::parseletter( $letter, 'branches', $reserve->{'branchcode'} );
1781
        C4::Letters::parseletter( $letter, 'borrowers', $borrowernumber );
1782
        C4::Letters::parseletter( $letter, 'biblio', $biblionumber );
1783
        C4::Letters::parseletter( $letter, 'reserves', $borrowernumber, $biblionumber );
1784
1785
        if ( $reserve->{'itemnumber'} ) {
1786
            C4::Letters::parseletter( $letter, 'items', $reserve->{'itemnumber'} );
1787
        }
1788
        my $today = C4::Dates->new()->output();
1789
        $letter->{'title'} =~ s/<<today>>/$today/g;
1790
        $letter->{'content'} =~ s/<<today>>/$today/g;
1791
        $letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers
1792
1761
        C4::Letters::EnqueueLetter(
1793
        C4::Letters::EnqueueLetter(
1762
            {   letter                 => $letter,
1794
            {   letter                 => $letter,
1763
                borrowernumber         => $borrowernumber,
1795
                borrowernumber         => $borrowernumber,
(-)a/admin/categorie.pl (-1 / +1 lines)
Lines 249-255 sub _get_brief_messaging_prefs { Link Here
249
            message_name            => $option->{'message_name'},
249
            message_name            => $option->{'message_name'},
250
            $option->{'message_name'} => 1
250
            $option->{'message_name'} => 1
251
        };
251
        };
252
        foreach my $transport ( @{$pref->{'transports'}} ) {
252
        foreach my $transport ( keys %{$pref->{'transports'}} ) {
253
            push @{ $brief_pref->{'transports'} }, { transport => $transport };
253
            push @{ $brief_pref->{'transports'} }, { transport => $transport };
254
        }
254
        }
255
        push @$results, $brief_pref;
255
        push @$results, $brief_pref;
(-)a/misc/cronjobs/advance_notices.pl (-4 / +3 lines)
Lines 215-221 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
215
        print $letter->{'content'};
215
        print $letter->{'content'};
216
      }
216
      }
217
      else {
217
      else {
218
        foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
218
        foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
219
            C4::Letters::EnqueueLetter( { letter                 => $letter,
219
            C4::Letters::EnqueueLetter( { letter                 => $letter,
220
                                          borrowernumber         => $upcoming->{'borrowernumber'},
220
                                          borrowernumber         => $upcoming->{'borrowernumber'},
221
                                          from_address           => $from_address,
221
                                          from_address           => $from_address,
Lines 270-276 PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { Link Here
270
      print $letter->{'content'};
270
      print $letter->{'content'};
271
    }
271
    }
272
    else {
272
    else {
273
      foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
273
      foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
274
        C4::Letters::EnqueueLetter( { letter                 => $letter,
274
        C4::Letters::EnqueueLetter( { letter                 => $letter,
275
                                      borrowernumber         => $borrowernumber,
275
                                      borrowernumber         => $borrowernumber,
276
                                      from_address           => $from_address,
276
                                      from_address           => $from_address,
Lines 310-316 PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { Link Here
310
      print $letter->{'content'};
310
      print $letter->{'content'};
311
    }
311
    }
312
    else {
312
    else {
313
      foreach my $transport ( @{$borrower_preferences->{'transports'}} ) {
313
      foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) {
314
        C4::Letters::EnqueueLetter( { letter                 => $letter,
314
        C4::Letters::EnqueueLetter( { letter                 => $letter,
315
                                      borrowernumber         => $borrowernumber,
315
                                      borrowernumber         => $borrowernumber,
316
                                      from_address           => $from_address,
316
                                      from_address           => $from_address,
317
- 

Return to bug 4246