View | Details | Raw Unified | Return to bug 10276
Collapse All | Expand All

(-)a/C4/Branch.pm (-8 / +5 lines)
Lines 495-510 sub GetIndependentGroupModificationRights { Link Here
495
        push( @params, $other_branch );
495
        push( @params, $other_branch );
496
    }
496
    }
497
497
498
    $sql .= q{ UNION SELECT branchcode FROM branches WHERE branchcode = ? };
499
    push( @params, $this_branch );
500
498
    my $dbh = C4::Context->dbh;
501
    my $dbh = C4::Context->dbh;
499
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
502
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
500
503
501
    if ( $stringify ) {
504
    return join( ',', map { qq{'$_'} } @branchcodes ) if $stringify;
502
        if ( @branchcodes ) {
503
            return join( ',', map { qq{'$_'} } @branchcodes );
504
        } else {
505
            return qq{'$this_branch'};
506
        }
507
    }
508
505
509
    if ( wantarray() ) {
506
    if ( wantarray() ) {
510
        if ( @branchcodes ) {
507
        if ( @branchcodes ) {
Lines 513-519 sub GetIndependentGroupModificationRights { Link Here
513
            return $this_branch;
510
            return $this_branch;
514
        }
511
        }
515
    } else {
512
    } else {
516
        return scalar(@branchcodes);
513
        return scalar(@branchcodes) > 1;
517
    }
514
    }
518
}
515
}
519
516
(-)a/t/db_dependent/Branch.t (-2 / +4 lines)
Lines 21-27 use Modern::Perl; Link Here
21
use C4::Context;
21
use C4::Context;
22
use Data::Dumper;
22
use Data::Dumper;
23
23
24
use Test::More tests => 69;
24
use Test::More tests => 70;
25
25
26
use C4::Branch;
26
use C4::Branch;
27
27
Lines 381-386 is_deeply( \@branches_bra, [ 'BRA', 'BRB' ], 'Libraries in LIBCATCODE returned c Link Here
381
$string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 });
381
$string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 });
382
ok( $string eq q{'BRA','BRB'}, "String returns correctly" );
382
ok( $string eq q{'BRA','BRB'}, "String returns correctly" );
383
383
384
$string = GetIndependentGroupModificationRights({ branch => 'BRC', stringify => 1 });
385
ok( $string eq q{'BRC'}, "String returns correctly" );
386
384
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
387
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
385
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' );
388
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' );
386
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' );
389
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' );
387
- 

Return to bug 10276