Fix for Bug 6980, Patron attributes are shown when ExtendedPatronAttributes is disabled

This patch adds a check for the value of the ExtendedPatronAttributes
preference to the scripts and corresponding logic to the templates
controlling the sidebar menu.

The patch also corrects a duplication of attributes code in moremember.pl

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
1) Added extended patron attributes in configuration, turned ExtendedPatronAttributes on
2) Altered patron details, added values for patron attributes
> Verified patron attributes show show correctly
3) Turned off ExtendedPatronAttributes
> Verified patron attributes were hidden everywhere

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Owen Leonard 2011-10-06 14:27:16 -04:00 committed by Chris Cormack
parent aedb86a679
commit d150c98540
13 changed files with 83 additions and 29 deletions

View File

@ -632,7 +632,14 @@ my $fast_cataloging = 0;
if (defined getframeworkinfo('FA')) {
$fast_cataloging = 1
}
my $attributes = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
lib_messages_loop => $lib_messages_loop,
@ -682,7 +689,6 @@ $template->param(
circview => 1,
soundon => C4::Context->preference("SoundOn"),
fast_cataloging => $fast_cataloging,
extendedattributes => $attributes,
);
# save stickyduedate to session

View File

@ -48,13 +48,13 @@
<li> <span class="empty">No email stored.</span> </li>
[% END %]
[% END %]
[% FOREACH extendedattribute IN extendedattributes %]
[% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %]
[% IF ( extendedattribute.display_checkout ) %]
[% IF ( extendedattribute.value ) %]
<li>[% extendedattribute.description %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.value %][% END %]</li>
[% END %]
[% END %]
[% END %]
[% END %][% END %]
<li>Category: [% categoryname %] ([% categorycode %])</li>
<li>Home Library: [% IF ( branchname ) %][% branchname %][% ELSE %][% branch %][% END %]</li>
</ul></div>

View File

@ -50,13 +50,13 @@ in the global namespace %]
<li> <span class="empty">No email stored.</span> </li>
[% END %]
[% END %]
[% FOREACH extendedattribute IN borrower.extendedattributes %]
[% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN borrower.extendedattributes %]
[% IF ( extendedattribute.display_checkout ) %]
[% IF ( extendedattribute.value ) %]
<li>[% extendedattribute.description %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.value %][% END %]</li>
[% END %]
[% END %]
[% END %]
[% END %][% END %]
<li>Category: [% borrower.description %] ([% borrower.categorycode %])</li>
<li>Home Library: [% IF ( borrower.branchname ) %][% borrower.branchname %][% ELSE %][% borrower.branch %][% END %]</li>
</ul></div>

View File

@ -285,12 +285,12 @@ function validate1(date) {
<th>Type</th>
<th>Value</th>
</tr>
[% FOREACH patron_attribute IN patron_attributes %]
[% FOREACH extendedattribute IN extendedattributes %]
<tr>
<td>[% patron_attribute.code %] ([% patron_attribute.description %])</td>
<td>[% patron_attribute.value %]
[% IF ( patron_attribute.value_description ) %]
([% patron_attribute.value_description %])
<td>[% extendedattribute.code %] ([% extendedattribute.description %])</td>
<td>[% extendedattribute.value %]
[% IF ( extendedattribute.value_description ) %]
([% extendedattribute.value_description %])
[% END %]
</td>
</tr>

View File

@ -94,7 +94,14 @@ $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
my $attributes = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
finesview => 1,
@ -120,7 +127,6 @@ $template->param(
is_child => ($data->{'category_type'} eq 'C'),
reverse_col => $reverse_col,
accounts => $accts,
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -78,7 +78,14 @@ if ($add){
$template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
borrowernumber => $borrowernumber,
@ -99,7 +106,6 @@ if ($add){
branchcode => $data->{'branchcode'},
branchname => GetBranchName($data->{'branchcode'}),
is_child => ($data->{'category_type'} eq 'C'),
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;
}

View File

@ -106,8 +106,14 @@ if ($add){
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
my $attributes = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
borrowernumber => $borrowernumber,
firstname => $data->{'firstname'},
@ -127,7 +133,6 @@ if ($add){
branchcode => $data->{'branchcode'},
branchname => GetBranchName($data->{'branchcode'}),
is_child => ($data->{'category_type'} eq 'C'),
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;
}

View File

@ -162,7 +162,14 @@ if ($input->param('newflags')) {
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
borrowernumber => $bor->{'borrowernumber'},
@ -184,7 +191,6 @@ $template->param(
branchname => GetBranchName($bor->{'branchcode'}),
loop => \@loop,
is_child => ($bor->{'category_type'} eq 'C'),
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -90,7 +90,14 @@ if ( $newpassword && ! $errormsg ) {
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param( othernames => $bor->{'othernames'},
surname => $bor->{'surname'},
@ -114,7 +121,6 @@ my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
destination => $destination,
is_child => ($bor->{'category_type'} eq 'C'),
defaultnewpassword => $defaultnewpassword,
extendedattributes => $attributes,
);

View File

@ -425,8 +425,11 @@ my $branch=C4::Context->userenv->{'branch'};
$template->param(%$data);
if (C4::Context->preference('ExtendedPatronAttributes')) {
$template->param(ExtendedPatronAttributes => 1);
$template->param(patron_attributes => C4::Members::Attributes::GetBorrowerAttributes($borrowernumber));
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
my @types = C4::Members::AttributeTypes::GetAttributeTypes();
if (scalar(@types) == 0) {
$template->param(no_patron_attribute_types => 1);
@ -439,7 +442,6 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) {
$template->param(SMSSendDriver => C4::Context->preference("SMSSendDriver"));
$template->param(SMSnumber => defined $data->{'smsalertnumber'} ? $data->{'smsalertnumber'} : $data->{'mobile'});
}
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
detailview => 1,
@ -469,7 +471,6 @@ $template->param(
"dateformat_" . (C4::Context->preference("dateformat") || '') => 1,
samebranch => $samebranch,
quickslip => $quickslip,
extendedattributes => $attributes,
);
#Get the slip news items

View File

@ -53,7 +53,14 @@ $template->param( picture => 1 ) if $picture;
# Getting the messages
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
$template->param( %{$borrower} );
my $attributes = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
QUEUED_MESSAGES => $queued_messages,
@ -61,7 +68,6 @@ $template->param(
sentnotices => 1,
branchname => GetBranchName($borrower->{'branchcode'}),
categoryname => $borrower->{'description'},
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -233,7 +233,13 @@ sub borrower_add_additional_fields {
if ($picture) {
$b_ref->{has_picture} = 1;
}
$b_ref->{extendedattributes} = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
$b_ref->{extendedattributes} = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
);
}
$b_ref->{branchname} = GetBranchName( $b_ref->{branchcode} );
return;

View File

@ -96,7 +96,14 @@ if (! $limit){
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
my $attributes = GetBorrowerAttributes($borrowernumber);
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
ExtendedPatronAttributes => 1,
extendedattributes => $attributes
);
}
$template->param(
readingrecordview => 1,
@ -125,7 +132,6 @@ $template->param(
branchname => GetBranchName($data->{'branchcode'}),
showfulllink => (scalar @loop_reading > 50),
loop_reading => \@loop_reading,
extendedattributes => $attributes,
);
output_html_with_http_headers $input, $cookie, $template->output;