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

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

Return to bug 25090