From f6aa48ad45b453d04b68a9ca447544234934e7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Bergl=C3=A9n?= Date: Mon, 18 Dec 2017 13:24:24 +0100 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. --- .../data/mysql/atomicupdate/AutoApprovePatronProfileSettings.sql | 2 ++ .../intranet-tmpl/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 0000000..6b5acc9 --- /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'); \ No newline at end of file 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 5591aa1..9ed1b50 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 @@ -200,6 +200,12 @@ Patrons: no: "Don't" - track last patron activity. - Everytime 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." "Norwegian patron database": - - pref: NorwegianPatronDBEnable diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 12eebbb..6560b63 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::Members::Attributes qw( GetBorrowerAttributes ); use C4::Form::MessagingPreferences; @@ -281,6 +282,14 @@ elsif ( $action eq 'update' ) { } 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.7.4