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

(-)a/C4/Letters.pm (-14 / +16 lines)
Lines 926-948 sub _send_message_by_email { Link Here
926
926
927
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
927
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
928
    my $to_address = $message->{'to_address'};
928
    my $to_address = $message->{'to_address'};
929
    unless ($to_address) {
929
930
        unless ($member) {
930
    if ($member) {
931
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
931
        my $guarantorid = $member->{'guarantorid'};
932
            _set_message_status( { message_id => $message->{'message_id'},
932
        if ($guarantorid){
933
                                   status     => 'failed' } );
933
                $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
934
            return;
934
        } else {
935
        }
935
            unless ($to_address) {
936
        $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
936
                $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
937
        unless ($to_address) {  
937
            }
938
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
939
            # warning too verbose for this more common case?
940
            _set_message_status( { message_id => $message->{'message_id'},
941
                                   status     => 'failed' } );
942
            return;
943
        }
938
        }
944
    }
939
    }
945
940
941
    unless ($to_address) {
942
         warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
943
         _set_message_status( { message_id => $message->{'message_id'},
944
                               status     => 'failed' } );
945
         return;
946
    }
947
946
    my $utf8   = decode('MIME-Header', $message->{'subject'} );
948
    my $utf8   = decode('MIME-Header', $message->{'subject'} );
947
    $message->{subject}= encode('MIME-Header', $utf8);
949
    $message->{subject}= encode('MIME-Header', $utf8);
948
    my $subject = encode('utf8', $message->{'subject'});
950
    my $subject = encode('utf8', $message->{'subject'});
(-)a/C4/Members.pm (-12 / +20 lines)
Lines 1500-1521 Returns the empty string if no email address. Link Here
1500
1500
1501
sub GetNoticeEmailAddress {
1501
sub GetNoticeEmailAddress {
1502
    my $borrowernumber = shift;
1502
    my $borrowernumber = shift;
1503
    my $dbh = C4::Context->dbh();
1504
1505
    my $member = C4::Members::GetMember( 'borrowernumber' => $borrowernumber );
1506
    my $guarantorid = $member->{'guarantorid'};
1507
    my $borrowerNumberToSendEmail = $guarantorid ? $guarantorid : $borrowernumber;
1508
1509
    my $enableRedirectGuaranteeEmail =  C4::Context->preference("EnableRedirectGuaranteeEmail");
1510
    if (!$enableRedirectGuaranteeEmail){
1511
        $borrowerNumberToSendEmail = $borrowernumber;
1512
        $guarantorid = undef;
1513
    }
1503
1514
1504
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1515
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1505
    # if syspref is set to 'first valid' (value == OFF), look up email address
1516
    # if syspref is set to 'first valid' (value == OFF), look up email address
1517
    my $to_address = $member->{$which_address};
1506
    if ( $which_address eq 'OFF' ) {
1518
    if ( $which_address eq 'OFF' ) {
1507
        return GetFirstValidEmailAddress($borrowernumber);
1519
        $to_address = GetFirstValidEmailAddress($borrowerNumberToSendEmail);
1508
    }
1520
    } elsif( $guarantorid ) {
1509
    # specified email address field
1521
        my $guarantor = C4::Members::GetMember( 'borrowernumber' => $guarantorid );
1510
    my $dbh = C4::Context->dbh;
1522
        if ( $guarantor ){
1511
    my $sth = $dbh->prepare( qq{
1523
            $to_address = $guarantor->{ $which_address };
1512
        SELECT $which_address AS primaryemail
1524
        }
1513
        FROM borrowers
1525
   }
1514
        WHERE borrowernumber=?
1526
   return $to_address || '';
1515
    } );
1516
    $sth->execute($borrowernumber);
1517
    my $data = $sth->fetchrow_hashref;
1518
    return $data->{'primaryemail'} || '';
1519
}
1527
}
1520
1528
1521
=head2 GetExpiryDate 
1529
=head2 GetExpiryDate 
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 111-116 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
111
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
111
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
112
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
112
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
113
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
113
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
114
('EnableRedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
114
('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
115
('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
115
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
116
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
116
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
117
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 8603-8608 if ( CheckVersion($DBversion) ) { Link Here
8603
    SetVersion($DBversion);
8603
    SetVersion($DBversion);
8604
}
8604
}
8605
8605
8606
$DBversion = "XXX";
8607
if ( CheckVersion($DBversion) ) {
8608
   $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('EnableRedirectGuaranteeEmail','0',NULL,'Enable the ability to redirect guarantee email messages to guarantor.','YesNo')");
8609
   print "Upgrade to $DBversion done (Bug 12532 - Redirect guarantee email to guarantor)\n";
8610
   SetVersion($DBversion);
8611
}
8612
8606
=head1 FUNCTIONS
8613
=head1 FUNCTIONS
8607
8614
8608
=head2 TableExists($table)
8615
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +6 lines)
Lines 138-140 Patrons: Link Here
138
         - pref: CardnumberLength
138
         - pref: CardnumberLength
139
         - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
139
         - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
140
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
140
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
141
- 
141
     -
142
         - pref: EnableRedirectGuaranteeEmail
143
           choices:
144
               yes: Do
145
               no: "Don't"
146
         - enable the ability to redirect guarantee email messages to guarantor. All email message placed in message_queue table will be affected.

Return to bug 12532