From d150c98540e98cf783a7e06b1de76988cd4752c2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 6 Oct 2011 14:27:16 -0400 Subject: [PATCH] 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 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 --- circ/circulation.pl | 10 ++++++++-- koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc | 4 ++-- koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt | 4 ++-- .../prog/en/modules/members/moremember.tt | 10 +++++----- members/boraccount.pl | 10 ++++++++-- members/mancredit.pl | 8 +++++++- members/maninvoice.pl | 9 +++++++-- members/member-flags.pl | 10 ++++++++-- members/member-password.pl | 10 ++++++++-- members/moremember.pl | 9 +++++---- members/notices.pl | 10 ++++++++-- members/pay.pl | 8 +++++++- members/readingrec.pl | 10 ++++++++-- 13 files changed, 83 insertions(+), 29 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index bbcccd5340..efb87da7c9 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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 diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index a9fd453b9f..67300d5af4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -48,13 +48,13 @@
  • No email stored.
  • [% END %] [% END %] - [% FOREACH extendedattribute IN extendedattributes %] + [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %] [% IF ( extendedattribute.display_checkout ) %] [% IF ( extendedattribute.value ) %]
  • [% extendedattribute.description %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.value %][% END %]
  • [% END %] [% END %] - [% END %] + [% END %][% END %]
  • Category: [% categoryname %] ([% categorycode %])
  • Home Library: [% IF ( branchname ) %][% branchname %][% ELSE %][% branch %][% END %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt index 47c1290f9b..fe04b63cba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt @@ -50,13 +50,13 @@ in the global namespace %]
  • No email stored.
  • [% END %] [% END %] - [% FOREACH extendedattribute IN borrower.extendedattributes %] + [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN borrower.extendedattributes %] [% IF ( extendedattribute.display_checkout ) %] [% IF ( extendedattribute.value ) %]
  • [% extendedattribute.description %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.value %][% END %]
  • [% END %] [% END %] - [% END %] + [% END %][% END %]
  • Category: [% borrower.description %] ([% borrower.categorycode %])
  • Home Library: [% IF ( borrower.branchname ) %][% borrower.branchname %][% ELSE %][% borrower.branch %][% END %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 3eb42f3dd7..49a56cf088 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -285,12 +285,12 @@ function validate1(date) { Type Value - [% FOREACH patron_attribute IN patron_attributes %] + [% FOREACH extendedattribute IN extendedattributes %] - [% patron_attribute.code %] ([% patron_attribute.description %]) - [% patron_attribute.value %] - [% IF ( patron_attribute.value_description ) %] - ([% patron_attribute.value_description %]) + [% extendedattribute.code %] ([% extendedattribute.description %]) + [% extendedattribute.value %] + [% IF ( extendedattribute.value_description ) %] + ([% extendedattribute.value_description %]) [% END %] diff --git a/members/boraccount.pl b/members/boraccount.pl index b197b3f14b..e16405ba85 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -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; diff --git a/members/mancredit.pl b/members/mancredit.pl index 801fcc2868..3c664c2ce6 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -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; } diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 9a040b6cc9..1f42093677 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -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; } diff --git a/members/member-flags.pl b/members/member-flags.pl index 00a326802f..76f300e398 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -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; diff --git a/members/member-password.pl b/members/member-password.pl index 03f5243e4a..25e9551c8d 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -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, ); diff --git a/members/moremember.pl b/members/moremember.pl index 7f47dd61e9..9115dd1dda 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -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 diff --git a/members/notices.pl b/members/notices.pl index a6e65c807e..41f2a903bf 100755 --- a/members/notices.pl +++ b/members/notices.pl @@ -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; diff --git a/members/pay.pl b/members/pay.pl index 9389f82018..6bc18fc774 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -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; diff --git a/members/readingrec.pl b/members/readingrec.pl index 04414e3d5d..8c0cd6f3f1 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -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; -- 2.39.5