Bugzilla – Attachment 149896 Details for
Bug 27634
Turn off patron self-registration if no default category is set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27634: Turn off patron self-registration if no default category is set
Bug-27634-Turn-off-patron-self-registration-if-no-.patch (text/plain), 3.70 KB, created by
David Nind
on 2023-04-19 16:40:02 UTC
(
hide
)
Description:
Bug 27634: Turn off patron self-registration if no default category is set
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-04-19 16:40:02 UTC
Size:
3.70 KB
patch
obsolete
>From f93c5230f84e5609870426a1a073fc9de6005750 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 5 Feb 2021 10:53:54 +0100 >Subject: [PATCH] Bug 27634: Turn off patron self-registration if no default > category is set > >If there is no default category defined in PatronSelfRegistrationDefaultCategory the full feature must be displayed. > >We already hide the link from the OPAC main page, but the form is still accessible. > >Test plan (for the whole patch set): >1. Turn on PatronSelfRegistration >2. Don't set PatronSelfRegistrationDefaultCategory >3. Go to the OPAC main page and confirm that the "Register here" link is >not displayed >4. Hit opac-memberentry.pl and confirm that you are redirected to the >OPAC main page >5. Go to the about page and confirm that you see a warning in the >"System information" tab >6. Set PatronSelfRegistrationDefaultCategory to an invalid patron's >category >7. Repeat 3, 4, 5 >8. Set PatronSelfRegistrationDefaultCategory to a valid patron's >category >9. Self-register a patron and confirm it works as expected >10. Edit PatronSelfRegistrationBorrowerUnwantedField and confirm that >you cannot remove dateexpiry and categorycode > >Signed-off-by: David Nind <david@davidnind.com> >--- > opac/opac-memberentry.pl | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index a09bcb8bc1..65e4626dab 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -57,12 +57,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >-unless ( C4::Context->preference('PatronSelfRegistration') || $borrowernumber ) >-{ >- print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); >- exit; >-} >- > my $action = $cgi->param('action') || q{}; > if ( $borrowernumber && ( $action eq 'create' || $action eq 'new' ) ) { > print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); >@@ -78,6 +72,16 @@ if ( $action eq q{} ) { > } > } > >+my $PatronSelfRegistrationDefaultCategory = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >+my $defaultCategory = Koha::Patron::Categories->find($PatronSelfRegistrationDefaultCategory); >+# Having a valid PatronSelfRegistrationDefaultCategory is mandatory >+if ( !C4::Context->preference('PatronSelfRegistration') && !$borrowernumber >+ || ( ( $action eq 'new' || $action eq 'create' ) && !$defaultCategory ) ) >+{ >+ print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); >+ exit; >+} >+ > my $mandatory = GetMandatoryFields($action); > > my $params = {}; >@@ -96,8 +100,6 @@ if ( defined $min ) { > ); > } > >-my $defaultCategory = Koha::Patron::Categories->find(C4::Context->preference('PatronSelfRegistrationDefaultCategory')); >- > $template->param( > action => $action, > hidden => GetHiddenFields( $mandatory, $action ), >@@ -128,7 +130,7 @@ if ( $action eq 'create' ) { > my %borrower = ParseCgiForBorrower($cgi); > > %borrower = DelEmptyFields(%borrower); >- $borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >+ $borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory; > > my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); > my $invalidformfields = CheckForInvalidFields(\%borrower); >@@ -245,7 +247,7 @@ if ( $action eq 'create' ) { > { borrowernumber => $patron->borrowernumber }, > $template, > 1, >- C4::Context->preference('PatronSelfRegistrationDefaultCategory') >+ $PatronSelfRegistrationDefaultCategory > ); > } > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27634
:
116378
|
116379
|
116380
|
116381
|
116382
|
116383
|
116491
|
145599
|
145600
|
145601
|
145602
|
145603
|
145604
|
145605
|
145922
|
147531
|
147532
|
147533
|
147534
|
147535
|
147536
|
147537
|
149746
|
149747
|
149748
|
149896
|
149897
|
149898
|
149899
|
149900
|
149901
|
149902
|
150083
|
150084
|
150085
|
150086
|
150087
|
150088
|
150089
|
150090
|
151046
|
151047
|
151048
|
151049
|
155863
|
155864
|
155865
|
155866
|
155867
|
155868
|
155869
|
155870
|
156203