Bugzilla – Attachment 173899 Details for
Bug 25090
Moderate OPAC self registrations before a patron account is created
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25090 [WIP]: Redirect OPAC self reg verification email to the library
Bug-25090-WIP-Redirect-OPAC-self-reg-verification-.patch (text/plain), 10.16 KB, created by
Aleisha Amohia
on 2024-11-04 02:24:27 UTC
(
hide
)
Description:
Bug 25090 [WIP]: Redirect OPAC self reg verification email to the library
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-11-04 02:24:27 UTC
Size:
10.16 KB
patch
obsolete
>From b494601646bfa150ce681912fbe7283ba250f463 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 4 Nov 2024 02:19:35 +0000 >Subject: [PATCH] Bug 25090 [WIP]: Redirect OPAC self reg verification email to > the library > >So they can moderate and activate accounts made via OPAC self registration > >Sponsored-by: Mental Health Education & Resource Centre >--- > Koha/Patron.pm | 21 ++-- > .../modules/opac-registration-email-sent.tt | 18 +++- > opac/opac-memberentry.pl | 95 +++++++++++++------ > 3 files changed, 92 insertions(+), 42 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index bc031f8bcf9..b69a92d9ec9 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2796,16 +2796,19 @@ sub notify_library_of_registration { > || C4::Context->preference('KohaAdminEmailAddress'); > } > >- my $message_id = C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- borrowernumber => $self->borrowernumber, >- to_address => $to_address, >- message_transport_type => 'email' >+ unless ( C4::Context->preference("PatronSelfRegistrationVerifyByEmail") eq "library" ) { >+ # Only receive one of the OPAC_REG or OPAC_REG_VERIFY_LIB emails >+ my $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $self->borrowernumber, >+ to_address => $to_address, >+ message_transport_type => 'email' >+ } >+ ) or warn "can't enqueue letter $letter"; >+ if ($message_id) { >+ return 1; > } >- ) or warn "can't enqueue letter $letter"; >- if ( $message_id ) { >- return 1; > } > } > } >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >index abbd92032a3..771d91c7db1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >@@ -29,13 +29,21 @@ > <div class="col order-first order-md-first order-lg-2"> > [% END %] > <div id="registration-confirmation-pending" class="maincontent"> >- <h1>Please confirm your registration</h1> >- <div id="confirmation-pending" class="alert alert-info"> >+ [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %] >+ <h1>Your account is pending confirmation</h1> >+ <div id="confirmation-pending" class="alert alert-info"> > >- <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p> >+ <p>An email has been sent to the library to confirm the activation of your account.</p> >+ </div> <!-- /#confirmation-pending --> >+ [% ELSE %] >+ <h1>Please confirm your registration</h1> >+ <div id="confirmation-pending" class="alert alert-info"> > >- <p>Your account will not be activated until you follow the link provided in the confirmation email.</p> >- </div> <!-- /#confirmation-pending --> >+ <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p> >+ >+ <p>Your account will not be activated until you follow the link provided in the confirmation email.</p> >+ </div> <!-- /#confirmation-pending --> >+ [% END %] > </div> <!-- /#registration-confirmation-pending --> > </div> <!-- /.col/10 --> > </div> <!-- /.row --> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index b671dde7c04..b11c3abb2a9 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -177,11 +177,7 @@ if ( $op eq 'cud-create' ) { > die "Branchcode not allowed"; # They hack the form > } > else { >- if ( >- C4::Context->preference( >- 'PatronSelfRegistrationVerifyByEmail') >- ) >- { >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') ne "off" ) { > ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => "opac-registration-email-sent.tt", >@@ -190,38 +186,81 @@ if ( $op eq 'cud-create' ) { > authnotrequired => 1, > } > ); >- $template->param( 'email' => $borrower{'email'} ); >+ $template->param( 'email' => $borrower{'email'} ) >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "patron" ); > >- my $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ my $verification_token = md5_hex( time() . {} . rand() . {} . $$ ); > while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { >- $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ $verification_token = md5_hex( time() . {} . rand() . {} . $$ ); > } > >- $borrower{password} = Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($borrower{categorycode})) unless $borrower{password}; >+ $borrower{password} = >+ Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $borrower{categorycode} ) ) >+ unless $borrower{password}; > $borrower{verification_token} = $verification_token; > > $borrower{extended_attributes} = to_json($attributes); > Koha::Patron::Modification->new( \%borrower )->store(); > >- #Send verification email >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'members', >- letter_code => 'OPAC_REG_VERIFY', >- lang => 'default', # Patron does not have a preferred language defined yet >- tables => { >- borrower_modifications => $verification_token, >- }, >- ); >- >- my $message_id = C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- message_transport_type => 'email', >- to_address => $borrower{'email'}, >- from_address => >- C4::Context->preference('KohaAdminEmailAddress'), >+ my $message_id; >+ >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "library" ) { >+ >+ #Send verification email >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'members', >+ letter_code => 'OPAC_REG_VERIFY_LIB', >+ lang => 'default', # Patron does not have a preferred language defined yet >+ tables => { >+ 'borrower_modifications' => $verification_token, >+ }, >+ ); >+ >+ my $email_patron_registrations = C4::Context->preference('EmailPatronRegistrations'); >+ my $to_address; >+ if ( $email_patron_registrations eq "BranchEmailAddress" ) { >+ my $library = Koha::Libraries->find( $borrower{branchcode} ); >+ $to_address = $library->inbound_email_address; >+ } elsif ( $email_patron_registrations eq "KohaAdminEmailAddress" ) { >+ $to_address = C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } else { >+ $to_address = >+ C4::Context->preference('EmailAddressForPatronRegistrations') >+ || C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); > } >- ); >+ >+ $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ message_transport_type => 'email', >+ to_address => $to_address, >+ from_address => C4::Context->preference('KohaAdminEmailAddress'), >+ } >+ ); >+ >+ } else { >+ >+ #Send verification email >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'members', >+ letter_code => 'OPAC_REG_VERIFY', >+ lang => 'default', # Patron does not have a preferred language defined yet >+ tables => { >+ borrower_modifications => $verification_token, >+ }, >+ ); >+ >+ $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ message_transport_type => 'email', >+ to_address => $borrower{'email'}, >+ from_address => C4::Context->preference('KohaAdminEmailAddress'), >+ } >+ ); >+ } > C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; > } > else { >@@ -444,7 +483,7 @@ sub GetMandatoryFields { > if ( $op eq 'cud-create' || $op eq 'new' ) { > $mandatory_fields{'email'} = 1 > if C4::Context->preference( >- 'PatronSelfRegistrationVerifyByEmail'); >+ 'PatronSelfRegistrationVerifyByEmail') eq "patron"; > } > > return \%mandatory_fields; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25090
:
102845
|
103535
|
103536
|
104380
|
104381
|
104382
|
104383
|
104386
|
104994
|
104996
|
105319
|
112493
|
112494
|
112495
|
112496
|
112497
|
173894
|
173895
|
173896
|
173897
|
173898
|
173899
|
173962
|
173963
|
173964
|
174228
|
174229
|
174230