Lines 24-29
use Try::Tiny;
Link Here
|
24 |
|
24 |
|
25 |
# external modules |
25 |
# external modules |
26 |
use CGI qw ( -utf8 ); |
26 |
use CGI qw ( -utf8 ); |
|
|
27 |
use List::Util qw ( all ); |
27 |
|
28 |
|
28 |
# internal modules |
29 |
# internal modules |
29 |
use C4::Auth qw( get_template_and_user haspermission ); |
30 |
use C4::Auth qw( get_template_and_user haspermission ); |
Lines 164-171
foreach (@field_check) {
Link Here
|
164 |
$template->param( "quickadd" => 1 ) if ($quickadd); |
165 |
$template->param( "quickadd" => 1 ) if ($quickadd); |
165 |
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); |
166 |
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); |
166 |
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); |
167 |
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); |
|
|
168 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
169 |
|
167 |
if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { |
170 |
if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { |
168 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
|
|
169 |
output_and_exit_if_error( |
171 |
output_and_exit_if_error( |
170 |
$input, $cookie, $template, |
172 |
$input, $cookie, $template, |
171 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } |
173 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } |
Lines 627-633
if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) )
Link Here
|
627 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
629 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
628 |
and $input->param('setting_extended_patron_attributes') ) |
630 |
and $input->param('setting_extended_patron_attributes') ) |
629 |
{ |
631 |
{ |
630 |
$patron->extended_attributes($extended_patron_attributes); |
632 |
$patron->extended_attributes( $extended_patron_attributes, { check_editable => 1 } ); |
631 |
} |
633 |
} |
632 |
|
634 |
|
633 |
if ( |
635 |
if ( |
Lines 927-933
sub patron_attributes_form {
Link Here
|
927 |
|
929 |
|
928 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
930 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
929 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
931 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
930 |
if ( $attribute_types->count == 0 ) { |
932 |
if ( $attribute_types->count == 0 || ( !$logged_in_user->is_superlibrarian && all { $_->hidden } $attribute_types->as_list ) ) { |
931 |
$template->param( no_patron_attribute_types => 1 ); |
933 |
$template->param( no_patron_attribute_types => 1 ); |
932 |
return; |
934 |
return; |
933 |
} |
935 |
} |
Lines 941-952
sub patron_attributes_form {
Link Here
|
941 |
my @attribute_loop = (); |
943 |
my @attribute_loop = (); |
942 |
my $i = 0; |
944 |
my $i = 0; |
943 |
my %items_by_class; |
945 |
my %items_by_class; |
|
|
946 |
my @hidden_attributes; |
947 |
|
948 |
my $is_superlibrarian = $logged_in_user->is_superlibrarian; |
944 |
while ( my ($attr_type) = $attribute_types->next ) { |
949 |
while ( my ($attr_type) = $attribute_types->next ) { |
945 |
my $entry = { |
950 |
my $entry = { |
946 |
class => $attr_type->class(), |
951 |
class => $attr_type->class(), |
947 |
code => $attr_type->code(), |
952 |
code => $attr_type->code(), |
948 |
description => $attr_type->description(), |
953 |
description => $attr_type->description(), |
949 |
repeatable => $attr_type->repeatable(), |
954 |
repeatable => $attr_type->repeatable(), |
|
|
955 |
hidden => !$is_superlibrarian && $attr_type->hidden(), |
956 |
readonly => !$is_superlibrarian && $attr_type->readonly(), |
957 |
secret => !$is_superlibrarian && $attr_type->secret(), |
950 |
category => $attr_type->authorised_value_category(), |
958 |
category => $attr_type->authorised_value_category(), |
951 |
category_code => $attr_type->category_code(), |
959 |
category_code => $attr_type->category_code(), |
952 |
mandatory => $attr_type->mandatory(), |
960 |
mandatory => $attr_type->mandatory(), |
Lines 957-971
sub patron_attributes_form {
Link Here
|
957 |
my $newentry = {%$entry}; |
965 |
my $newentry = {%$entry}; |
958 |
$newentry->{value} = $attr->{attribute}; |
966 |
$newentry->{value} = $attr->{attribute}; |
959 |
$newentry->{use_dropdown} = 0; |
967 |
$newentry->{use_dropdown} = 0; |
960 |
if ( $attr_type->authorised_value_category() ) { |
|
|
961 |
$newentry->{use_dropdown} = 1; |
962 |
$newentry->{auth_val_loop} = |
963 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
964 |
} |
965 |
$i++; |
968 |
$i++; |
966 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
|
|
967 |
$newentry->{form_id} = "patron_attr_$i"; |
969 |
$newentry->{form_id} = "patron_attr_$i"; |
968 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
970 |
if (!$is_superlibrarian && ( $attr_type->hidden() || $attr_type->secret() ) ) { |
|
|
971 |
push @hidden_attributes, $newentry; |
972 |
} else { |
973 |
if ( $attr_type->authorised_value_category() ) { |
974 |
$newentry->{use_dropdown} = 1; |
975 |
$newentry->{auth_val_loop} = |
976 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
977 |
} |
978 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
979 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
980 |
} |
969 |
} |
981 |
} |
970 |
} else { |
982 |
} else { |
971 |
$i++; |
983 |
$i++; |
Lines 988-994
sub patron_attributes_form {
Link Here
|
988 |
}; |
1000 |
}; |
989 |
} |
1001 |
} |
990 |
|
1002 |
|
991 |
$template->param( patron_attributes => \@attribute_loop ); |
1003 |
$template->param( patron_attributes => \@attribute_loop, hidden_patron_attributes => \@hidden_attributes ); |
992 |
|
1004 |
|
993 |
} |
1005 |
} |
994 |
|
1006 |
|