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

(-)a/opac/opac-memberentry.pl (-14 / +66 lines)
Lines 158-166 if ( $action eq 'create' ) { Link Here
158
        $template->param( patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ) );
158
        $template->param( patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ) );
159
    }
159
    }
160
    else {
160
    else {
161
        my $patronverification = C4::Context->boolean_preference('PatronSelfRegistrationVerifyByEmailToPatron');
162
        my $libraryverification = C4::Context->preference('PatronSelfRegistrationVerifyByEmailToLibrary');
161
        if (
163
        if (
162
            C4::Context->boolean_preference(
164
            $patronverification
163
                'PatronSelfRegistrationVerifyByEmail')
165
            || $libraryverification
164
          )
166
          )
165
        {
167
        {
166
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
168
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 183-210 if ( $action eq 'create' ) { Link Here
183
185
184
            Koha::Patron::Modification->new( \%borrower )->store();
186
            Koha::Patron::Modification->new( \%borrower )->store();
185
187
186
            #Send verification email
188
            my $letter_code;
187
            my $letter = C4::Letters::GetPreparedLetter(
189
            my $action;
188
                module      => 'members',
190
            my $toaddress;
189
                letter_code => 'OPAC_REG_VERIFY',
191
            my $letter;
190
                lang        => 'default', # Patron does not have a preferred language defined yet
192
            if ($patronverification && !$libraryverification) {
191
                tables      => {
193
                $action = 'patrontoverify';
192
                    borrower_modifications => $verification_token,
194
            } elsif ($patronverification && $libraryverification) {
193
                },
195
                $action = 'patronandlibrarytoverify';
194
            );
196
            } else {
197
                $action = 'librarytoverify';
198
            }
199
            $template->param( action => $action );
200
201
            if ($action eq 'patrontoverify') {
202
                # Send verification email to patron
203
                $letter_code = 'OPAC_REG_VERIFY';
204
                $letter = C4::Letters::GetPreparedLetter(
205
                    module      => 'members',
206
                    letter_code => $letter_code,
207
                    lang        => 'default', # Patron does not have a preferred language defined yet
208
                    tables      => {
209
                        borrower_modifications => $verification_token,
210
                    },
211
                );
212
                $toaddress = $borrower{'email'};
213
            } elsif ($action eq 'patronandlibrarytoverify') {
214
                $letter_code = 'PATRON_AND_LIB_VER';
215
                $letter = C4::Letters::GetPreparedLetter(
216
                    module      => 'members',
217
                    letter_code => $letter_code,
218
                    lang        => 'default',
219
                    tables      => {
220
                        borrower_modifications => $verification_token,
221
                    },
222
                );
223
                $toaddress = $borrower{'email'};
224
            } else {
225
                 # Send verification email to library
226
                 $letter_code = 'STAFF_VER_OPAC_REG';
227
                 $letter = C4::Letters::GetPreparedLetter(
228
                     module      => 'members',
229
                     letter_code => $letter_code,
230
                     lang        => 'default', # Patron does not have a preferred language defined yet
231
                     tables      => {
232
                         borrower_modifications => $verification_token,
233
                     },
234
                );
235
                if ($libraryverification eq "BranchEmailAddress") {
236
                    my $library = Koha::Libraries->find( $borrower{branchcode} );
237
                    $toaddress = $library->branchreplyto
238
                    || $library->branchemail
239
                    || C4::Context->preference('ReplytoDefault')
240
                    || C4::Context->preference('KohaAdminEmailAddress')
241
                } elsif ($libraryverification eq "KohaAdminEmailAddress") {
242
                    $toaddress = C4::Context->preference('ReplytoDefault')
243
                    || C4::Context->preference('KohaAdminEmailAddress');
244
                }
245
            }
195
246
196
            C4::Letters::EnqueueLetter(
247
            C4::Letters::EnqueueLetter(
197
                {
248
                {
198
                    letter                 => $letter,
249
                    letter                 => $letter,
199
                    message_transport_type => 'email',
250
                    message_transport_type => 'email',
200
                    to_address             => $borrower{'email'},
251
                    to_address             => $toaddress,
201
                    from_address =>
252
                    from_address =>
202
                      C4::Context->preference('KohaAdminEmailAddress'),
253
                      C4::Context->preference('KohaAdminEmailAddress'),
203
                }
254
                }
204
            );
255
            );
256
205
            my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
257
            my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
206
                    letter_code => 'OPAC_REG_VERIFY'
258
                letter_code => $letter_code
207
                    } );
259
            } );
208
        }
260
        }
209
        else {
261
        else {
210
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
262
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
(-)a/opac/opac-password-recovery.pl (-1 / +7 lines)
Lines 34-39 my $uniqueKey = $query->param('uniqueKey'); Link Here
34
my $username       = $query->param('username') // q{};
34
my $username       = $query->param('username') // q{};
35
my $borrower_number;
35
my $borrower_number;
36
36
37
$borrower_number = $query->param('borrowernumber') if ($query->param('borrowernumber'));
38
37
#errors
39
#errors
38
my $hasError;
40
my $hasError;
39
41
Lines 219-225 elsif ($uniqueKey) { #reset password form Link Here
219
    );
221
    );
220
}
222
}
221
else {    #password recovery form (to send email)
223
else {    #password recovery form (to send email)
222
    $template->param( password_recovery => 1 );
224
    my $borrower = Koha::Patrons->find($borrower_number);
225
    $template->param( email => $borrower->email, username => $borrower->userid ) if $borrower;
226
    $template->param(
227
        password_recovery => 1,
228
    );
223
}
229
}
224
230
225
output_html_with_http_headers $query, $cookie, $template->output;
231
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/opac-registration-verify.pl (-25 / +107 lines)
Lines 59-91 if ( Link Here
59
        }
59
        }
60
    );
60
    );
61
61
62
    my $patron_attrs = $m->unblessed;
62
    my $libraryhasverified = $cgi->param('approved');
63
    $patron_attrs->{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($patron_attrs->{categorycode}));
63
    my $needlibraryverification = C4::Context->preference('PatronSelfRegistrationVerifyByEmailToLibrary');
64
    my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
64
65
    $patron_attrs->{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
65
    my $action;
66
    delete $patron_attrs->{timestamp};
66
    if ( $libraryhasverified && $needlibraryverification ) {
67
    delete $patron_attrs->{verification_token};
67
        $action = 'libraryhasverified';
68
    delete $patron_attrs->{changed_fields};
68
    } elsif ( !$libraryhasverified && $needlibraryverification ) {
69
    my $patron = Koha::Patron->new( $patron_attrs )->store;
69
        $action = 'librarytoverify';
70
70
    } else {
71
    Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt;
71
        $action = 'nolibraryverification';
72
72
    }
73
    if ($patron) {
73
74
        $m->delete();
74
    $template->param( action => $action );
75
        C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
75
76
76
    if ($action eq 'nolibraryverification' || $action eq 'libraryhasverified') {
77
        $template->param( password_cleartext => $patron->plain_text_password );
77
78
        $template->param( borrower => $patron );
78
        # Create account as library verification not required or already done
79
        $template->param(
79
        my $patron_attrs = $m->unblessed;
80
            PatronSelfRegistrationAdditionalInstructions =>
80
        $patron_attrs->{password} ||= Koha::AuthUtils::generate_password;
81
              C4::Context->preference(
81
        my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
82
                'PatronSelfRegistrationAdditionalInstructions')
82
        $patron_attrs->{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
83
        delete $patron_attrs->{timestamp};
84
        delete $patron_attrs->{verification_token};
85
        delete $patron_attrs->{changed_fields};
86
        my $patron = Koha::Patron->new( $patron_attrs )->store;
87
88
        # If library verification required then send password reset email directly to patron
89
        if ($needlibraryverification) {
90
            my $letter = C4::Letters::GetPreparedLetter(
91
                module      => 'members',
92
                letter_code => 'SELF_REG_APPROVED',
93
                lang        => 'default', # Patron does not have a preferred language defined yet
94
                tables      => {
95
                    borrowers => $patron->borrowernumber,
96
                },
97
            );
98
99
            C4::Letters::EnqueueLetter(
100
                {
101
                    letter                 => $letter,
102
                    message_transport_type => 'email',
103
                    to_address             => $patron->email,
104
                    from_address           => C4::Context->preference('KohaAdminEmailAddress'),
105
                }
106
            );
107
108
            my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
109
                letter_code => 'SELF_REG_APPROVED'
110
            } );
111
        }
112
113
        Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt;
114
115
        if ($patron) {
116
            $m->delete();
117
            C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
118
119
            $template->param( password_cleartext => $patron->plain_text_password );
120
            $template->param( borrower => $patron );
121
            $template->param(
122
                PatronSelfRegistrationAdditionalInstructions =>
123
                C4::Context->preference(
124
                    'PatronSelfRegistrationAdditionalInstructions')
125
            );
126
127
            my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-registration-confirmation.tt','opac',$cgi);
128
            $template->param( news_lang => $news_lang );
129
        }
130
131
    } else {
132
133
        # Send verification email to library to approve
134
        my $toaddress;
135
        if ($needlibraryverification eq "BranchEmailAddress" ) {
136
            my $library = Koha::Libraries->find( $m->branchcode );
137
            $toaddress = $library->branchreplyto
138
            || $library->branchemail
139
            || C4::Context->preferences('ReplytoDefault')
140
            || C4::Context->preferences('KohaAdminEmailAddress')
141
        }
142
        elsif ( $needlibraryverification eq "KohaAdminEmailAddress" ) {
143
            $toaddress = C4::Context->preference('ReplytoDefault')
144
            || C4::Context->preference('KohaAdminEmailAddress');
145
        }
146
147
        my $patron_attrs = $m->unblessed;
148
        my $letter;
149
        # Send verification email to library
150
        $letter = C4::Letters::GetPreparedLetter(
151
            module      => 'members',
152
            letter_code => 'STAFF_VER_OPAC_REG',
153
            lang        => 'default', # Patron does not have a preferred language defined yet
154
            tables      => {
155
                borrower_modifications => $patron_attrs->{verification_token},
156
            },
83
        );
157
        );
84
158
85
        my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-registration-confirmation.tt','opac',$cgi);
159
        C4::Letters::EnqueueLetter(
86
        $template->param( news_lang => $news_lang );
160
            {
161
                letter                 => $letter,
162
                message_transport_type => 'email',
163
                to_address             => $toaddress,
164
                from_address =>
165
                    C4::Context->preference('KohaAdminEmailAddress'),
166
            }
167
        );
168
        my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
169
            letter_code => 'STAFF_VER_OPAC_REG'
170
        } );
87
    }
171
    }
88
89
}
172
}
90
else {
173
else {
91
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
174
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
92
- 

Return to bug 25090