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-confirmation.tt (-10 / +22 lines)
Lines 61-69 Link Here
61
                    <div id="registration-complete">
61
                    <div id="registration-complete">
62
                        <h1>Registration complete!</h1>
62
                        <h1>Registration complete!</h1>
63
63
64
                        <p>You have successfully registered your new account.</p>
64
                        [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %]
65
                            <p>You have successfully registered this new account.</p>
66
                        [% ELSE %]
67
                            <p>You have successfully registered your new account.</p>
68
                        [% END %]
69
65
                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %]
70
                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %]
66
                            <p>To log in, use the following credentials:</p>
71
                            [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %]
72
                                <p>Please securely provide the following credentials to the account holder so they can log in:</p>
73
                            [% ELSE %]
74
                                <p>To log in, use the following credentials:</p>
75
                            [% END %]
67
76
68
                            <p id="patron-userid-p" class="registration-line">
77
                            <p id="patron-userid-p" class="registration-line">
69
                                <span id="patron-userid-label" class="registration-label">Username:</span>
78
                                <span id="patron-userid-label" class="registration-label">Username:</span>
Lines 81-93 Link Here
81
                                </p>
90
                                </p>
82
                            [% END %]
91
                            [% END %]
83
92
84
                            <p id="patron-instructions">
93
                            [% UNLESS Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %]
85
                            [% IF borrower.category.effective_change_password %]
94
                                <p id="patron-instructions">
86
                                <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span>
95
                                [% IF borrower.category.effective_change_password %]
87
                            [% ELSE %]
96
                                    <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span>
88
                                <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span>
97
                                [% ELSE %]
98
                                    <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span>
99
                                [% END %]
100
                                </p>
89
                            [% END %]
101
                            [% END %]
90
                            </p>
102
91
                        [% END %]
103
                        [% END %]
92
104
93
                        [% IF ( PatronSelfRegistrationAdditionalInstructions ) %]
105
                        [% IF ( PatronSelfRegistrationAdditionalInstructions ) %]
Lines 110-122 Link Here
110
                                    <fieldset class="brief">
122
                                    <fieldset class="brief">
111
                                        <legend>Log in to your account:</legend>
123
                                        <legend>Log in to your account:</legend>
112
                                        <label for="userid">Login:</label>
124
                                        <label for="userid">Login:</label>
113
                                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %]
125
                                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') && Koha.Preference('PatronSelfRegistrationVerifyByEmail') != "library" %]
114
                                            <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="[% borrower.userid | html %]" autocomplete="off" />
126
                                            <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="[% borrower.userid | html %]" autocomplete="off" />
115
                                        [% ELSE %]
127
                                        [% ELSE %]
116
                                            <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="" autocomplete="off" />
128
                                            <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="" autocomplete="off" />
117
                                        [% END %]
129
                                        [% END %]
118
                                        <label for="password">Password:</label>
130
                                        <label for="password">Password:</label>
119
                                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %]
131
                                        [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') && Koha.Preference('PatronSelfRegistrationVerifyByEmail') != "library" %]
120
                                            <input class="form-control" type="password" id="password" size="10" name="login_password" value="[% password_cleartext | html %]" autocomplete="off" />
132
                                            <input class="form-control" type="password" id="password" size="10" name="login_password" value="[% password_cleartext | html %]" autocomplete="off" />
121
                                        [% ELSE %]
133
                                        [% ELSE %]
122
                                            <input class="form-control" type="password" id="password" size="10" name="login_password" value="" autocomplete="off" />
134
                                            <input class="form-control" type="password" id="password" size="10" name="login_password" value="" autocomplete="off" />
(-)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