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

(-)a/C4/Letters.pm (-14 / +16 lines)
Lines 1115-1137 sub _send_message_by_email { Link Here
1115
1115
1116
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1116
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1117
    my $to_address = $message->{'to_address'};
1117
    my $to_address = $message->{'to_address'};
1118
    unless ($to_address) {
1118
1119
        unless ($member) {
1119
    if ($member) {
1120
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1120
        my $guarantorid = $member->{'guarantorid'};
1121
            _set_message_status( { message_id => $message->{'message_id'},
1121
        if ($guarantorid){
1122
                                   status     => 'failed' } );
1122
                $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
1123
            return;
1123
        } else {
1124
        }
1124
            unless ($to_address) {
1125
        $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
1125
                $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} );
1126
        unless ($to_address) {  
1126
            }
1127
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
1128
            # warning too verbose for this more common case?
1129
            _set_message_status( { message_id => $message->{'message_id'},
1130
                                   status     => 'failed' } );
1131
            return;
1132
        }
1127
        }
1133
    }
1128
    }
1134
1129
1130
    unless ($to_address) {
1131
         warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1132
         _set_message_status( { message_id => $message->{'message_id'},
1133
                               status     => 'failed' } );
1134
         return;
1135
    }
1136
1135
    my $utf8   = decode('MIME-Header', $message->{'subject'} );
1137
    my $utf8   = decode('MIME-Header', $message->{'subject'} );
1136
    $message->{subject}= encode('MIME-Header', $utf8);
1138
    $message->{subject}= encode('MIME-Header', $utf8);
1137
    my $subject = encode('utf8', $message->{'subject'});
1139
    my $subject = encode('utf8', $message->{'subject'});
(-)a/C4/Members.pm (-12 / +20 lines)
Lines 1553-1574 Returns the empty string if no email address. Link Here
1553
1553
1554
sub GetNoticeEmailAddress {
1554
sub GetNoticeEmailAddress {
1555
    my $borrowernumber = shift;
1555
    my $borrowernumber = shift;
1556
    my $dbh = C4::Context->dbh();
1557
1558
    my $member = C4::Members::GetMember( 'borrowernumber' => $borrowernumber );
1559
    my $guarantorid = $member->{'guarantorid'};
1560
    my $borrowerNumberToSendEmail = $guarantorid ? $guarantorid : $borrowernumber;
1561
1562
    my $enableRedirectGuaranteeEmail =  C4::Context->preference("EnableRedirectGuaranteeEmail");
1563
    if (!$enableRedirectGuaranteeEmail){
1564
        $borrowerNumberToSendEmail = $borrowernumber;
1565
        $guarantorid = undef;
1566
    }
1556
1567
1557
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1568
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1558
    # if syspref is set to 'first valid' (value == OFF), look up email address
1569
    # if syspref is set to 'first valid' (value == OFF), look up email address
1570
    my $to_address = $member->{$which_address};
1559
    if ( $which_address eq 'OFF' ) {
1571
    if ( $which_address eq 'OFF' ) {
1560
        return GetFirstValidEmailAddress($borrowernumber);
1572
        $to_address = GetFirstValidEmailAddress($borrowerNumberToSendEmail);
1561
    }
1573
    } elsif( $guarantorid ) {
1562
    # specified email address field
1574
        my $guarantor = C4::Members::GetMember( 'borrowernumber' => $guarantorid );
1563
    my $dbh = C4::Context->dbh;
1575
        if ( $guarantor ){
1564
    my $sth = $dbh->prepare( qq{
1576
            $to_address = $guarantor->{ $which_address };
1565
        SELECT $which_address AS primaryemail
1577
        }
1566
        FROM borrowers
1578
   }
1567
        WHERE borrowernumber=?
1579
   return $to_address || '';
1568
    } );
1569
    $sth->execute($borrowernumber);
1570
    my $data = $sth->fetchrow_hashref;
1571
    return $data->{'primaryemail'} || '';
1572
}
1580
}
1573
1581
1574
=head2 GetExpiryDate 
1582
=head2 GetExpiryDate 
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 116-121 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
116
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
116
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
117
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
117
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
118
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
118
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
119
('EnableRedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
119
('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
120
('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
120
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
121
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
121
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
122
('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 9669-9674 if ( CheckVersion($DBversion) ) { Link Here
9669
    SetVersion ($DBversion);
9669
    SetVersion ($DBversion);
9670
}
9670
}
9671
9671
9672
$DBversion = "3.19.00.XXX";
9673
if ( CheckVersion($DBversion) ) {
9674
   $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')");
9675
   print "Upgrade to $DBversion done (Bug 12532 - Redirect guarantee email to guarantor)\n";
9676
   SetVersion($DBversion);
9677
}
9678
9672
=head1 FUNCTIONS
9679
=head1 FUNCTIONS
9673
9680
9674
=head2 TableExists($table)
9681
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +6 lines)
Lines 139-144 Patrons: Link Here
139
         - pref: CardnumberLength
139
         - pref: CardnumberLength
140
         - "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
         - "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')."
141
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
141
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
142
     -
143
         - pref: EnableRedirectGuaranteeEmail
144
           choices:
145
               yes: Do
146
               no: "Don't"
147
         - enable the ability to redirect guarantee email messages to guarantor. All email message placed in message_queue table will be affected.
142
    "Norwegian patron database":
148
    "Norwegian patron database":
143
     -
149
     -
144
         - pref: NorwegianPatronDBEnable
150
         - pref: NorwegianPatronDBEnable
145
- 

Return to bug 12532