Bugzilla – Attachment 103968 Details for
Bug 22844
Simplify the process of selecting database columns for system preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22844: Make the patron's attribute mandatory at the OPAC
Bug-22844-Make-the-patrons-attribute-mandatory-at-.patch (text/plain), 4.93 KB, created by
Victor Grousset/tuxayo
on 2020-04-29 16:37:30 UTC
(
hide
)
Description:
Bug 22844: Make the patron's attribute mandatory at the OPAC
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2020-04-29 16:37:30 UTC
Size:
4.93 KB
patch
obsolete
>From 876dfc0ba906137db4e54bc3799946c355a1ad1b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 Apr 2020 13:09:49 +0200 >Subject: [PATCH] Bug 22844: Make the patron's attribute mandatory at the OPAC > >Test plan: >- Set 1+ patron's attribute(s) mandatory >- Use the self-registration feature and confirm that you cannot selfreg >if the attribute has no value (or empty string) >- Same with the modification form (logged in) > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > .../bootstrap/en/modules/opac-memberentry.tt | 9 +++++++- > opac/opac-memberentry.pl | 21 ++++++++++++++++--- > 2 files changed, 26 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 35af40224f..616d95eae7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -907,7 +907,11 @@ > [% IF loop.first %]<a name="patron-attr-start-[% pa.type.code | html %]"></a>[% END %] > [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %] > <li data-category_code="[% pa.type.category_code | html %]"> >- <label for="[% form_id | html %]">[% pa.type.description | html %]: </label> >+ [% IF pa.type.mandatory && pa.type.opac_editable %] >+ <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label> >+ [% ELSE %] >+ <label for="[% form_id | html %]">[% pa.type.description | html %]: </label> >+ [% END %] > [% IF pa.type.opac_editable %] > <input type="hidden" name="patron_attribute_code" value="[% pa.type.code | html %]" /> > [% IF ( pa.type.authorised_value_category ) %] >@@ -928,6 +932,9 @@ > [% ELSE %] > <textarea rows="2" cols="30" id="[% form_id | html %]" name="patron_attribute_value">[% pa_value | html %]</textarea> > [% END %] >+ [% IF pa.type.mandatory %] >+ <span class="required">Required</span> >+ [% END %] > <a href="#" class="clear-attribute">Clear</a> > [% IF ( pa.type.repeatable ) %] > <a href="#" class="clone-attribute">New</a> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index faf32e8285..d2b4eb28e6 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -123,7 +123,7 @@ if ( $action eq 'create' ) { > > %borrower = DelEmptyFields(%borrower); > >- my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action ); >+ my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); > my $invalidformfields = CheckForInvalidFields(\%borrower); > delete $borrower{'password2'}; > my $cardnumber_error_code; >@@ -259,7 +259,7 @@ elsif ( $action eq 'update' ) { > $borrower{borrowernumber} = $borrowernumber; > > my @empty_mandatory_fields = >- CheckMandatoryFields( \%borrower, $action ); >+ ( CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); > my $invalidformfields = CheckForInvalidFields(\%borrower); > > # Send back the data to the template >@@ -412,6 +412,20 @@ sub CheckMandatoryFields { > return @empty_mandatory_fields; > } > >+sub CheckMandatoryAttributes{ >+ my ( $borrower, $attributes ) = @_; >+ >+ my @empty_mandatory_fields; >+ >+ for my $attribute (@$attributes ) { >+ my $attr = Koha::Patron::Attribute::Types->find($attribute->{code}); >+ push @empty_mandatory_fields, $attribute->{code} >+ if $attr && $attr->mandatory && $attribute->{attribute} =~ m|^\s*$|; >+ } >+ >+ return @empty_mandatory_fields; >+} >+ > sub CheckForInvalidFields { > my $borrower = shift; > my @invalidFields; >@@ -689,7 +703,8 @@ sub ParsePatronAttributes { > } > > foreach my $code ( keys %{$delete_candidates} ) { >- if ( Koha::Patron::Attributes->search({ >+ if ( not $borrowernumber # self-registration >+ || Koha::Patron::Attributes->search({ > borrowernumber => $borrowernumber, code => $code })->count > 0 ) > { > push @attributes, { code => $code, attribute => '' } >-- >2.26.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 22844
:
89322
|
89323
|
89389
|
89403
|
89530
|
89531
|
89749
|
89903
|
89904
|
89905
|
90407
|
96007
|
98145
|
98146
|
98147
|
98148
|
98149
|
98150
|
98151
|
98297
|
98298
|
100440
|
100441
|
100442
|
100443
|
100444
|
100445
|
100446
|
100447
|
101198
|
101199
|
101200
|
101201
|
101202
|
101203
|
101204
|
101205
|
101302
|
101480
|
101481
|
101482
|
101483
|
101484
|
101485
|
101486
|
101487
|
101488
|
101617
|
101618
|
101619
|
101620
|
101621
|
101622
|
101623
|
101624
|
103842
|
103843
|
103844
|
103845
|
103846
|
103847
|
103848
|
103849
|
103850
|
103904
|
103960
|
103961
|
103962
|
103963
|
103964
|
103965
|
103966
|
103967
|
103968
|
103969
|
106545
|
106546
|
106547
|
106548
|
106549
|
106550
|
106551
|
106552
|
106553
|
106554
|
107126