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

(-)a/C4/Acquisition.pm (-8 / +14 lines)
Lines 1965-1973 sub GetParcel { Link Here
1965
    my @query_params = ( $supplierid, $code, $datereceived );
1965
    my @query_params = ( $supplierid, $code, $datereceived );
1966
    if ( C4::Context->preference("IndependentBranches") ) {
1966
    if ( C4::Context->preference("IndependentBranches") ) {
1967
        unless ( C4::Context->IsSuperLibrarian() ) {
1967
        unless ( C4::Context->IsSuperLibrarian() ) {
1968
            my $branches =
1968
            my @branches = GetIndependentGroupModificationRights();
1969
              GetIndependentGroupModificationRights( { stringify => 1 } );
1969
            $strsth .=
1970
            $strsth .= " AND ( borrowers.branchcode IN ( $branches ) OR borrowers.branchcode  = '')";
1970
                " AND ( borrowers.branchcode IN ( "
1971
              . join( ',', ('?') x @branches )
1972
              . " ) OR borrowers.branchcode  = '')";
1973
            push( @query_params, @branches );
1971
        }
1974
        }
1972
    }
1975
    }
1973
    $strsth .= " ORDER BY aqbasket.basketno";
1976
    $strsth .= " ORDER BY aqbasket.basketno";
Lines 2182-2189 sub GetLateOrders { Link Here
2182
    }
2185
    }
2183
    if (C4::Context->preference("IndependentBranches")
2186
    if (C4::Context->preference("IndependentBranches")
2184
            && !C4::Context->IsSuperLibrarian() ) {
2187
            && !C4::Context->IsSuperLibrarian() ) {
2185
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2188
        my @branches = GetIndependentGroupModificationRights();
2186
        $from .= qq{ AND borrowers.branchcode IN ( $branches ) };
2189
        $from .= "AND borrowers.branchcode IN ( " . join(',', ('?') x @branches) . " ) ";
2190
        push( @query_params, @branches );
2187
    }
2191
    }
2188
    $from .= " AND orderstatus <> 'cancelled' ";
2192
    $from .= " AND orderstatus <> 'cancelled' ";
2189
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
2193
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
Lines 2407-2415 sub GetHistory { Link Here
2407
    if ( C4::Context->preference("IndependentBranches")
2411
    if ( C4::Context->preference("IndependentBranches")
2408
        && !C4::Context->IsSuperLibrarian() )
2412
        && !C4::Context->IsSuperLibrarian() )
2409
    {
2413
    {
2410
        my $branches =
2414
        my @branches = GetIndependentGroupModificationRights();
2411
          GetIndependentGroupModificationRights( { stringify => 1 } );
2415
        $query .=
2412
        $query .= qq{ AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( $branches ) ) };
2416
          " AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( "
2417
          . join( ',', ('?') x @branches ) . " ) ) ";
2418
        push( @query_params, @branches );
2413
    }
2419
    }
2414
    $query .= " ORDER BY id";
2420
    $query .= " ORDER BY id";
2415
    my $sth = $dbh->prepare($query);
2421
    my $sth = $dbh->prepare($query);
(-)a/C4/Branch.pm (-17 / +8 lines)
Lines 116-123 sub GetBranches { Link Here
116
    my $query = "SELECT * FROM branches";
116
    my $query = "SELECT * FROM branches";
117
    my @bind_parameters;
117
    my @bind_parameters;
118
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
118
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
119
      my $branches = GetIndependentGroupModificationRights({ stringify => 1 });
119
      my @branches = GetIndependentGroupModificationRights();
120
      $query .= qq{ WHERE branchcode IN ( $branches ) };
120
      $query .= " WHERE branchcode IN ( " . join(',', ('?') x @branches) . " ) ";
121
      push( @bind_parameters, @branches );
121
    }
122
    }
122
    $query .= " ORDER BY branchname";
123
    $query .= " ORDER BY branchname";
123
    $sth = $dbh->prepare($query);
124
    $sth = $dbh->prepare($query);
Lines 427-438 sub GetBranchesInCategory { Link Here
427
=head2 GetIndependentGroupModificationRights
428
=head2 GetIndependentGroupModificationRights
428
429
429
    GetIndependentGroupModificationRights(
430
    GetIndependentGroupModificationRights(
430
                                           {
431
        {
431
                                               branch => $this_branch,
432
            branch => $this_branch,
432
                                               for => $other_branch,
433
            for => $other_branch,
433
                                               stringify => 1,
434
        }
434
                                           }
435
    );
435
                                          );
436
436
437
    Returns a list of branches this branch shares a common
437
    Returns a list of branches this branch shares a common
438
    independent group with.
438
    independent group with.
Lines 447-458 sub GetBranchesInCategory { Link Here
447
447
448
    If called in a scalar context, it returns
448
    If called in a scalar context, it returns
449
    a count of matching branchcodes. Returns 1 if
449
    a count of matching branchcodes. Returns 1 if
450
451
    If stringify param is passed, the return value will
452
    be a string of the comma delimited branchcodes. This
453
    is useful for "branchcode IN $branchcodes" clauses
454
    in SQL queries.
455
456
    $this_branch and $other_branch are equal for efficiency.
450
    $this_branch and $other_branch are equal for efficiency.
457
451
458
    So you can write:
452
    So you can write:
Lines 467-473 sub GetIndependentGroupModificationRights { Link Here
467
461
468
    my $this_branch  = $params->{branch};
462
    my $this_branch  = $params->{branch};
469
    my $other_branch = $params->{for};
463
    my $other_branch = $params->{for};
470
    my $stringify    = $params->{stringify};
471
464
472
    $this_branch ||= C4::Context->userenv->{branch};
465
    $this_branch ||= C4::Context->userenv->{branch};
473
466
Lines 501-508 sub GetIndependentGroupModificationRights { Link Here
501
    my $dbh = C4::Context->dbh;
494
    my $dbh = C4::Context->dbh;
502
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
495
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
503
496
504
    return join( ',', map { qq{'$_'} } @branchcodes ) if $stringify;
505
506
    if ( wantarray() ) {
497
    if ( wantarray() ) {
507
        if ( @branchcodes ) {
498
        if ( @branchcodes ) {
508
            return @branchcodes;
499
            return @branchcodes;
(-)a/C4/Items.pm (-3 / +8 lines)
Lines 2760-2768 sub PrepareItemrecordDisplay { Link Here
2760
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2760
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2761
                        if (   ( C4::Context->preference("IndependentBranches") )
2761
                        if (   ( C4::Context->preference("IndependentBranches") )
2762
                            && !C4::Context->IsSuperLibrarian() ) {
2762
                            && !C4::Context->IsSuperLibrarian() ) {
2763
                            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2763
                            my @branches =
2764
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode IN ( $branches ) ORDER BY branchname" );
2764
                              GetIndependentGroupModificationRights();
2765
                            $sth->execute();
2765
                            my $sql =
2766
                                "SELECT branchcode,branchname FROM branches WHERE branchcode IN ("
2767
                              . join( ',', ('?') x @branches )
2768
                              . ") ORDER BY branchname";
2769
                            my $sth = $dbh->prepare($sql);
2770
                            $sth->execute(@branches);
2766
                            push @authorised_values, ""
2771
                            push @authorised_values, ""
2767
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2772
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2768
                            while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
2773
                            while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
(-)a/C4/Members.pm (-9 / +15 lines)
Lines 1345-1363 sub checkuniquemember { Link Here
1345
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1345
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1346
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1346
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1347
1347
1348
    my @params;
1349
    if ($collectivity) {
1350
        push( @params, uc($surname) );
1351
    }
1352
    elsif ($dateofbirth) {
1353
        push( @params, uc($surname), ucfirst($firstname), $dateofbirth );
1354
    }
1355
    else {
1356
        push( @params, uc($surname), ucfirst($firstname) );
1357
    }
1358
1348
    if ( C4::Context->preference('IndependentBranches') ) {
1359
    if ( C4::Context->preference('IndependentBranches') ) {
1349
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1360
        my @branches = GetIndependentGroupModificationRights();
1350
        $request .= " AND branchcode IN ( $branches )";
1361
        $request .= " AND branchcode IN ( " . join(',', ('?') x @branches) ." )";
1362
        push( @params, @branches );
1351
    }
1363
    }
1352
1364
1353
    my $sth = $dbh->prepare($request);
1365
    my $sth = $dbh->prepare($request);
1354
    if ($collectivity) {
1366
    $sth->execute( @params );
1355
        $sth->execute( uc($surname) );
1356
    } elsif($dateofbirth){
1357
        $sth->execute( uc($surname), ucfirst($firstname), $dateofbirth );
1358
    }else{
1359
        $sth->execute( uc($surname), ucfirst($firstname));
1360
    }
1361
    my @data = $sth->fetchrow;
1367
    my @data = $sth->fetchrow;
1362
    ( $data[0] ) and return $data[0], $data[1];
1368
    ( $data[0] ) and return $data[0], $data[1];
1363
    return 0;
1369
    return 0;
(-)a/C4/Serials.pm (-23 / +36 lines)
Lines 238-258 sub GetSerialInformation { Link Here
238
               subscription.*,
238
               subscription.*,
239
               subscription.subscriptionid as subsid
239
               subscription.subscriptionid as subsid
240
    |;
240
    |;
241
    my @branches;
241
    if (   C4::Context->preference('IndependentBranches')
242
    if (   C4::Context->preference('IndependentBranches')
242
        && C4::Context->userenv
243
        && C4::Context->userenv
243
        && C4::Context->userenv->{'flags'} % 2 != 1
244
        && C4::Context->userenv->{'flags'} % 2 != 1
244
        && C4::Context->userenv->{'branch'} ) {
245
        && C4::Context->userenv->{'branch'} ) {
245
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
246
        @branches = GetIndependentGroupModificationRights();
246
        $query .= qq|
247
        $query .= "
247
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
248
            , (
248
        |;
249
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) ." ) )
250
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
251
            ) AS cannotedit
252
        ";
249
    }
253
    }
250
    $query .= qq|
254
    $query .= qq|
251
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
255
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
252
        WHERE  serialid = ?
256
        WHERE  serialid = ?
253
    |;
257
    |;
254
    my $rq = $dbh->prepare($query);
258
    my $rq = $dbh->prepare($query);
255
    $rq->execute($serialid);
259
    $rq->execute($serialid, @branches);
256
    my $data = $rq->fetchrow_hashref;
260
    my $data = $rq->fetchrow_hashref;
257
261
258
    # create item information if we have serialsadditems for this subscription
262
    # create item information if we have serialsadditems for this subscription
Lines 355-371 sub GetSubscription { Link Here
355
                subscription.biblionumber as bibnum
359
                subscription.biblionumber as bibnum
356
    |;
360
    |;
357
361
362
    my @branches;
358
    if (   C4::Context->preference('IndependentBranches')
363
    if (   C4::Context->preference('IndependentBranches')
359
        && C4::Context->userenv
364
        && C4::Context->userenv
360
        && C4::Context->userenv->{'flags'} % 2 != 1
365
        && C4::Context->userenv->{'flags'} % 2 != 1
361
        && C4::Context->userenv->{'branch'} )
366
        && C4::Context->userenv->{'branch'} )
362
    {
367
    {
363
        my $branches =
368
        @branches = GetIndependentGroupModificationRights();
364
          GetIndependentGroupModificationRights( { stringify => 1 } );
365
369
366
        $query .= qq|
370
        $query .= "
367
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
371
            , (
368
        |;
372
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) ." ) )
373
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
374
            ) AS cannotedit
375
        ";
369
    }
376
    }
370
377
371
    $query .= qq|
378
    $query .= qq|
Lines 378-384 sub GetSubscription { Link Here
378
385
379
    $debug and warn "query : $query\nsubsid :$subscriptionid";
386
    $debug and warn "query : $query\nsubsid :$subscriptionid";
380
    my $sth = $dbh->prepare($query);
387
    my $sth = $dbh->prepare($query);
381
    $sth->execute($subscriptionid);
388
    $sth->execute($subscriptionid, @branches);
382
    my $subscription = $sth->fetchrow_hashref;
389
    my $subscription = $sth->fetchrow_hashref;
383
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
390
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
384
    return $subscription;
391
    return $subscription;
Lines 413-429 sub GetFullSubscription { Link Here
413
            subscription.subscriptionid AS subscriptionid
420
            subscription.subscriptionid AS subscriptionid
414
    |;
421
    |;
415
422
423
    my @branches;
416
    if (   C4::Context->preference('IndependentBranches')
424
    if (   C4::Context->preference('IndependentBranches')
417
        && C4::Context->userenv
425
        && C4::Context->userenv
418
        && C4::Context->userenv->{'flags'} % 2 != 1
426
        && C4::Context->userenv->{'flags'} % 2 != 1
419
        && C4::Context->userenv->{'branch'} )
427
        && C4::Context->userenv->{'branch'} )
420
    {
428
    {
421
        my $branches =
429
        @branches = GetIndependentGroupModificationRights();
422
          GetIndependentGroupModificationRights( { stringify => 1 } );
423
430
424
        $query .= qq|
431
        $query .= "
425
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
432
            , (
426
        |;
433
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) . " ) )
434
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
435
            ) AS cannotedit
436
        ";
427
    }
437
    }
428
438
429
    $query .= qq|
439
    $query .= qq|
Lines 439-445 sub GetFullSubscription { Link Here
439
          |;
449
          |;
440
    $debug and warn "GetFullSubscription query: $query";
450
    $debug and warn "GetFullSubscription query: $query";
441
    my $sth = $dbh->prepare($query);
451
    my $sth = $dbh->prepare($query);
442
    $sth->execute($subscriptionid);
452
    $sth->execute( $subscriptionid, @branches );
443
    my $subscriptions = $sth->fetchall_arrayref( {} );
453
    my $subscriptions = $sth->fetchall_arrayref( {} );
444
    for my $subscription ( @$subscriptions ) {
454
    for my $subscription ( @$subscriptions ) {
445
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
455
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
Lines 596-612 sub GetFullSubscriptionsFromBiblionumber { Link Here
596
            subscription.subscriptionid AS subscriptionid
606
            subscription.subscriptionid AS subscriptionid
597
    |;
607
    |;
598
608
609
    my @branches;
599
    if (   C4::Context->preference('IndependentBranches')
610
    if (   C4::Context->preference('IndependentBranches')
600
        && C4::Context->userenv
611
        && C4::Context->userenv
601
        && C4::Context->userenv->{'flags'} != 1
612
        && C4::Context->userenv->{'flags'} != 1
602
        && C4::Context->userenv->{'branch'} )
613
        && C4::Context->userenv->{'branch'} )
603
    {
614
    {
604
        my $branches =
615
        @branches = GetIndependentGroupModificationRights();
605
          GetIndependentGroupModificationRights( { stringify => 1 } );
606
616
607
        $query .= qq|
617
        $query .= "
608
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
618
            , (
609
        |;
619
                ( subscription.branchcode NOT IN (" . join(',', ('?') x @branches) . ") )
620
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
621
            ) AS cannotedit
622
        ";
610
    }
623
    }
611
624
612
    $query .= qq|
625
    $query .= qq|
Lines 621-627 sub GetFullSubscriptionsFromBiblionumber { Link Here
621
          serial.subscriptionid
634
          serial.subscriptionid
622
          |;
635
          |;
623
    my $sth = $dbh->prepare($query);
636
    my $sth = $dbh->prepare($query);
624
    $sth->execute($biblionumber);
637
    $sth->execute($biblionumber, @branches);
625
    my $subscriptions = $sth->fetchall_arrayref( {} );
638
    my $subscriptions = $sth->fetchall_arrayref( {} );
626
    for my $subscription ( @$subscriptions ) {
639
    for my $subscription ( @$subscriptions ) {
627
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
640
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
(-)a/C4/Suggestions.pm (-14 / +16 lines)
Lines 137-145 sub SearchSuggestion { Link Here
137
        && !C4::Context->IsSuperLibrarian()
137
        && !C4::Context->IsSuperLibrarian()
138
        && !$suggestion->{branchcode} )
138
        && !$suggestion->{branchcode} )
139
    {
139
    {
140
        my $branches =
140
        my @branches =
141
          GetIndependentGroupModificationRights( { stringify => 1 } );
141
          GetIndependentGroupModificationRights();
142
        push( @query, qq{ AND (suggestions.branchcode IN ( $branches ) OR suggestions.branchcode='') } );
142
        push( @query, " AND (suggestions.branchcode IN ( " . join(',', ('?') x @branches) ." ) OR suggestions.branchcode='') " );
143
        push( @sql_params, @branches );
143
    }
144
    }
144
    else {
145
    else {
145
        if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) {
146
        if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) {
Lines 343-354 sub GetSuggestionByStatus { Link Here
343
            && !C4::Context->IsSuperLibrarian() )
344
            && !C4::Context->IsSuperLibrarian() )
344
        {
345
        {
345
346
346
            my $branches =
347
            my @branches =
347
              GetIndependentGroupModificationRights( { stringify => 1 } );
348
              GetIndependentGroupModificationRights();
348
349
349
            $query .= qq{
350
            $query .= "
350
                AND (U1.branchcode IN ( $branches ) OR U1.branchcode ='')
351
                AND (U1.branchcode IN ( " . join(',', ('?') x @branches) . " ) OR U1.branchcode ='')
351
            };
352
            ";
353
            push( @sql_params, @branches );
352
        }
354
        }
353
355
354
        if ($branchcode) {
356
        if ($branchcode) {
Lines 396-417 sub CountSuggestion { Link Here
396
    if ( C4::Context->preference("IndependentBranches")
398
    if ( C4::Context->preference("IndependentBranches")
397
        && !C4::Context->IsSuperLibrarian() )
399
        && !C4::Context->IsSuperLibrarian() )
398
    {
400
    {
399
        my $branches =
401
        my @branches =
400
          GetIndependentGroupModificationRights( { stringify => 1 } );
402
          GetIndependentGroupModificationRights();
401
403
402
        my $query = qq{
404
        my $query = "
403
            SELECT count(*)
405
            SELECT count(*)
404
            FROM suggestions
406
            FROM suggestions
405
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
407
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
406
            WHERE STATUS=?
408
            WHERE STATUS=?
407
                AND (
409
                AND (
408
                    borrowers.branchcode IN ( $branches )
410
                    borrowers.branchcode IN (" . join(',', ('?') x @branches) . ")
409
                    OR
411
                    OR
410
                    borrowers.branchcode=?
412
                    borrowers.branchcode=?
411
                )
413
                )
412
        };
414
        ";
413
        $sth = $dbh->prepare($query);
415
        $sth = $dbh->prepare($query);
414
        $sth->execute( $status, $userenv->{branch} );
416
        $sth->execute( $status, @branches, $userenv->{branch} );
415
    }
417
    }
416
    else {
418
    else {
417
        my $query = q{
419
        my $query = q{
(-)a/circ/pendingreserves.pl (-2 / +3 lines)
Lines 154-161 if ( $run_report ) { Link Here
154
154
155
155
156
    if (C4::Context->preference('IndependentBranches')){
156
    if (C4::Context->preference('IndependentBranches')){
157
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
157
        my @branches = GetIndependentGroupModificationRights();
158
        $strsth .= " AND items.holdingbranch IN ( $branches ) ";
158
        $strsth .= " AND items.holdingbranch IN ( " . join(',', ('?') x @branches) . " ) ";
159
        push( @query_params, @branches );
159
    }
160
    }
160
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
161
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
161
162
(-)a/circ/reserveratios.pl (-2 / +3 lines)
Lines 121-128 my $strsth = Link Here
121
";
121
";
122
122
123
if ( C4::Context->preference('IndependentBranches') ) {
123
if ( C4::Context->preference('IndependentBranches') ) {
124
    my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
124
    my @branches = GetIndependentGroupModificationRights();
125
    $strsth .= " AND items.holdingbranch IN ( $branches ) ";
125
    $strsth .= " AND items.holdingbranch IN (" . join(',', ('?') x @branches) . ") ";
126
    push( @query_params, @branches );
126
}
127
}
127
128
128
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC";
129
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC";
(-)a/t/db_dependent/Branch.t (-14 / +1 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 => 70;
24
use Test::More tests => 66;
25
25
26
use C4::Branch;
26
use C4::Branch;
27
27
Lines 351-359 is( scalar(@$loop), GetBranchesCount(), 'There is the right number of branches' Link Here
351
my @branches_bra = GetIndependentGroupModificationRights({ branch => 'BRA' });
351
my @branches_bra = GetIndependentGroupModificationRights({ branch => 'BRA' });
352
is_deeply( \@branches_bra, [ 'BRA' ], 'Library with no group only has rights for its own branch' );
352
is_deeply( \@branches_bra, [ 'BRA' ], 'Library with no group only has rights for its own branch' );
353
353
354
my $string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 });
355
ok( $string eq q{'BRA'}, "String returns correctly" );
356
357
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
354
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
358
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB' }), 'Boolean test for BRA rights to BRB returns false' );
355
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB' }), 'Boolean test for BRA rights to BRB returns false' );
359
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC' }), 'Boolean test for BRA rights to BRC returns false' );
356
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC' }), 'Boolean test for BRA rights to BRC returns false' );
Lines 378-389 ModBranch({ Link Here
378
@branches_bra = GetIndependentGroupModificationRights({ branch => 'BRA' });
375
@branches_bra = GetIndependentGroupModificationRights({ branch => 'BRA' });
379
is_deeply( \@branches_bra, [ 'BRA', 'BRB' ], 'Libraries in LIBCATCODE returned correctly' );
376
is_deeply( \@branches_bra, [ 'BRA', 'BRB' ], 'Libraries in LIBCATCODE returned correctly' );
380
377
381
$string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 });
382
ok( $string eq q{'BRA','BRB'}, "String returns correctly" );
383
384
$string = GetIndependentGroupModificationRights({ branch => 'BRC', stringify => 1 });
385
ok( $string eq q{'BRC'}, "String returns correctly" );
386
387
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
378
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRA' }), 'Boolean test for BRA rights to BRA returns true' );
388
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' );
379
ok( GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRB'}), 'Boolean test for BRA rights to BRB returns true' );
389
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' );
380
ok( !GetIndependentGroupModificationRights({ branch => 'BRA', for => 'BRC'}), 'Boolean test for BRA rights to BRC returns false' );
Lines 413-421 ok( GetIndependentGroupModificationRights({ branch => 'BRC', for => 'BRC' }), 'B Link Here
413
ok( GetIndependentGroupModificationRights({ branch => 'BRC', for => 'BRA'}), 'Boolean test for BRC rights to BRA returns true' );
404
ok( GetIndependentGroupModificationRights({ branch => 'BRC', for => 'BRA'}), 'Boolean test for BRC rights to BRA returns true' );
414
ok( GetIndependentGroupModificationRights({ branch => 'BRC', for => 'BRA'}), 'Boolean test for BRC rights to BRB returns true' );
405
ok( GetIndependentGroupModificationRights({ branch => 'BRC', for => 'BRA'}), 'Boolean test for BRC rights to BRB returns true' );
415
406
416
$string = GetIndependentGroupModificationRights({ branch => 'BRA', stringify => 1 });
417
ok( $string eq q{'BRA','BRB','BRC'}, "String returns correctly" );
418
419
# End transaction
407
# End transaction
420
$dbh->rollback;
408
$dbh->rollback;
421
409
422
- 

Return to bug 10276