From d5e25353d4e7d7b44dfd446638f0f05d08a40d85 Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Tue, 29 Dec 2020 14:33:40 +0100 Subject: [PATCH] Bug 27312 - Add a syspref to redirect patron after self registration We have an authentication workflow that requires redirecting the patron to a URL or path after successfull self registration. See Bugzilla for further details. This patch adds a syspref that takes a full URL or local path, and if this is set, a patron will be redirected after completing the self registration in the OPAC. To test: - Apply this patch, including running the atomic database update - Enable PatronSelfRegistration and set a patron category in PatronSelfRegistrationDefaultCategory - Do a self registration in the OPAC and check it works as expeced - Fill inn a complete URL in RedirectURLAfterPatronSelfReg - Do a new self registration in the OPAC and note that you are redirected to the URL you entered - Check in the staff client that the patron was registered as expected, before being redirected - Sign off --- .../bug27312-add-syspref-RedirectURLAfterPatronSelfReg.perl | 5 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 5 +++++ opac/opac-memberentry.pl | 6 ++++++ 4 files changed, 17 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug27312-add-syspref-RedirectURLAfterPatronSelfReg.perl diff --git a/installer/data/mysql/atomicupdate/bug27312-add-syspref-RedirectURLAfterPatronSelfReg.perl b/installer/data/mysql/atomicupdate/bug27312-add-syspref-RedirectURLAfterPatronSelfReg.perl new file mode 100644 index 0000000000..c47fde1661 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug27312-add-syspref-RedirectURLAfterPatronSelfReg.perl @@ -0,0 +1,5 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('RedirectURLAfterPatronSelfReg', '', NULL, 'Redirect the patron to this URL after successfull self registration.', 'Free')" ); + NewVersion( $DBversion, 27312, "Add a syspref to redirect patron after self registration"); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 2ea427bdd2..96b6c16f2e 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -541,6 +541,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), ('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), +('RedirectURLAfterPatronSelfReg','',NULL,'Redirect the patron to this URL after successfull self registration.','Free'), ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), ('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), ('RenewAccruingItemInOpac','0','','If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), 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 3654080c02..54eab4489a 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 @@ -865,6 +865,11 @@ OPAC: yes: Allow no: "Don't allow" - patrons to notify the library of changes to their contact information from the OPAC. + - + - "Redirect the patron to " + - pref: RedirectURLAfterPatronSelfReg + class: long + - "after successfull self registration. This can be a full URL or a URL fragment, starting with /." Advanced search options: - diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index a3f1ae61b8..671a6af8b2 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -237,6 +237,12 @@ if ( $action eq 'create' ) { ); } + # Check if we should redirect the patron somewhere else, e.g. for authentication + if ( C4::Context->preference('RedirectURLAfterPatronSelfReg') ) { + print $cgi->redirect( C4::Context->preference('RedirectURLAfterPatronSelfReg') ); + exit; + } + $template->param( password_cleartext => $patron->plain_text_password ); $template->param( borrower => $patron->unblessed ); } else { -- 2.17.1