Lines 102-110
sub GetValidLinkInfo {
Link Here
|
102 |
=cut |
102 |
=cut |
103 |
|
103 |
|
104 |
sub SendPasswordRecoveryEmail { |
104 |
sub SendPasswordRecoveryEmail { |
105 |
my $borrower = shift; # from GetMember |
105 |
my $borrower = shift; # Koha::Borrower |
106 |
my $userEmail = shift; #to_address (the one specified in the request) |
106 |
my $userEmail = shift; #to_address (the one specified in the request) |
107 |
my $protocol = shift; #only required to determine if 'http' or 'https' |
|
|
108 |
my $update = shift; |
107 |
my $update = shift; |
109 |
|
108 |
|
110 |
my $schema = Koha::Database->new->schema; |
109 |
my $schema = Koha::Database->new->schema; |
Lines 119-144
sub SendPasswordRecoveryEmail {
Link Here
|
119 |
if($update){ |
118 |
if($update){ |
120 |
my $rs = $schema->resultset('BorrowerPasswordRecovery')->search( |
119 |
my $rs = $schema->resultset('BorrowerPasswordRecovery')->search( |
121 |
{ |
120 |
{ |
122 |
borrowernumber => $borrower->{'borrowernumber'}, |
121 |
borrowernumber => $borrower->borrowernumber, |
123 |
}); |
122 |
}); |
124 |
$rs->update({uuid => $uuid_str, valid_until => $expirydate->datetime()}); |
123 |
$rs->update({uuid => $uuid_str, valid_until => $expirydate->datetime()}); |
125 |
} else { |
124 |
} else { |
126 |
my $rs = $schema->resultset('BorrowerPasswordRecovery')->create({ |
125 |
my $rs = $schema->resultset('BorrowerPasswordRecovery')->create({ |
127 |
borrowernumber=>$borrower->{'borrowernumber'}, |
126 |
borrowernumber=>$borrower->borrowernumber, |
128 |
uuid => $uuid_str, |
127 |
uuid => $uuid_str, |
129 |
valid_until=> $expirydate->datetime() |
128 |
valid_until=> $expirydate->datetime() |
130 |
}); |
129 |
}); |
131 |
} |
130 |
} |
132 |
|
131 |
|
133 |
# create link |
132 |
# create link |
134 |
my $uuidLink = $protocol . C4::Context->preference( 'OPACBaseURL' ) . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str"; |
133 |
my $uuidLink = C4::Context->preference( 'OPACBaseURL' ) . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str"; |
135 |
|
134 |
|
136 |
# prepare the email |
135 |
# prepare the email |
137 |
my $letter = C4::Letters::GetPreparedLetter ( |
136 |
my $letter = C4::Letters::GetPreparedLetter ( |
138 |
module => 'members', |
137 |
module => 'members', |
139 |
letter_code => 'PASSWORD_RESET', |
138 |
letter_code => 'PASSWORD_RESET', |
140 |
branchcode => $borrower->{branchcode}, |
139 |
branchcode => $borrower->branchcode, |
141 |
substitute => {passwordreseturl => $uuidLink, user => $borrower->{userid} }, |
140 |
substitute => {passwordreseturl => $uuidLink, user => $borrower->userid }, |
142 |
); |
141 |
); |
143 |
|
142 |
|
144 |
# define to/from emails |
143 |
# define to/from emails |
Lines 146-152
sub SendPasswordRecoveryEmail {
Link Here
|
146 |
|
145 |
|
147 |
C4::Letters::EnqueueLetter( { |
146 |
C4::Letters::EnqueueLetter( { |
148 |
letter => $letter, |
147 |
letter => $letter, |
149 |
borrowernumber => $borrower->{borrowernumber}, |
148 |
borrowernumber => $borrower->borrowernumber, |
150 |
to_address => $userEmail, |
149 |
to_address => $userEmail, |
151 |
from_address => $kohaEmail, |
150 |
from_address => $kohaEmail, |
152 |
message_transport_type => 'email', |
151 |
message_transport_type => 'email', |