Lines 177-187
if ( $op eq 'cud-create' ) {
Link Here
|
177 |
die "Branchcode not allowed"; # They hack the form |
177 |
die "Branchcode not allowed"; # They hack the form |
178 |
} |
178 |
} |
179 |
else { |
179 |
else { |
180 |
if ( |
180 |
if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') ne "off" ) { |
181 |
C4::Context->preference( |
|
|
182 |
'PatronSelfRegistrationVerifyByEmail') |
183 |
) |
184 |
{ |
185 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
181 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
186 |
{ |
182 |
{ |
187 |
template_name => "opac-registration-email-sent.tt", |
183 |
template_name => "opac-registration-email-sent.tt", |
Lines 190-227
if ( $op eq 'cud-create' ) {
Link Here
|
190 |
authnotrequired => 1, |
186 |
authnotrequired => 1, |
191 |
} |
187 |
} |
192 |
); |
188 |
); |
193 |
$template->param( 'email' => $borrower{'email'} ); |
189 |
$template->param( 'email' => $borrower{'email'} ) |
|
|
190 |
if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "patron" ); |
194 |
|
191 |
|
195 |
my $verification_token = md5_hex( time().{}.rand().{}.$$ ); |
192 |
my $verification_token = md5_hex( time() . {} . rand() . {} . $$ ); |
196 |
while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { |
193 |
while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { |
197 |
$verification_token = md5_hex( time().{}.rand().{}.$$ ); |
194 |
$verification_token = md5_hex( time() . {} . rand() . {} . $$ ); |
198 |
} |
195 |
} |
199 |
|
196 |
|
200 |
$borrower{password} = Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($borrower{categorycode})) unless $borrower{password}; |
197 |
$borrower{password} = |
|
|
198 |
Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $borrower{categorycode} ) ) |
199 |
unless $borrower{password}; |
201 |
$borrower{verification_token} = $verification_token; |
200 |
$borrower{verification_token} = $verification_token; |
202 |
|
201 |
|
203 |
$borrower{extended_attributes} = to_json($attributes); |
202 |
$borrower{extended_attributes} = to_json($attributes); |
204 |
Koha::Patron::Modification->new( \%borrower )->store(); |
203 |
Koha::Patron::Modification->new( \%borrower )->store(); |
205 |
|
204 |
|
206 |
#Send verification email |
205 |
my $message_id; |
207 |
my $letter = C4::Letters::GetPreparedLetter( |
206 |
|
208 |
module => 'members', |
207 |
if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "library" ) { |
209 |
letter_code => 'OPAC_REG_VERIFY', |
208 |
|
210 |
lang => 'default', # Patron does not have a preferred language defined yet |
209 |
#Send verification email |
211 |
tables => { |
210 |
my $letter = C4::Letters::GetPreparedLetter( |
212 |
borrower_modifications => $verification_token, |
211 |
module => 'members', |
213 |
}, |
212 |
letter_code => 'OPAC_REG_VERIFY_LIB', |
214 |
); |
213 |
lang => 'default', # Patron does not have a preferred language defined yet |
215 |
|
214 |
tables => { |
216 |
my $message_id = C4::Letters::EnqueueLetter( |
215 |
'borrower_modifications' => $verification_token, |
217 |
{ |
216 |
}, |
218 |
letter => $letter, |
217 |
); |
219 |
message_transport_type => 'email', |
218 |
|
220 |
to_address => $borrower{'email'}, |
219 |
my $email_patron_registrations = C4::Context->preference('EmailPatronRegistrations'); |
221 |
from_address => |
220 |
my $to_address; |
222 |
C4::Context->preference('KohaAdminEmailAddress'), |
221 |
if ( $email_patron_registrations eq "BranchEmailAddress" ) { |
|
|
222 |
my $library = Koha::Libraries->find( $borrower{branchcode} ); |
223 |
$to_address = $library->inbound_email_address; |
224 |
} elsif ( $email_patron_registrations eq "KohaAdminEmailAddress" ) { |
225 |
$to_address = C4::Context->preference('ReplytoDefault') |
226 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
227 |
} else { |
228 |
$to_address = |
229 |
C4::Context->preference('EmailAddressForPatronRegistrations') |
230 |
|| C4::Context->preference('ReplytoDefault') |
231 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
223 |
} |
232 |
} |
224 |
); |
233 |
|
|
|
234 |
$message_id = C4::Letters::EnqueueLetter( |
235 |
{ |
236 |
letter => $letter, |
237 |
message_transport_type => 'email', |
238 |
to_address => $to_address, |
239 |
from_address => C4::Context->preference('KohaAdminEmailAddress'), |
240 |
} |
241 |
); |
242 |
|
243 |
} else { |
244 |
|
245 |
#Send verification email |
246 |
my $letter = C4::Letters::GetPreparedLetter( |
247 |
module => 'members', |
248 |
letter_code => 'OPAC_REG_VERIFY', |
249 |
lang => 'default', # Patron does not have a preferred language defined yet |
250 |
tables => { |
251 |
borrower_modifications => $verification_token, |
252 |
}, |
253 |
); |
254 |
|
255 |
$message_id = C4::Letters::EnqueueLetter( |
256 |
{ |
257 |
letter => $letter, |
258 |
message_transport_type => 'email', |
259 |
to_address => $borrower{'email'}, |
260 |
from_address => C4::Context->preference('KohaAdminEmailAddress'), |
261 |
} |
262 |
); |
263 |
} |
225 |
C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; |
264 |
C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; |
226 |
} |
265 |
} |
227 |
else { |
266 |
else { |
Lines 444-450
sub GetMandatoryFields {
Link Here
|
444 |
if ( $op eq 'cud-create' || $op eq 'new' ) { |
483 |
if ( $op eq 'cud-create' || $op eq 'new' ) { |
445 |
$mandatory_fields{'email'} = 1 |
484 |
$mandatory_fields{'email'} = 1 |
446 |
if C4::Context->preference( |
485 |
if C4::Context->preference( |
447 |
'PatronSelfRegistrationVerifyByEmail'); |
486 |
'PatronSelfRegistrationVerifyByEmail') eq "patron"; |
448 |
} |
487 |
} |
449 |
|
488 |
|
450 |
return \%mandatory_fields; |
489 |
return \%mandatory_fields; |
451 |
- |
|
|