Bug 34478: Manual fix - change op to action - opac-memberentry

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2024-01-31 10:02:30 -05:00 committed by Jonathan Druart
parent 632146366a
commit fd03feab5d
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0
2 changed files with 45 additions and 45 deletions

View file

@ -32,12 +32,12 @@
[% END %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF action == 'edit' %]Update your personal details[% ELSE %]Register a new account[% END %] &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
<title>[% IF op == 'edit' %]Update your personal details[% ELSE %]Register a new account[% END %] &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% IF action == 'edit' %]
[% IF op == 'edit' %]
[% INCLUDE 'bodytag.inc' bodyid='opac-patron-update' %]
[% ELSE %]
<body id="opac-patron-registration" class="opac">
@ -47,7 +47,7 @@
<div class="main">
[% WRAPPER breadcrumbs %]
[% IF action == 'edit' %]
[% IF op == 'edit' %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
[% END %]
@ -72,13 +72,13 @@
<h1>Your personal details</h1>
[% IF action == 'edit' %]
[% IF op == 'edit' %]
<div id="update-account" class="maincontent">
[% ELSE %]
<div id="add-account" class="maincontent">
[% END %]
[% IF action == 'edit' %]
[% IF op == 'edit' %]
[% UNLESS OPACPatronDetails %]
<div class="alert alert-info">To make changes to your record please contact the library.</div>
[% END %]
@ -209,6 +209,7 @@
[% END %]
<form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
[% INCLUDE 'csrf-token.inc' %]
[% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %]
[% IF mandatory.defined( field ) %]
@ -229,7 +230,7 @@
<label for="borrower_cardnumber" class="[% required.cardnumber | html %]">Library card number:</label>
[% IF borrower && !(cardnumber_wrong_length || cardnumber_already_exists) && action == 'edit' %]
[% IF borrower && !(cardnumber_wrong_length || cardnumber_already_exists) && op == 'edit' %]
[% borrower.cardnumber | html %]
[% ELSE %]
[% IF minlength_cardnumber == maxlength_cardnumber %]
@ -253,7 +254,7 @@
</li>
[% END %]
[% IF action != 'new' %]
[% IF op != 'new' %]
[% UNLESS hidden.defined('userid') %]
<li>
<label>Username:</label>
@ -596,7 +597,7 @@
<div class="required_label [% required.email | html %]">Required</div>
</li>
[% IF action != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
[% IF op != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
<li>
<label for="borrower_repeat_email" class="[% required.email | html %]">Confirm primary email:</label>
@ -929,7 +930,7 @@
</div> <!-- /.row -->
[% END %]
[% UNLESS action == 'edit' || hidden.defined('password') %]
[% UNLESS op == 'edit' || hidden.defined('password') %]
<div class="row">
<div class="col">
<fieldset class="rows" id="memberentry_password">
@ -1032,7 +1033,7 @@
</div> <!-- /.row -->
[% END %]
[% IF Koha.Preference('PrivacyPolicyConsent') && action != 'edit' %]
[% IF Koha.Preference('PrivacyPolicyConsent') && op != 'edit' %]
<div class="row">
<div class="col">
<fieldset class="rows" id="memberentry_gdpr_consent">
@ -1053,7 +1054,7 @@
</div> <!-- /.row -->
[% END %]
[% UNLESS action == 'edit' %]
[% UNLESS op == 'edit' %]
<div class="row">
<div class="col">
<fieldset class="rows" id="memberentry_captcha">
@ -1077,17 +1078,16 @@
<div class="row">
<div class="col">
[% IF action == 'edit' %]
[% IF op == 'edit' %]
[% IF OPACPatronDetails %]
<fieldset class="action">
<input type="hidden" name="action" value="update" />
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-update" />
<input type="submit" class="btn btn-primary" value="Submit update request" />
</fieldset>
[% END %]
[% ELSE %]
<fieldset class="action">
<input type="hidden" name="action" value="create" />
<input type="hidden" name="op" value="cud-create" />
<input type="submit" class="btn btn-primary" value="Submit" />
</fieldset>
[% END %]
@ -1111,7 +1111,7 @@
<script>
$(document).ready(function() {
[% IF action == 'edit' && !OPACPatronDetails %]
[% IF op == 'edit' && !OPACPatronDetails %]
$("#memberentry-form :input").attr('readonly', true);
$("#borrower_branchcode").attr('disabled',true);
$("#borrower_title").attr('disabled',true);
@ -1250,7 +1250,7 @@
} );
});
[% IF action != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
[% IF op != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
$("#borrower_email").bind("cut copy paste", function(e){
e.preventDefault();
$("#borrower_email").bind("contextmenu", function(e){

View file

@ -56,18 +56,18 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $action = $cgi->param('action') || q{};
if ( $borrowernumber && ( $action eq 'create' || $action eq 'new' ) ) {
my $op = $cgi->param('op') || q{};
if ( $borrowernumber && ( $op eq 'cud-create' || $op eq 'new' ) ) {
print $cgi->redirect("/cgi-bin/koha/opac-main.pl");
exit;
}
if ( $action eq q{} ) {
if ( $op eq q{} ) {
if ($borrowernumber) {
$action = 'cud-edit';
$op = 'edit';
}
else {
$action = 'new';
$op = 'new';
}
}
@ -75,16 +75,16 @@ my $PatronSelfRegistrationDefaultCategory = C4::Context->preference('PatronSelfR
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 ) )
|| ( ( $op eq 'new' || $op eq 'cud-create' ) && !$defaultCategory ) )
{
print $cgi->redirect("/cgi-bin/koha/opac-main.pl");
exit;
}
my $mandatory = GetMandatoryFields($action);
my $mandatory = GetMandatoryFields($op);
my $params = {};
if ( $action eq 'create' || $action eq 'new' ) {
if ( $op eq 'cud-create' || $op eq 'new' ) {
my @PatronSelfRegistrationLibraryList = split '\|', C4::Context->preference('PatronSelfRegistrationLibraryList');
$params = { branchcode => { -in => \@PatronSelfRegistrationLibraryList } }
if @PatronSelfRegistrationLibraryList;
@ -102,8 +102,8 @@ if ( defined $min ) {
my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', C4::Context->preference('template') );
$template->param(
action => $action,
hidden => GetHiddenFields( $mandatory, $action ),
op => $op,
hidden => GetHiddenFields( $mandatory, $op ),
mandatory => $mandatory,
libraries => $libraries,
OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
@ -127,14 +127,14 @@ foreach my $attr (@$attributes) {
}
}
if ( $action eq 'create' ) {
if ( $op eq 'cud-create' ) {
my %borrower = ParseCgiForBorrower($cgi);
%borrower = DelEmptyFields(%borrower);
$borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory;
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $op ), CheckMandatoryAttributes( \%borrower, $attributes ) );
my $invalidformfields = CheckForInvalidFields(\%borrower);
delete $borrower{'password2'};
my $is_cardnumber_valid;
@ -311,7 +311,7 @@ if ( $action eq 'create' ) {
}
}
}
elsif ( $action eq 'cud-update' ) {
elsif ( $op eq 'cud-update' ) {
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
@ -319,7 +319,7 @@ elsif ( $action eq 'cud-update' ) {
$borrower{borrowernumber} = $borrowernumber;
my @empty_mandatory_fields = grep { $_ ne 'password' } # password is not required when editing personal details
( CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
( CheckMandatoryFields( \%borrower, $op ), CheckMandatoryAttributes( \%borrower, $attributes ) );
my $invalidformfields = CheckForInvalidFields(\%borrower);
# Send back the data to the template
@ -333,7 +333,7 @@ elsif ( $action eq 'cud-update' ) {
);
$template->param( patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber, $attributes ) );
$template->param( action => 'cud-edit' );
$template->param( op => 'edit' );
}
else {
my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
@ -371,7 +371,7 @@ elsif ( $action eq 'cud-update' ) {
else {
my $patron = Koha::Patrons->find( $borrowernumber );
$template->param(
action => 'cud-edit',
op => 'edit',
nochanges => 1,
borrower => $patron->unblessed,
patron_attribute_classes => GeneratePatronAttributesForm( $borrowernumber, $attributes ),
@ -379,13 +379,13 @@ elsif ( $action eq 'cud-update' ) {
}
}
}
elsif ( $action eq 'cud-edit' ) { #Display logged in borrower's data
elsif ( $op eq 'edit' ) { #Display logged in borrower's data
my $patron = Koha::Patrons->find( $borrowernumber );
my $borrower = $patron->unblessed;
$template->param(
borrower => $borrower,
hidden => GetHiddenFields( $mandatory, 'cud-edit' ),
hidden => GetHiddenFields( $mandatory, 'edit' ),
);
if (C4::Context->preference('OPACpatronimages')) {
@ -413,10 +413,10 @@ $template->param(
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
sub GetHiddenFields {
my ( $mandatory, $action ) = @_;
my ( $mandatory, $op ) = @_;
my %hidden_fields;
my $BorrowerUnwantedField = $action eq 'cud-edit' || $action eq 'cud-update' ?
my $BorrowerUnwantedField = $op eq 'edit' || $op eq 'cud-update' ?
C4::Context->preference( "PatronSelfModificationBorrowerUnwantedField" ) :
C4::Context->preference( "PatronSelfRegistrationBorrowerUnwantedField" );
@ -432,22 +432,22 @@ sub GetHiddenFields {
}
sub GetMandatoryFields {
my ($action) = @_;
my ($op) = @_;
my %mandatory_fields;
my $BorrowerMandatoryField = $action eq 'cud-edit' || $action eq 'cud-update' ?
my $BorrowerMandatoryField = $op eq 'edit' || $op eq 'cud-update' ?
C4::Context->preference("PatronSelfModificationMandatoryField") :
C4::Context->preference("PatronSelfRegistrationBorrowerMandatoryField");
my @fields = split( /\|/, $BorrowerMandatoryField );
push @fields, 'gdpr_proc_consent' if C4::Context->preference('PrivacyPolicyConsent') && $action eq 'create';
push @fields, 'gdpr_proc_consent' if C4::Context->preference('PrivacyPolicyConsent') && $op eq 'cud-create';
foreach (@fields) {
$mandatory_fields{$_} = 1;
}
if ( $action eq 'create' || $action eq 'new' ) {
if ( $op eq 'cud-create' || $op eq 'new' ) {
$mandatory_fields{'email'} = 1
if C4::Context->preference(
'PatronSelfRegistrationVerifyByEmail');
@ -457,11 +457,11 @@ sub GetMandatoryFields {
}
sub CheckMandatoryFields {
my ( $borrower, $action ) = @_;
my ( $borrower, $op ) = @_;
my @empty_mandatory_fields;
my $mandatory_fields = GetMandatoryFields($action);
my $mandatory_fields = GetMandatoryFields($op);
delete $mandatory_fields->{'cardnumber'};
foreach my $key ( keys %$mandatory_fields ) {
@ -569,11 +569,11 @@ sub ParseCgiForBorrower {
sub DelUnchangedFields {
my ( $borrowernumber, %new_data ) = @_;
# get the mandatory fields so we can get the hidden fields
my $mandatory = GetMandatoryFields('cud-edit');
my $mandatory = GetMandatoryFields('edit');
my $patron = Koha::Patrons->find( $borrowernumber );
my $current_data = $patron->unblessed;
# get the hidden fields so we don't obliterate them should they have data patrons aren't allowed to modify
my $hidden_fields = GetHiddenFields($mandatory, 'cud-edit');
my $hidden_fields = GetHiddenFields($mandatory, 'edit');
foreach my $key ( keys %new_data ) {