From 3dca2e5cac20e850537116926832f57f37fcb36f Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 13 Apr 2020 14:30:49 +0000 Subject: [PATCH] Bug 25090: Add sysprefs to define destination of OPAC self reg verification emails Online resources such as Ancestry, EBSCO etc. often charge on a usage basis and for library users to access them they need a Koha OPAC login. Enabling PatronSelfRegistration syspref allows patrons to immediately create a Koha patron and have the ability to login to the OPAC. Enabling PatronSelfRegistrationVerifyByEmail delays when the patron can login to the OPAC until after they have clicked on the verification email sent to their entered email address. Currently there is no way for libraries to moderate self registrations and prevent certain users (e.g. registrations from outside an organisation) from having OPAC logins and therefore access to paid online resources. This enhancement adds two new system preferences PatronSelfRegistrationVerificationRecipient and PatronSelfRegistrationVerificationRecipientAddress. These new system preferences work in the same way as existing sysprefs EmailPurchaseSuggestions, EmailAddressForSuggestions, and they keep the current Koha behaviour as their default. The former new syspref allows librarians to control where the verification email (generated after OPAC self registration form is submitted) goes to. The choices are: A. Self registering patrons selected home library email B. KohaAdminEmailAddress - Although ReplyToDefault syspref is defaulted to be used first C. Email address entered into PatronSelfRegistrationVerificationRecipientAddress D. Self registering patron email address - This is the default set for PatronSelfRegistrationVerificationRecipient. If A,B,C is selected then a new STAFF_OPAC_REG_VERIFY notice is sent to the library staff after the OPAC self registration form is submitted. The library staff can then review the submitted patron information and if they are happy for that user to have a OPAC login they click the verification link. Whereupon a patron account is added to the Koha borrowers table and the 'SELF_REG_APPROVED' notice containing a password reset link is sent to the patron. If D is selected then after submitting the OPAC self registration form is submitted then the patron is emailed the OPAC_REG_VERIFY notice directly and they can click the verification link whereupon they have a OPAC login. Test plan: 1. Enable PatronSelfRegistration, PatronSelfRegistrationVerifyByEmail, and OpacResetPassword sysprefs. Also ensure there are different values in KohaAdminEmailAddress, ReplyToAddress sysprefs and branch email address (Administration > Libraries) 2. Visit OPAC click registration link 3. Submit form and query the database: select to_address from message_queue where letter_code='OPAC_REG_VERIFY'; 4. Observe the verification email is sent directly to the email address entered in step #3 5. Apply patch and restart plack 6. update database: cd installer/data/mysql sudo koha-shell ./updatedatabase.pl 7. Observe 2 new sysprefs: * PatronSelfRegistrationVerificationRecipient -> Note this has default value of 'email address of Self registering patron' * PatronSelfRegistrationVerificationRecipientAddress 8. Repeat steps 2,3,4 and observe the 'OPAC_REG_VERIFY' notices is still sent directly to the patron 9. Change PatronSelfRegistrationVerificationRecipient to 'email address of branch' 10. Revisit the OPAC, resubmit the OPAC self registration (setting the library to a library with a email set in step #1) and observe text is displayed telling you that your self registration has been sent to librarians for approval 11. Query the database: select to_address, content from message_queue where letter_code='STAFF_OPAC_REG_VERIFY'; Observe that the STAFF_OPAC_REG_VERIFY notice was sent to the individual library email address and contains: * Card number * Name: title firstname surname * Physical address: streetnumber, streettype, address, address2, city, state, zipcode, country * Email * Phone * Mobile * Fax * Secondary email * Secondary phone * Home library * Temporary patron category And a verification link 12. Query the database and observe the patron added in step 8 doesn't yet exist in the borrowers table, e.g: select * from borrowers where email=; 13. Copy the verification link from step #11 into your browser 14. Observe the OPAC is displaying text telling you a password reset link email was sent to patron 15. Query the database and observe the patron has been added to the borrowers table now: select * from borrowers where email=; 16. Query the message_queue table and observe the password reset email 'SELF_REG_APPROVED' has been sent to the patron: select to_address, content from message_queue where letter_code='SELF_REG_APPROVED'; 17. Click on the password reset link in that email and observe the password reset page in the OPAC loads with the login username and email; are prefilled. 18. Reset the password and try logging in and observe you are able to. 19. Change PatronSelfRegistrationVerificationRecipient to 'KohaAdminEmailAddress' and repeat steps 10 and 11 and observe the 'STAFF_OPAC_REG_VERIFY' notice has been sent to ReplyToDefault syspref email 20. Repeat steps 12, 13, 14, 15, 16, 17, 18 and observe they all have the same outcomes as when PatronSelfRegistrationVerificationRecipient was set to 'email address of branch' 21. Change PatronSelfRegistrationVerificationRecipient to 'PatronSelfRegistrationVerificationRecipientAddress' and then set a different email address in PatronSelfRegistrationVerificationRecipientAddress' 22. Repeat steps 10 and 11 and observe the 'STAFF_OPAC_REG_VERIFY' notice has been sent to the email you set in PatronSelfRegistrationVerificationRecipientAddress 23. Repeat steps 12, 13, 14, 15, 16, 17, 18 and observe they all have the same outcomes as when PatronSelfRegistrationVerificationRecipient was set to 'email address of branch' 24. Run tests: sudo koha-shell prove xt prove t Sponsored-By: Mental Health Education Resource Centre, NZ --- ...lfRegistrationVerificationRecipient_syspref.sql | 2 + ...VER_OPAC_REG_and_SELF_REG_APPROVED_notices.perl | 42 +++++++++++++ .../data/mysql/de-DE/mandatory/sample_notices.sql | 29 +++++++++ .../data/mysql/en/mandatory/sample_notices.yml | 48 +++++++++++++++ .../data/mysql/es-ES/mandatory/sample_notices.sql | 29 +++++++++ .../mysql/fr-CA/obligatoire/sample_notices.sql | 30 ++++++++++ .../mysql/fr-FR/1-Obligatoire/sample_notices.sql | 29 +++++++++ installer/data/mysql/it-IT/necessari/notices.sql | 29 +++++++++ .../mysql/nb-NO/1-Obligatorisk/sample_notices.sql | 30 ++++++++++ .../data/mysql/pl-PL/mandatory/sample_notices.sql | 29 +++++++++ .../data/mysql/ru-RU/mandatory/sample_notices.sql | 29 +++++++++ installer/data/mysql/sysprefs.sql | 2 + .../data/mysql/uk-UA/mandatory/sample_notices.sql | 29 +++++++++ .../prog/en/modules/admin/preferences/opac.pref | 13 +++++ .../en/modules/opac-registration-confirmation.tt | 11 +++- .../en/modules/opac-registration-email-sent.tt | 12 ++++ opac/opac-memberentry.pl | 68 ++++++++++++++++++---- opac/opac-password-recovery.pl | 8 ++- opac/opac-registration-verify.pl | 28 +++++++++ 19 files changed, 483 insertions(+), 14 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_25090-add_PatronSelfRegistrationVerificationRecipient_syspref.sql create mode 100644 installer/data/mysql/atomicupdate/bug_25090-add_STAFF_VER_OPAC_REG_and_SELF_REG_APPROVED_notices.perl diff --git a/installer/data/mysql/atomicupdate/bug_25090-add_PatronSelfRegistrationVerificationRecipient_syspref.sql b/installer/data/mysql/atomicupdate/bug_25090-add_PatronSelfRegistrationVerificationRecipient_syspref.sql new file mode 100644 index 0000000000..387c190641 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25090-add_PatronSelfRegistrationVerificationRecipient_syspref.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('PatronSelfRegistrationVerificationRecipient', 'RegisteringPatron', 'PatronSelfRegistrationVerificationRecipientAddress|BranchEmailAddress|KohaAdminEmailAddress|RegisteringPatron', 'Choose email address that self registering users verification email will be sent to.', 'Choice'); +INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('PatronSelfRegistrationVerificationRecipientAddress', '', '', 'If you choose PatronSelfRegistrationVerificationRecipientAddress you have to enter a valid email address:', 'free'); diff --git a/installer/data/mysql/atomicupdate/bug_25090-add_STAFF_VER_OPAC_REG_and_SELF_REG_APPROVED_notices.perl b/installer/data/mysql/atomicupdate/bug_25090-add_STAFF_VER_OPAC_REG_and_SELF_REG_APPROVED_notices.perl new file mode 100644 index 0000000000..a8af76ba8a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25090-add_STAFF_VER_OPAC_REG_and_SELF_REG_APPROVED_notices.perl @@ -0,0 +1,42 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+ +

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+ +

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

+

', 1, 'email') + }); + $dbh->do(q{ + INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email') + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 25090 - Custom destination for OPAC self registration verification emails to allow libraries to moderate which registrations get Koha accounts)\n"; +} diff --git a/installer/data/mysql/de-DE/mandatory/sample_notices.sql b/installer/data/mysql/de-DE/mandatory/sample_notices.sql index 0fbf5f73d2..f596045d08 100644 --- a/installer/data/mysql/de-DE/mandatory/sample_notices.sql +++ b/installer/data/mysql/de-DE/mandatory/sample_notices.sql @@ -386,3 +386,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 7f814c377b..beb502575b 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -736,6 +736,54 @@ tables: - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly." - module: members + code: STAFF_VER_OPAC_REG + branchode: "" + name: "New patron Opac Self-Registration to verify" + is_html: 1 + title: "Verify new Opac patron self registration" + message_transport_type: email + lang: default + content: + - "

Opac self registration pending verification

" + - "

Submitted Opac patron self registration:

" + - "
    " + - "
  • <>
  • " + - "
  • <> <> <>
  • " + - "
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • " + - "
  • Email: <>
  • " + - "
  • Phone: <>
  • " + - "
  • Mobile: <>
  • " + - "
  • Fax: <>
  • " + - "
  • Secondary email: <>
  • " + - "
  • Secondary phone:<>
  • " + - "
  • Home library: <>
  • " + - "
  • Temporary patron category: <>
  • " + - "
" + - "

" + - "

" + - "If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link:" + - "

" + - "<>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1" + - "

" + - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly." + - "

" + + - module: members + code: SELF_REG_APPROVED + branchcode: "" + name: "Self registration approved" + is_html: 1 + title: "Your self registration has been approved" + message_transport_type: email + lang: default + content: + - "" + - "

Please click the password reset link below to reset your Koha password then you'll be able to login to the OPAC:

" + - "

" + - "<>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<>" + - "

" + + - module: members code: PASSWORD_RESET branchcode: "" name: "Online password reset" diff --git a/installer/data/mysql/es-ES/mandatory/sample_notices.sql b/installer/data/mysql/es-ES/mandatory/sample_notices.sql index 4ee0a6c800..73770fd7cf 100644 --- a/installer/data/mysql/es-ES/mandatory/sample_notices.sql +++ b/installer/data/mysql/es-ES/mandatory/sample_notices.sql @@ -378,3 +378,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'),('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql b/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql index ba88804699..71e27e275d 100644 --- a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql +++ b/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql @@ -268,3 +268,33 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql index 6106d737f3..83cb63a204 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql @@ -379,3 +379,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/it-IT/necessari/notices.sql b/installer/data/mysql/it-IT/necessari/notices.sql index e462da9d00..8804d0debe 100644 --- a/installer/data/mysql/it-IT/necessari/notices.sql +++ b/installer/data/mysql/it-IT/necessari/notices.sql @@ -382,3 +382,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql index 8439fd96d8..1c228d778f 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql @@ -398,3 +398,33 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql index 6373e2e975..859f9a87b8 100644 --- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql +++ b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql @@ -376,3 +376,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql index f9c4fc55d5..3466f9f129 100644 --- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql +++ b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql @@ -378,3 +378,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e39352448c..403a2fd6b7 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -497,6 +497,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfRegistrationExpireTemporaryAccountsDelay','0',NULL,'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.','Integer'), ('PatronSelfRegistrationLibraryList','',NULL,'Only display libraries listed. If empty, all libraries are displayed.','Free'), ('PatronSelfRegistrationPrefillForm','1',NULL,'Display password and prefill login form after a patron has self registered','YesNo'), +('PatronSelfRegistrationVerificationRecipient', 'RegisteringPatron', 'PatronSelfRegistrationVerificationRecipientAddress|BranchEmailAddress|KohaAdminEmailAddress|RegisteringPatron', 'Choose email address that self registering users verification email will be sent to', 0, 'Choice'), +('PatronSelfRegistrationVerificationRecipientAddress', '', '', 'If you choose PatronSelfRegistrationVerificationRecipientAddress you have to enter a valid email address:', 'free'), ('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.','YesNo'), ('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'), ('EnablePayPalOpacPayments', '0', NULL , 'Enables the ability to pay fees and fines from the OPAC via PayPal', 'YesNo' ), diff --git a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql index 5356ad74f4..8f54c09f24 100644 --- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql +++ b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql @@ -469,3 +469,32 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, ', 'print', 'default'); + +INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES ('members', 'STAFF_VER_OPAC_REG', 'New patron Opac Self-Registration to verify', 'Verify new Opac patron self registration', '

Opac self registration pending verification

+

Submitted Opac patron self registration:

+
    +
  • <>
  • +
  • <> <> <>
  • +
  • Physical address: <> <> <> <>, <>, <> <>, <>
  • +
  • Email: <>
  • +
  • Phone: <>
  • +
  • Mobile: <>
  • +
  • Fax: <>
  • +
  • Secondary email: <>
  • +
  • Secondary phone:<>
  • +
  • Home library: <>
  • +
  • Temporary patron category: <>
  • +
+

+

+ If you wish to create a Koha patron account thereby giving this patron Opac access please click on this verification link: +

+

+ <>/cgi-bin/koha/opac-registration-verify.pl?token=<>&approved=1 +

+

+ If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly. +

', 1, 'email'), ('members', 'SELF_REG_APPROVED', 'Self registration approved', 'Your self registration has been approved', '

Please click the password reset link below to reset your Koha password then you will be able to login to the OPAC:

+

+ <>/cgi-bin/koha/opac-password-recovery.pl?borrowernumber=<> +

', 1, 'email'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 44be2236d2..94eba71344 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -826,6 +826,19 @@ OPAC: - "library patrons to register or modify their account via the OPAC." - "
NOTE: This needs PatronSelfRegistrationDefaultCategory to be set to a valid patron category code." - + - "Choose email address that self registration verification emails will be sent to: " + - pref: PatronSelfRegistrationVerificationRecipient + default: RegisteringPatron + choices: + RegisteringPatron: email address of Self registering patron + PatronSelfRegistrationVerificationRecipientAddress: PatronSelfRegistrationVerificationRecipientAddress + BranchEmailAddress: email address of branch + KohaAdminEmailAddress: KohaAdminEmailAddress + - "
NOTE: This system preferences requires the PatronSelfRegistrationVerifyByEmail to be set to Require." + - "
If you choose PatronSelfRegistrationVerificationRecipientAddress you have to enter a valid email address:" + - pref: PatronSelfRegistrationVerificationRecipientAddress + class: email + - - pref: PatronSelfRegistrationVerifyByEmail choices: yes: Require diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt index 2fc4493983..d16bb070f8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt @@ -31,6 +31,15 @@
[% END %] + [% IF verificationapproved == 1 %] +
+

New patron registered!

+ +

You have successfully registered a new Koha patron account for [% borrower.firstname | html %] [% borrower.surname | html %].

+

An email containing a password reset link has been sent to [% borrower.firstname | html %] [% borrower.surname | html %]'s email address: [% borrower.email | html %]:

+

Once [% borrower.firstname | html %] [% borrower.surname | html %] has reset their password they will be able to log into and use the Koha OPAC.

+
+ [% ELSE %]

Registration Complete!

@@ -65,7 +74,7 @@
[% PatronSelfRegistrationAdditionalInstructions | $raw %]
- + [% END %]
[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %] 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 1a4bdce4d4..036f19bd30 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 @@ -25,6 +25,7 @@ [% ELSE %]
[% END %] + [% IF verificationrecipient == 'RegisteringPatron' %]

Please confirm your registration

@@ -34,6 +35,17 @@

Your account will not be activated until you follow the link provided in the confirmation email.

+ [% ELSE %] +
+
+

Thank you for submitting your library registration

+ +

A library staff member will review your registration shortly, and if approved an email will be sent to [% email | html %] containing your OPAC login credentials.

+ +

Your account will not be activated until it has been approved by a library staff member.

+
+
+ [% END %]
diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index faf32e8285..8575a33379 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -182,28 +182,72 @@ if ( $action eq 'create' ) { 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 $verificationrecipient = C4::Context->preference("PatronSelfRegistrationVerificationRecipient"); + my $customverificationrecipient = C4::Context->preference("PatronSelfRegistrationVerificationRecipientAddress"); + # Determine the 'to_address' of the verification email + my $toaddress; + if ($verificationrecipient eq "BranchEmailAddress" ) { + my $library = Koha::Libraries->find( $borrower{branchcode} ); + $toaddress = $library->branchreplyto + || $library->branchemail + || C4::Context->preferences('ReplytoDefault') + || C4::Context->preferences('KohaAdminEmailAddress') + } + elsif ( $verificationrecipient eq "KohaAdminEmailAddress" ) { + $toaddress = C4::Context->preference('ReplytoDefault') + || C4::Context->preference('KohaAdminEmailAddress'); + + } elsif ( $verificationrecipient eq "RegisteringPatron" ) { + $toaddress = $borrower{'email'} + } else { + $toaddress = + $customverificationrecipient + || C4::Context->preference('ReplytoDefault') + || C4::Context->preference('KohaAdminEmailAddress'); + } + $template->param( verificationrecipient => $verificationrecipient ); + + my $letter; + if ($verificationrecipient eq "RegisteringPatron" ) { + # Send verification email directly to registering patron + $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, + }, + ); + } else { + # Send verification email to library + $letter = C4::Letters::GetPreparedLetter( + module => 'members', + letter_code => 'STAFF_VER_OPAC_REG', + lang => 'default', # Patron does not have a preferred language defined yet + tables => { + borrower_modifications => $verification_token, + }, + ); + } C4::Letters::EnqueueLetter( { letter => $letter, message_transport_type => 'email', - to_address => $borrower{'email'}, + to_address => $toaddress, from_address => C4::Context->preference('KohaAdminEmailAddress'), } ); - my $num_letters_attempted = C4::Letters::SendQueuedMessages( { + if ($verificationrecipient eq "RegisteringPatron") { + my $num_letters_attempted = C4::Letters::SendQueuedMessages( { letter_code => 'OPAC_REG_VERIFY' - } ); + } ); + } else { + my $num_letters_attempted = C4::Letters::SendQueuedMessages( { + letter_code => 'STAFF_VER_OPAC_REG' + } ); + } } else { ( $template, $borrowernumber, $cookie ) = get_template_and_user( diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl index a695165b56..92786f7935 100755 --- a/opac/opac-password-recovery.pl +++ b/opac/opac-password-recovery.pl @@ -34,6 +34,8 @@ my $uniqueKey = $query->param('uniqueKey'); my $username = $query->param('username') // q{}; my $borrower_number; +$borrower_number = $query->param('borrowernumber') if ($query->param('borrowernumber')); + #errors my $hasError; @@ -208,7 +210,11 @@ elsif ($uniqueKey) { #reset password form ); } else { #password recovery form (to send email) - $template->param( password_recovery => 1 ); + my $borrower = Koha::Patrons->find($borrower_number); + $template->param( email => $borrower->email, username => $borrower->userid ) if $borrower; + $template->param( + password_recovery => 1, + ); } output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index d408d5c5ae..298af6a760 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -38,6 +38,7 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) { my $token = $cgi->param('token'); my $m = Koha::Patron::Modifications->find( { verification_token => $token } ); +my $verificationapproval = $cgi->param('approved'); my ( $template, $borrowernumber, $cookie ); @@ -67,6 +68,33 @@ if ( delete $patron_attrs->{changed_fields}; my $patron = Koha::Patron->new( $patron_attrs )->store; + if ($verificationapproval) { + # Send password reset email directly to registering patron + my $letter = C4::Letters::GetPreparedLetter( + module => 'members', + letter_code => 'SELF_REG_APPROVED', + lang => 'default', # Patron does not have a preferred language defined yet + tables => { + borrowers => $patron->borrowernumber, + }, + ); + + C4::Letters::EnqueueLetter( + { + letter => $letter, + message_transport_type => 'email', + to_address => $patron->email, + from_address => C4::Context->preference('KohaAdminEmailAddress'), + } + ); + + my $num_letters_attempted = C4::Letters::SendQueuedMessages( { + letter_code => 'SELF_REG_APPROVED' + } ); + + $template->param( verificationapproved => $verificationapproval ); + } + Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt; if ($patron) { -- 2.11.0