@@ -, +, @@ --- C4/Branch.pm | 13 +++++-------- t/db_dependent/Branch.t | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) --- a/C4/Branch.pm +++ a/C4/Branch.pm @@ -500,16 +500,13 @@ sub GetIndependentGroupModificationRights { push( @params, $other_branch ); } + $sql .= q{ UNION SELECT branchcode FROM branches WHERE branchcode = ? }; + push( @params, $this_branch ); + my $dbh = C4::Context->dbh; my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) }; - if ( $stringify ) { - if ( @branchcodes ) { - return join( ',', map { qq{'$_'} } @branchcodes ); - } else { - return qq{'$this_branch'}; - } - } + return join( ',', map { qq{'$_'} } @branchcodes ) if $stringify; if ( wantarray() ) { if ( @branchcodes ) { @@ -518,7 +515,7 @@ sub GetIndependentGroupModificationRights { return $this_branch; } } else { - return scalar(@branchcodes); + return scalar(@branchcodes) > 1; } } --- a/t/db_dependent/Branch.t +++ a/t/db_dependent/Branch.t @@ -21,7 +21,7 @@ use Modern::Perl; use C4::Context; use Data::Dumper; -use Test::More tests => 69; +use Test::More tests => 70; use C4::Branch; @@ -389,6 +389,9 @@ is_deeply( \@branches_bra, [ 'BRA', 'BRB' ], 'Libraries in LIBCATCODE returned c $string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 }); ok( $string eq q{'BRA','BRB'}, "String returns correctly" ); +$string = GetIndependentGroupModificationRights({ branch => 'BRC', stringify => 1 }); +ok( $string eq q{'BRC'}, "String returns correctly" ); + ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' ); ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' ); ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' ); --