From 036a6e0a9d828244861771ad77c9c751ab25d28d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 11 Jul 2016 22:06:46 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 16908: Koha::Patrons - Remove GetSortDetails Content-Type: text/plain; charset="utf-8" This subroutine was only used in one script and its job is the same as GetAuthorisedValueByCode. It's better to use the AuthorisedValues TT plugin to retrieve AV descriptions. Test plan: Edit a patron with sort1 and/or sort2 defined. On the patron details page (members/moremember.pl) you should see the sort1 and/or sort2 info displayed. Signed-off-by: Owen Leonard --- C4/Members.pm | 26 ---------------------- admin/aqbudgets.pl | 2 +- .../prog/en/modules/members/moremember.tt | 4 ++-- members/moremember.pl | 4 ---- t/db_dependent/Koha.t | 13 ++--------- 5 files changed, 5 insertions(+), 44 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 63e3f36..90de135 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -70,7 +70,6 @@ BEGIN { &GetNoticeEmailAddress &GetAge - &GetSortDetails &GetTitles &GetHideLostItemsPreference @@ -1496,31 +1495,6 @@ sub SetAge{ return $borrower; } # sub SetAge -=head2 GetSortDetails (OUEST-PROVENCE) - - ($lib) = &GetSortDetails($category,$sortvalue); - -Returns the authorized value details -C<&$lib>return value of authorized value details -C<&$sortvalue>this is the value of authorized value -C<&$category>this is the value of authorized value category - -=cut - -sub GetSortDetails { - my ( $category, $sortvalue ) = @_; - my $dbh = C4::Context->dbh; - my $query = qq|SELECT lib - FROM authorised_values - WHERE category=? - AND authorised_value=? |; - my $sth = $dbh->prepare($query); - $sth->execute( $category, $sortvalue ); - my $lib = $sth->fetchrow; - return ($lib) if ($lib); - return ($sortvalue) unless ($lib); -} - =head2 MoveMemberToDeleted $result = &MoveMemberToDeleted($borrowernumber); diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 0e6b744..1968fa8 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -30,7 +30,7 @@ use C4::Branch; # GetBranches use C4::Auth; use C4::Acquisition; use C4::Budgets; -use C4::Members; # calls GetSortDetails() +use C4::Members; use C4::Context; use C4::Output; use C4::Koha; 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 65bdb7a..1f8973a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -391,8 +391,8 @@ function validate1(date) { [% END %] - [% IF ( sort1 ) %]
  • Sort field 1:[% lib1 %]
  • [% END %] - [% IF ( sort2 ) %]
  • Sort field 2:[% lib2 %]
  • [% END %] + [% IF ( sort1 ) %]
  • Sort field 1:[% AuthorisedValues.GetByCode('Bsort1', sort1) %]
  • [% END %] + [% IF ( sort2 ) %]
  • Sort field 2:[% AuthorisedValues.GetByCode('Bsort2', sort2) %]
  • [% END %]
  • Username: [% userid %]
  • Password: [% IF ( password ) %] diff --git a/members/moremember.pl b/members/moremember.pl index 98286a0..cb589b6 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -209,10 +209,6 @@ my $library = Koha::Libraries->find( $data->{branchcode})->unblessed; @{$data}{keys %$library} = values %$library; # merge in all branch columns my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); -my $lib1 = &GetSortDetails( "Bsort1", $data->{'sort1'} ); -my $lib2 = &GetSortDetails( "Bsort2", $data->{'sort2'} ); -$template->param( lib1 => $lib1 ) if ($lib1); -$template->param( lib2 => $lib2 ) if ($lib2); # If printing a page, send the account informations to the template if ($print eq "page") { diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 82fdc5e..1fab9db 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -21,7 +21,7 @@ $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; subtest 'Authorized Values Tests' => sub { - plan tests => 7; + plan tests => 4; my $data = { category => 'CATEGORY', @@ -46,18 +46,9 @@ subtest 'Authorized Values Tests' => sub { # Tests SKIP: { - skip "INSERT failed", 4 unless $insert_success; + skip "INSERT failed", 1 unless $insert_success; is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); - - my $sortdet=C4::Members::GetSortDetails("lost", "3"); - is ($sortdet, "Lost and Paid For", "lost and paid works"); - - my $sortdet2=C4::Members::GetSortDetails("loc", "child"); - is ($sortdet2, "Children's Area", "Child area works"); - - my $sortdet3=C4::Members::GetSortDetails("withdrawn", "1"); - is ($sortdet3, "Withdrawn", "Withdrawn works"); } # Clean up -- 2.1.4