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

(-)a/C4/Letters.pm (-1 / +3 lines)
Lines 1257-1263 sub _send_message_by_email { Link Here
1257
1257
1258
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1258
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1259
    my $to_address = $message->{'to_address'};
1259
    my $to_address = $message->{'to_address'};
1260
    unless ($to_address) {
1260
1261
    my $use_garantor = C4::Context->preference('RedirectGuaranteeEmail');
1262
    if($use_garantor || !$to_address) {
1261
        unless ($patron) {
1263
        unless ($patron) {
1262
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1264
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1263
            _set_message_status( { message_id => $message->{'message_id'},
1265
            _set_message_status( { message_id => $message->{'message_id'},
(-)a/Koha/Patron.pm (-2 / +16 lines)
Lines 756-769 Returns the empty string if no email address. Link Here
756
756
757
sub notice_email_address{
757
sub notice_email_address{
758
    my ( $self ) = @_;
758
    my ( $self ) = @_;
759
    my $address;
759
760
760
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
761
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
761
    # if syspref is set to 'first valid' (value == OFF), look up email address
762
    # if syspref is set to 'first valid' (value == OFF), look up email address
762
    if ( $which_address eq 'OFF' ) {
763
    if ( $which_address eq 'OFF' ) {
763
        return $self->first_valid_email_address;
764
        $address = $self->first_valid_email_address;
765
    } else {
766
        $address = $self->$which_address || '';
764
    }
767
    }
765
768
766
    return $self->$which_address || '';
769
    my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail');
770
    if ($use_guarantor) {
771
        my $guarantor = $self->guarantor;
772
        if ($guarantor) {
773
            my $guarantor_address = $guarantor->notice_email_address;
774
            if ($address){
775
            $address .= ', ';
776
            }
777
            $address .=  $guarantor_address if $guarantor_address;
778
        }
779
    }
780
    return $address;
767
}
781
}
768
782
769
=head3 first_valid_email_address
783
=head3 first_valid_email_address
(-)a/installer/data/mysql/atomicupdate/bug_12532-RedirectGuaranteeEmail_syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
2
VALUES ('RedirectGuaranteeEmail','0',NULL,'Enable the ability to redirect guarantee email messages to guarantor.','YesNo');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 452-457 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
452
('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'),
452
('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'),
453
('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
453
('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
454
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
454
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
455
('RedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
455
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
456
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
456
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
457
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
457
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
458
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 206-211 Patrons: Link Here
206
               no: Allow all permitted users
206
               no: Allow all permitted users
207
         - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
207
         - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
208
208
209
    -
210
         - pref: RedirectGuaranteeEmail
211
           choices:
212
               yes: Enable
213
               no: Disable
214
         - sending emails to both guarantees and their guarantor. This does not affect patrons without guarantors.
209
    "Norwegian patron database":
215
    "Norwegian patron database":
210
     -
216
     -
211
         - pref: NorwegianPatronDBEnable
217
         - pref: NorwegianPatronDBEnable
(-)a/t/db_dependent/Members.t (-2 / +37 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 51;
20
use Test::More tests => 54;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 138-143 C4::Context->clear_syspref_cache(); Link Here
138
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
138
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
139
is ($checkcardnum, "2", "Card number is too long");
139
is ($checkcardnum, "2", "Card number is too long");
140
140
141
# Test notice_email_address
142
# Add Guarantor for testing
143
my $GUARANTOR_EMAIL = "Robert\@email.com";
144
%data = (
145
    cardnumber => "2997924548",
146
    firstname =>  "Robert",
147
    surname => "Tables",
148
    categorycode => $patron_category->{categorycode},
149
    branchcode => $BRANCHCODE,
150
    dateofbirth => '',
151
    dateexpiry => '9999-12-31',
152
    userid => 'bobbytables',
153
    email => $GUARANTOR_EMAIL
154
);
155
$member->{guarantorid} = AddMember( %data );
156
ModMember( %$member );
157
158
$member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } );
159
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' );
160
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
161
C4::Context->clear_syspref_cache();
162
163
my $notice_email = $member->notice_email_address;
164
is ($notice_email, $EMAIL, "notice_email_address returns correct value when AutoEmailPrimaryAddress is off");
165
166
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
167
C4::Context->clear_syspref_cache();
168
169
$notice_email = $member->notice_email_address;
170
is ($notice_email, $EMAILPRO, "notice_email_address returns correct value when AutoEmailPrimaryAddress is emailpro");
171
172
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
173
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' );
174
C4::Context->clear_syspref_cache();
175
$notice_email = $member->notice_email_address;
176
is ($notice_email, $EMAIL . ", " . $GUARANTOR_EMAIL, "notice_email_address returns correct value when RedirectGuaranteeEmail is enabled");
141
177
142
# Add a new borrower
178
# Add a new borrower
143
%data = (
179
%data = (
144
- 

Return to bug 12532