Lines 57-68
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
57 |
} |
57 |
} |
58 |
); |
58 |
); |
59 |
|
59 |
|
60 |
unless ( C4::Context->preference('PatronSelfRegistration') || $borrowernumber ) |
|
|
61 |
{ |
62 |
print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); |
63 |
exit; |
64 |
} |
65 |
|
66 |
my $action = $cgi->param('action') || q{}; |
60 |
my $action = $cgi->param('action') || q{}; |
67 |
if ( $action eq q{} ) { |
61 |
if ( $action eq q{} ) { |
68 |
if ($borrowernumber) { |
62 |
if ($borrowernumber) { |
Lines 73-78
if ( $action eq q{} ) {
Link Here
|
73 |
} |
67 |
} |
74 |
} |
68 |
} |
75 |
|
69 |
|
|
|
70 |
my $PatronSelfRegistrationDefaultCategory = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); |
71 |
my $defaultCategory = Koha::Patron::Categories->find($PatronSelfRegistrationDefaultCategory); |
72 |
# Having a valid PatronSelfRegistrationDefaultCategory is mandatory |
73 |
if ( !C4::Context->preference('PatronSelfRegistration') && !$borrowernumber |
74 |
|| ( ( $action eq 'new' || $action eq 'create' ) && !$defaultCategory ) ) |
75 |
{ |
76 |
print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); |
77 |
exit; |
78 |
} |
79 |
|
76 |
my $mandatory = GetMandatoryFields($action); |
80 |
my $mandatory = GetMandatoryFields($action); |
77 |
|
81 |
|
78 |
my @libraries = Koha::Libraries->search; |
82 |
my @libraries = Koha::Libraries->search; |
Lines 96-103
if ( defined $min ) {
Link Here
|
96 |
); |
100 |
); |
97 |
} |
101 |
} |
98 |
|
102 |
|
99 |
my $defaultCategory = Koha::Patron::Categories->find(C4::Context->preference('PatronSelfRegistrationDefaultCategory')); |
|
|
100 |
|
101 |
$template->param( |
103 |
$template->param( |
102 |
action => $action, |
104 |
action => $action, |
103 |
hidden => GetHiddenFields( $mandatory, $action ), |
105 |
hidden => GetHiddenFields( $mandatory, $action ), |
Lines 129-135
if ( $action eq 'create' ) {
Link Here
|
129 |
my %borrower = ParseCgiForBorrower($cgi); |
131 |
my %borrower = ParseCgiForBorrower($cgi); |
130 |
|
132 |
|
131 |
%borrower = DelEmptyFields(%borrower); |
133 |
%borrower = DelEmptyFields(%borrower); |
132 |
$borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); |
134 |
$borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory; |
133 |
|
135 |
|
134 |
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); |
136 |
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); |
135 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
137 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
Lines 238-244
if ( $action eq 'create' ) {
Link Here
|
238 |
{ borrowernumber => $patron->borrowernumber }, |
240 |
{ borrowernumber => $patron->borrowernumber }, |
239 |
$template, |
241 |
$template, |
240 |
1, |
242 |
1, |
241 |
C4::Context->preference('PatronSelfRegistrationDefaultCategory') |
243 |
$PatronSelfRegistrationDefaultCategory |
242 |
); |
244 |
); |
243 |
} |
245 |
} |
244 |
|
246 |
|
245 |
- |
|
|