$debug = $ENV{DEBUG} || 0;
}
-my $input = new CGI;
+my $input = CGI->new;
($debug) or $debug = $input->param('debug') || 0;
my %data;
= get_template_and_user({template_name => "members/memberentrygen.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => {borrowers => 'edit_borrowers'},
debug => ($debug) ? 1 : 0,
});
my @errors;
my $borrower_data;
my $NoUpdateLogin;
+my $NoUpdateEmail;
my $userenv = C4::Context->userenv;
my @messages;
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
+ # check permission to modify email info.
+ if ( $patron->is_superlibrarian && !$logged_in_user->is_superlibrarian ) {
+ $NoUpdateEmail = 1;
+ }
+
$borrower_data = $patron->unblessed;
$borrower_data->{category_type} = $patron->category->category_type;
}
push(@errors,"ERROR_$_");
}
}
- # check permission to modify login info.
+
+ # check permission to modify login info.
if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) {
$NoUpdateLogin = 1;
}
# the edited values list when editing certain sub-forms. Get it straight
# from the DB if absent.
my $userid = $newdata{ userid } // $borrower_data->{ userid };
- my $p = $borrowernumber ? Koha::Patrons->find( $borrowernumber ) : Koha::Patron->new;
+ my $p = $borrowernumber ? Koha::Patrons->find( $borrowernumber ) : Koha::Patron->new();
$p->userid( $userid );
unless ( $p->has_valid_userid ) {
push @errors, "ERROR_login_exist";
push @errors, "ERROR_password_mismatch" if ( $password ne $password2 );
if ( $password and $password ne '****' ) {
- my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password );
+ my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, Koha::Patron::Categories->find($categorycode) );
unless ( $is_valid ) {
push @errors, 'ERROR_password_too_short' if $error eq 'too_short';
push @errors, 'ERROR_password_too_weak' if $error eq 'too_weak';
}
$patron = Koha::Patrons->find( $borrowernumber );
+
+ if ($NoUpdateEmail) {
+ delete $newdata{'email'};
+ delete $newdata{'emailpro'};
+ delete $newdata{'B_email'};
+ }
+
$newdata{debarredcomment} = $newdata{debarred_comment};
delete $newdata{debarred_comment};
delete $newdata{password2};
push @categoryloop,
{ 'categorycode' => $patron_category->categorycode,
'categoryname' => $patron_category->description,
+ 'effective_min_password_length' => $patron_category->effective_min_password_length,
+ 'effective_require_strong_password' => $patron_category->effective_require_strong_password,
'categorycodeselected' =>
( defined($categorycode) && $patron_category->categorycode eq $categorycode ),
};
modify => $modify,
nok => $nok,#flag to know if an error
NoUpdateLogin => $NoUpdateLogin,
+ NoUpdateEmail => $NoUpdateEmail,
);
# Generate CSRF token
$i++;
undef $newentry->{value} if ($attr_type->unique_id() && $op eq 'duplicate');
$newentry->{form_id} = "patron_attr_$i";
- push @{$items_by_class{$attr_type->{class}}}, $newentry;
+ push @{$items_by_class{$attr_type->class()}}, $newentry;
}
} else {
$i++;