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

(-)a/Koha/Patron.pm (-9 / +12 lines)
Lines 2796-2811 sub notify_library_of_registration { Link Here
2796
                || C4::Context->preference('KohaAdminEmailAddress');
2796
                || C4::Context->preference('KohaAdminEmailAddress');
2797
        }
2797
        }
2798
2798
2799
        my $message_id = C4::Letters::EnqueueLetter(
2799
        unless ( C4::Context->preference("PatronSelfRegistrationVerifyByEmail") eq "library" ) {
2800
            {
2800
            # Only receive one of the OPAC_REG or OPAC_REG_VERIFY_LIB emails
2801
                letter                 => $letter,
2801
            my $message_id = C4::Letters::EnqueueLetter(
2802
                borrowernumber         => $self->borrowernumber,
2802
                {
2803
                to_address             => $to_address,
2803
                    letter                 => $letter,
2804
                message_transport_type => 'email'
2804
                    borrowernumber         => $self->borrowernumber,
2805
                    to_address             => $to_address,
2806
                    message_transport_type => 'email'
2807
                }
2808
            ) or warn "can't enqueue letter $letter";
2809
            if ($message_id) {
2810
                return 1;
2805
            }
2811
            }
2806
        ) or warn "can't enqueue letter $letter";
2807
        if ( $message_id ) {
2808
            return 1;
2809
        }
2812
        }
2810
    }
2813
    }
2811
}
2814
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt (-5 / +13 lines)
Lines 29-41 Link Here
29
                    <div class="col order-first order-md-first order-lg-2">
29
                    <div class="col order-first order-md-first order-lg-2">
30
                [% END %]
30
                [% END %]
31
                    <div id="registration-confirmation-pending" class="maincontent">
31
                    <div id="registration-confirmation-pending" class="maincontent">
32
                        <h1>Please confirm your registration</h1>
32
                        [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %]
33
                        <div id="confirmation-pending" class="alert alert-info">
33
                            <h1>Your account is pending confirmation</h1>
34
                            <div id="confirmation-pending" class="alert alert-info">
34
35
35
                            <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p>
36
                                <p>An email has been sent to the library to confirm the activation of your account.</p>
37
                            </div> <!-- /#confirmation-pending -->
38
                        [% ELSE %]
39
                            <h1>Please confirm your registration</h1>
40
                            <div id="confirmation-pending" class="alert alert-info">
36
41
37
                            <p>Your account will not be activated until you follow the link provided in the confirmation email.</p>
42
                                <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p>
38
                        </div> <!-- /#confirmation-pending -->
43
44
                                <p>Your account will not be activated until you follow the link provided in the confirmation email.</p>
45
                            </div> <!-- /#confirmation-pending -->
46
                        [% END %]
39
                    </div> <!-- /#registration-confirmation-pending -->
47
                    </div> <!-- /#registration-confirmation-pending -->
40
                </div> <!-- /.col/10 -->
48
                </div> <!-- /.col/10 -->
41
            </div> <!-- /.row -->
49
            </div> <!-- /.row -->
(-)a/opac/opac-memberentry.pl (-29 / +67 lines)
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
- 

Return to bug 25090