From 08bd5ee3006264c28d3d8247f0099da7bdb05861 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Tue, 19 May 2020 12:44:31 +0200 Subject: [PATCH] Bug 20057 - Syspref for auto approval of patron profile changes Testplan for this patch: 1. Apply patch. 2. Make sure syspref "PatronSelfRegistrationVerifyByEmail" is set to "Don't require". 3. Make sure syspref "AutoApprovePatronProfileSettings" is set to "Disable". 3. Edit patron personal details via opac interface. 4. Expect modifications to require manual approval by staff via link on main page. 5. Set syspref "AutoApprovePatronProfileSettings" to "Enable". 6. Edit patron personal details via opac interface again. 7. Expect modifications to have been approved automatically. Signed-off-by: Liz Rea This works, we may want some different text for this situation in the OPAC, it still says the librarian has to approve the change. --- .../atomicupdate/AutoApprovePatronProfileSettings.sql | 2 ++ .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++++ opac/opac-memberentry.pl | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/AutoApprovePatronProfileSettings.sql diff --git a/installer/data/mysql/atomicupdate/AutoApprovePatronProfileSettings.sql b/installer/data/mysql/atomicupdate/AutoApprovePatronProfileSettings.sql new file mode 100644 index 0000000000..55f54def46 --- /dev/null +++ b/installer/data/mysql/atomicupdate/AutoApprovePatronProfileSettings.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES +('AutoApprovePatronProfileSettings', '0', '', 'Automatically approve Patron profile changes.', 'YesNo'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 991de6668a..143433f523 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -72,6 +72,12 @@ Patrons: no: "Don't" - track last patron activity. - Every time a patron will connect, the borrowers.lastseen will be updated with the current time. + - + - pref: AutoApprovePatronProfileSettings + choices: + yes: Enable + no: Disable + - "Automatically approve Patron profile changes." - - pref: ProtectSuperlibrarianPrivileges choices: diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index faf32e8285..e7cd4ccec0 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -25,6 +25,7 @@ use String::Random qw( random_string ); use C4::Auth; use C4::Output; +use C4::Context; use C4::Members; use C4::Form::MessagingPreferences; use Koha::AuthUtils; @@ -299,6 +300,14 @@ elsif ( $action eq 'update' ) { Koha::Patron::Modifications->search({ borrowernumber => $borrowernumber })->delete; my $m = Koha::Patron::Modification->new( \%borrower_changes )->store(); + #Automatically approve patron profile changes if set in syspref + + if (C4::Context->preference('AutoApprovePatronProfileSettings')) { + # Need to get the object from database, otherwise it is not complete enough to allow deletion + # when approval has been performed. + my $tmp_m = Koha::Patron::Modifications->find({borrowernumber => $borrowernumber}); + $tmp_m->approve() if $tmp_m; + } my $patron = Koha::Patrons->find( $borrowernumber ); $template->param( borrower => $patron->unblessed ); -- 2.20.1