From b12198a53feff9aad0f08160505477b50d0421b0 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Tue, 19 May 2020 12:44:31 +0200 Subject: [PATCH] Bug 20057: System preference for auto approval of patron profile changes Testplan for this patch: 1. Apply patch. 2. 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. Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- .../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 eb49161489..be281c43e0 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 @@ -73,6 +73,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 a076cd31b0..c0cd8c7351 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.39.5