Bugzilla – Attachment 47002 Details for
Bug 15629
Move the C4::Branch related code to Koha::Libraries - part 3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15629: Koha::Libraries - Remove GetBranchInfo
Bug-15629-KohaLibraries---Remove-GetBranchInfo.patch (text/plain), 4.83 KB, created by
Jonathan Druart
on 2016-01-20 14:36:51 UTC
(
hide
)
Description:
Bug 15629: Koha::Libraries - Remove GetBranchInfo
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-01-20 14:36:51 UTC
Size:
4.83 KB
patch
obsolete
>From 9999d20d832eee4d9baf38795d56f2d512072baf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 20 Jan 2016 13:22:48 +0000 >Subject: [PATCH] Bug 15629: Koha::Libraries - Remove GetBranchInfo > >C4::Branch::GetBranchInfo was only used once in opac/opac-suggestions.pl >The occurrence can easily be replaced by a call to Koha::Libraries->find > >Test plan: >1/ Create a suggestion for library A >2/ Enable OPACViewOthersSuggestions >3/ Use a patron from library B to see the suggestions >4/ The "Suggested for" value should be correctly filled with the library >A name. >--- > C4/Branch.pm | 50 ------------------------------------------------ > opac/opac-suggestions.pl | 3 ++- > t/db_dependent/Branch.t | 18 +++++------------ > 3 files changed, 7 insertions(+), 64 deletions(-) > >diff --git a/C4/Branch.pm b/C4/Branch.pm >index b8eb9ca..9f82638 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -33,7 +33,6 @@ BEGIN { > &GetBranch > &GetBranches > &GetBranchesLoop >- &GetBranchInfo > &mybranch > ); > @EXPORT_OK = qw( &onlymine &mybranch ); >@@ -58,7 +57,6 @@ The functions in this module deal with branches. > $branches = &GetBranches(); > > Returns informations about ALL branches, IndependentBranches Insensitive. >-GetBranchInfo() returns the same information. > > Create a branch selector with the following code. > >@@ -185,54 +183,6 @@ sub GetBranch { > return $branch; > } > >-=head2 GetBranchInfo >- >-$results = GetBranchInfo($branchcode); >- >-returns C<$results>, a reference to an array of hashes containing branches. >-if $branchcode, just this branch, with associated categories. >-if ! $branchcode && $categorytype, all branches in the category. >- >-=cut >- >-sub GetBranchInfo { >- my ($branchcode,$categorytype) = @_; >- my $dbh = C4::Context->dbh; >- my $sth; >- >- >- if ($branchcode) { >- $sth = >- $dbh->prepare( >- "Select * from branches where branchcode = ? order by branchcode"); >- $sth->execute($branchcode); >- } >- else { >- $sth = $dbh->prepare("Select * from branches order by branchcode"); >- $sth->execute(); >- } >- my @results; >- while ( my $data = $sth->fetchrow_hashref ) { >- my @bind = ($data->{'branchcode'}); >- my $query= "select r.categorycode from branchrelations r"; >- $query .= ", branchcategories c " if($categorytype); >- $query .= " where branchcode=? "; >- if($categorytype) { >- $query .= " and c.categorytype=? and r.categorycode=c.categorycode"; >- push @bind, $categorytype; >- } >- my $nsth=$dbh->prepare($query); >- $nsth->execute( @bind ); >- my @cats = (); >- while ( my ($cat) = $nsth->fetchrow_array ) { >- push( @cats, $cat ); >- } >- $data->{'categories'} = \@cats; >- push( @results, $data ); >- } >- return \@results; >-} >- > 1; > __END__ > >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index 83b12f1..46a5f1b 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -28,6 +28,7 @@ use C4::Output; > use C4::Suggestions; > use C4::Koha; > use C4::Scrubber; >+use Koha::Libraries; > > use Koha::DateUtils qw( dt_from_string ); > >@@ -149,7 +150,7 @@ if ( $op eq "delete_confirm" ) { > print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else"); > exit; > } >-map{ $_->{'branchcodesuggestedby'}=GetBranchInfo($_->{'branchcodesuggestedby'})->[0]->{'branchname'}} @$suggestions_loop; >+map{ $_->{'branchcodesuggestedby'} = Koha::Libraries->find($_->{'branchcodesuggestedby'})->branchname} @$suggestions_loop; > > foreach my $suggestion(@$suggestions_loop) { > if($suggestion->{'suggestedby'} == $borrowernumber) { >diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t >index c715e98..e10abd3 100644 >--- a/t/db_dependent/Branch.t >+++ b/t/db_dependent/Branch.t >@@ -40,7 +40,6 @@ can_ok( > GetBranch > GetBranches > GetBranchesLoop >- GetBranchInfo > mybranch > ) > ); >@@ -192,18 +191,11 @@ my $CAT1 = Koha::LibraryCategories->find('CAT1'); > $b2_stored->add_to_categories([$CAT1]); > is( Koha::Libraries->search->count, $count + 2, 'BRB added' ); > >-#Test GetBranchInfo >-my $b1info = GetBranchInfo( $b1->{branchcode} ); >-$b1->{categories} = []; >-is_deeply( @$b1info[0], $b1, 'BRA has no categories' ); >- >-my $b2info = GetBranchInfo( $b2->{branchcode} ); >-my @cat = ( $cat1->{categorycode} ); >-delete $b2->{add}; >-delete $b2->{CAT1}; >-$b2->{issuing} = undef; >-$b2->{categories} = \@cat; >-is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' ); >+my $b1info = Koha::Libraries->find( $b1->{branchcode} ); >+is_deeply( $b1info->categories->count, 0, 'BRA has no categories' ); >+ >+my $b2info = Koha::Libraries->find( $b2->{branchcode} ); >+is_deeply( $b2->categories->count, 1, 'BRB has the category CAT1' ); > > Koha::LibraryCategory->new($cat2)->store; > is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" ); >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15629
:
46997
|
46998
|
46999
|
47000
|
47001
|
47002
|
47518
|
47519
|
47520
|
47521
|
47522
|
47523
|
47553
|
47701
|
47706
|
47707
|
47708
|
47709
|
47710
|
47711
|
47712
|
47713