# external modules
use CGI qw ( -utf8 );
-use List::MoreUtils qw/uniq/;
# internal modules
-use C4::Auth;
+use C4::Auth qw( get_template_and_user haspermission );
use C4::Context;
-use C4::Output;
-use C4::Members;
-use C4::Koha;
-use C4::Log;
-use C4::Letters;
+use C4::Output qw( output_and_exit output_and_exit_if_error output_html_with_http_headers );
+use C4::Members qw( checkcardnumber get_cardnumber_length );
+use C4::Koha qw( GetAuthorisedValues );
+use C4::Letters qw( SendAlerts );
use C4::Form::MessagingPreferences;
use Koha::AuthUtils;
use Koha::AuthorisedValues;
-use Koha::Patron::Debarments;
+use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments );
use Koha::Cities;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Libraries;
use Koha::Patrons;
use Koha::Patron::Attribute::Types;
use Email::Valid;
use Koha::SMS::Providers;
-use vars qw($debug);
-
-BEGIN {
- $debug = $ENV{DEBUG} || 0;
-}
-
-my $input = new CGI;
-($debug) or $debug = $input->param('debug') || 0;
+my $input = CGI->new;
my %data;
my $dbh = C4::Context->dbh;
= get_template_and_user({template_name => "members/memberentrygen.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => {borrowers => 'edit_borrowers'},
- debug => ($debug) ? 1 : 0,
});
my $borrowernumber = $input->param('borrowernumber');
## Deal with guarantor stuff
$template->param( relationships => scalar $patron->guarantor_relationships ) if $patron;
-my @relations = split /,|\|/, C4::Context->preference('borrowerRelationship');
+my @relations = split /\|/, C4::Context->preference('borrowerRelationship'), -1;
+@relations = ('') unless @relations;
my $empty_relationship_allowed = grep {$_ eq ""} @relations;
$template->param( empty_relationship_allowed => $empty_relationship_allowed );
if ( $formatteddate ) {
$newdata{$_} = $formatteddate;
} else {
- ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
$template->param( "ERROR_$_" => 1 );
push(@errors,"ERROR_$_");
}
qr/^\d+-DAYS/,
qr/^patron_attr_/,
qr/^csrf_token$/,
- qr/^add_debarment$/, qr/^debarred_expiration$/, qr/^remove_debarment$/, # We already dealt with debarments previously
+ qr/^add_debarment$/, qr/^debarred_comment$/,qr/^debarred_expiration$/, qr/^remove_debarment$/, # We already dealt with debarments previously
qr/^housebound_chooser$/, qr/^housebound_deliverer$/,
qr/^select_city$/,
qr/^new_guarantor_/,
$newdata{'userid'} = $data{'userid'};
}
}
-
-$debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
+
my $extended_patron_attributes;
if ($op eq 'save' || $op eq 'insert'){
if (C4::Context->preference("IndependentBranches")) {
unless ( C4::Context->IsSuperLibrarian() ){
- $debug and print STDERR " $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
push @errors, "ERROR_branch";
}
# 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';
for my $attr ( @$extended_patron_attributes ) {
$attr->{borrowernumber} = $borrowernumber if $borrowernumber;
my $attribute = Koha::Patron::Attribute->new($attr);
- eval {$attribute->check_unique_id};
- if ( $@ ) {
+ if ( !$attribute->unique_ok ) {
push @errors, "ERROR_extended_unique_id_failed";
my $attr_type = Koha::Patron::Attribute::Types->find($attr->{code});
$template->param(
### Error checks should happen before this line.
$nok = $nok || scalar(@errors);
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
- $debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
my $success;
if ($op eq 'insert'){
# we know it's not a duplicate borrowernumber or there would already be an error
delete $newdata{'B_email'};
}
- $newdata{debarredcomment} = $newdata{debarred_comment};
- delete $newdata{debarred_comment};
delete $newdata{password2};
eval {
my $no_categories = 1;
my $no_add;
foreach my $category_type (qw(C A S P I X)) {
- my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => $category_type }, {order_by => ['categorycode']});
+ my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => $category_type }, {order_by => ['categorycode']});
$no_categories = 0 if $patron_categories->count > 0;
my @categoryloop;
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 ),
};
);
my $cities = Koha::Cities->search( {}, { order_by => 'city_name' } );
-my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE' );
$template->param(
- roadtypes => $roadtypes,
cities => $cities,
);
}
$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
-$debug and warn "memberentry step: $step";
$template->param(%data);
$template->param( "step_$step" => 1) if $step; # associate with step to know where u are
$template->param( step => $step ) if $step; # associate with step to know where u are
$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++;
push @{$items_by_class{$attr_type->class()}}, $newentry;
}
}
- while ( my ($class, @items) = each %items_by_class ) {
+ for my $class ( sort keys %items_by_class ) {
my $av = Koha::AuthorisedValues->search({ category => 'PA_CLASS', authorised_value => $class });
my $lib = $av->count ? $av->next->lib : $class;
push @attribute_loop, {
class => $class,
- items => @items,
+ items => $items_by_class{$class},
lib => $lib,
}
}