@@ -, +, @@ category is set --- opac/opac-memberentry.pl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/opac/opac-memberentry.pl +++ a/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 ( $action eq q{} ) { if ($borrowernumber) { @@ -73,6 +67,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 @libraries = Koha::Libraries->search; @@ -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 ), @@ -129,7 +131,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); @@ -238,7 +240,7 @@ if ( $action eq 'create' ) { { borrowernumber => $patron->borrowernumber }, $template, 1, - C4::Context->preference('PatronSelfRegistrationDefaultCategory') + $PatronSelfRegistrationDefaultCategory ); } --