Bugzilla – Attachment 71502 Details for
Bug 18403
Hide patron information if not part of the logged in user library group
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18403: Add new method Koha::Library::Group->has_child
Bug-18403-Add-new-method-KohaLibraryGroup-haschild.patch (text/plain), 3.58 KB, created by
Jonathan Druart
on 2018-02-12 19:33:28 UTC
(
hide
)
Description:
Bug 18403: Add new method Koha::Library::Group->has_child
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-02-12 19:33:28 UTC
Size:
3.58 KB
patch
obsolete
>From eb68ca2af2c9ebf32091f98380dbbd07cd7ff2e6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Apr 2017 16:10:02 -0300 >Subject: [PATCH] Bug 18403: Add new method Koha::Library::Group->has_child > >This is more a follow-up for bug 15707. It could be moved on its own bug report >if necessary. > >IMPORTANT NOTE: At the moment the feature only works for 1 level depth, see >bug 15707 comment 166+ for the discussion > >It means that if we have: > root_group > + groupA > + groupA1 > + groupA1_library2 > + groupA_library1 > + groupA2 > + groupB > + groupB_library1 >groupA1_library2 is not considered a child of groupA1. >Note that this can change. > >Test plan: > prove t/db_dependent/LibraryGroups.t >should return green > >Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Library/Group.pm | 15 +++++++++++++++ > t/db_dependent/LibraryGroups.t | 25 ++++++++++++++++++++++++- > 2 files changed, 39 insertions(+), 1 deletion(-) > >diff --git a/Koha/Library/Group.pm b/Koha/Library/Group.pm >index 677ae1e6ad..a54e5b1a60 100644 >--- a/Koha/Library/Group.pm >+++ b/Koha/Library/Group.pm >@@ -62,6 +62,21 @@ sub children { > return wantarray ? $children->as_list : $children; > } > >+=head3 has_child >+ >+my $has_child = $group->has_child( $branchcode ); >+ >+Return true if the given branchcode library is a child of this group. >+ >+=cut >+ >+sub has_child { >+ my ( $self, $branchcode ) = @_; >+ return unless $branchcode; # Does not support group of libraries. >+ return ( grep { $_ and $_ eq $branchcode } >+ $self->children->get_column('branchcode') ) ? 1 : 0; >+} >+ > =head3 library > > my $library = $group->library(); >diff --git a/t/db_dependent/LibraryGroups.t b/t/db_dependent/LibraryGroups.t >index 69c6fa03ce..02e9817948 100644 >--- a/t/db_dependent/LibraryGroups.t >+++ b/t/db_dependent/LibraryGroups.t >@@ -4,7 +4,7 @@ use Modern::Perl; > > use List::MoreUtils 'any'; > >-use Test::More tests => 16; >+use Test::More tests => 17; > > use t::lib::TestBuilder; > >@@ -84,6 +84,29 @@ subtest 'Koha::Library->library_groups' => sub { > is( $groups->count, 2, 'Library 1 should be part of 2 groups' ); > }; > >+# root_group >+# + groupA >+# + groupA1 >+# + groupA1_library2 >+# + groupA_library1 >+# + groupA2 >+# + groupB >+# + groupB_library1 >+ >+subtest 'Koha::Library::Group->has_child' => sub { >+ plan tests => 2; >+ is( $groupA->has_child( $library1->{branchcode} ), 1, 'library1 should be condidered as a child of groupA' ); >+ is( $groupB->has_child( $library2->{branchcode} ), 0, 'library2 should not be considered as a child of groupB' ); >+ >+ # TODO This is not implemented because not used yet >+ # ->has_child only works with libraries >+ #is( $groupA->has_child( $groupA1 ), 1, 'groupA1 should be condidered as a child of groupA' ); >+ >+ # FIXME At the time of writing this test fails because the ->children methods does not return more than 1 level of depth >+ # See Bug 15707 comments 166-170+ >+ #is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' ); >+}; >+ > my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); > my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); > my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); >-- >2.11.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 18403
:
62010
|
62011
|
62012
|
62013
|
62014
|
62015
|
62016
|
62017
|
62018
|
62019
|
62020
|
62021
|
62022
|
62023
|
62024
|
62025
|
62026
|
62027
|
62028
|
62029
|
62030
|
62031
|
62032
|
62033
|
62302
|
62303
|
62830
|
62831
|
62832
|
62833
|
62834
|
62835
|
62836
|
62837
|
62838
|
62839
|
62840
|
62841
|
62842
|
62843
|
62844
|
62845
|
62846
|
62847
|
62848
|
62849
|
62850
|
62851
|
62852
|
62853
|
62854
|
62855
|
71392
|
71394
|
71500
|
71501
| 71502 |
71503
|
71504
|
71505
|
71506
|
71507
|
71508
|
71509
|
71510
|
71511
|
71512
|
71513
|
71514
|
71515
|
71516
|
71517
|
71518
|
71519
|
71520
|
71521
|
71522
|
71523
|
71524
|
71525
|
71526
|
71527
|
71528
|
71529
|
71530
|
71767