use C4::Log;
use C4::Letters;
use C4::Form::MessagingPreferences;
+use Koha::AuthUtils;
use Koha::AuthorisedValues;
use Koha::Patron::Debarments;
use Koha::Cities;
use Koha::DateUtils;
use Koha::Libraries;
+use Koha::Patrons;
use Koha::Patron::Categories;
use Koha::Patron::HouseboundRole;
use Koha::Patron::HouseboundRoles;
$template->param("uppercasesurnames" => C4::Context->preference('uppercasesurnames'));
-my $minpw = C4::Context->preference('minPasswordLength');
-$template->param("minPasswordLength" => $minpw);
-
# function to designate mandatory fields (visually with css)
my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField");
my @field_check=split(/\|/,$check_BorrowerMandatoryField);
$template->param( "quickadd" => 1 ) if ( $quickadd );
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
-( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
+if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+ exit;
+ }
+
+ $borrower_data = $patron->unblessed;
+ $borrower_data->{category_type} = $patron->category->category_type;
+}
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
my $category_type = $input->param('category_type') || '';
unless ($category_type or !($categorycode)){
#recover all data from guarantor address phone ,fax...
if ( $guarantorid ) {
- if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
+ if (my $guarantor = Koha::Patrons->find( $guarantorid )) {
+ my $guarantordata = $guarantor->unblessed;
$category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
$guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
$newdata{'contactfirstname'}= $guarantordata->{'firstname'};
$newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode'));
$newdata{'country'} = $input->param('country') if defined($input->param('country'));
+$newdata{'lang'} = $input->param('lang') if defined($input->param('lang'));
+
# builds default userid
# userid input text may be empty or missing because of syspref BorrowerUnwantedField
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ ) {
my $dateofbirth;
if ($op eq 'save' && $step == 3) {
- my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
- $dateofbirth = $borrower->{dateofbirth};
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ $dateofbirth = $patron->dateofbirth;
}
else {
$dateofbirth = $newdata{dateofbirth};
unless (Check_Userid($userid,$borrowernumber)) {
push @errors, "ERROR_login_exist";
}
-
+
my $password = $input->param('password');
my $password2 = $input->param('password2');
push @errors, "ERROR_password_mismatch" if ( $password ne $password2 );
- push @errors, "ERROR_short_password" if( $password && $minpw && $password ne '****' && (length($password) < $minpw) );
+
+ if ( $password and $password ne '****' ) {
+ my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password );
+ 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';
+ push @errors, 'ERROR_password_has_whitespaces' if $error eq 'has_whitespaces';
+ }
+ }
# Validate emails
my $emailprimary = $input->param('email');
C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
}
}
- print scalar ($destination eq "circ") ?
- $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
- $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
- exit; # You can only send 1 redirect! After that, content or other headers don't matter.
+
+ if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) {
+ # If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission
+ $destination = 'not_circ';
+ }
+ print scalar( $destination eq "circ" )
+ ? $input->redirect(
+ "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber")
+ : $input->redirect(
+ "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"
+ );
+ exit; # You can only send 1 redirect! After that, content or other headers don't matter.
}
if ($delete){
# HouseboundModule data
$template->param(
- housebound_role => Koha::Patron::HouseboundRoles->find($borrowernumber),
+ housebound_role => scalar Koha::Patron::HouseboundRoles->find($borrowernumber),
);
if(defined($data{'flags'})){
);
}
+if ( C4::Context->preference('TranslateNotices') ) {
+ my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', C4::Context->preference('template') );
+ $template->param( languages => $translated_languages );
+}
+
output_html_with_http_headers $input, $cookie, $template->output;
sub parse_extended_patron_attributes {