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

(-)a/C4/Acquisition.pm (-8 / +14 lines)
Lines 1883-1891 sub GetParcel { Link Here
1883
    my @query_params = ( $supplierid, $code, $datereceived );
1883
    my @query_params = ( $supplierid, $code, $datereceived );
1884
    if ( C4::Context->preference("IndependentBranches") ) {
1884
    if ( C4::Context->preference("IndependentBranches") ) {
1885
        unless ( C4::Context->IsSuperLibrarian() ) {
1885
        unless ( C4::Context->IsSuperLibrarian() ) {
1886
            my $branches =
1886
            my @branches = GetIndependentGroupModificationRights();
1887
              GetIndependentGroupModificationRights( { stringify => 1 } );
1887
            $strsth .=
1888
            $strsth .= " AND ( borrowers.branchcode IN ( $branches ) OR borrowers.branchcode  = '')";
1888
                " AND ( borrowers.branchcode IN ( "
1889
              . join( ',', ('?') x @branches )
1890
              . " ) OR borrowers.branchcode  = '')";
1891
            push( @query_params, @branches );
1889
        }
1892
        }
1890
    }
1893
    }
1891
    $strsth .= " ORDER BY aqbasket.basketno";
1894
    $strsth .= " ORDER BY aqbasket.basketno";
Lines 2096-2103 sub GetLateOrders { Link Here
2096
    }
2099
    }
2097
    if (C4::Context->preference("IndependentBranches")
2100
    if (C4::Context->preference("IndependentBranches")
2098
            && !C4::Context->IsSuperLibrarian() ) {
2101
            && !C4::Context->IsSuperLibrarian() ) {
2099
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2102
        my @branches = GetIndependentGroupModificationRights();
2100
        $from .= qq{ AND borrowers.branchcode IN ( $branches ) };
2103
        $from .= "AND borrowers.branchcode IN ( " . join(',', ('?') x @branches) . " ) ";
2104
        push( @query_params, @branches );
2101
    }
2105
    }
2102
    $from .= " AND orderstatus <> 'cancelled' ";
2106
    $from .= " AND orderstatus <> 'cancelled' ";
2103
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
2107
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
Lines 2311-2319 sub GetHistory { Link Here
2311
    if ( C4::Context->preference("IndependentBranches")
2315
    if ( C4::Context->preference("IndependentBranches")
2312
        && !C4::Context->IsSuperLibrarian() )
2316
        && !C4::Context->IsSuperLibrarian() )
2313
    {
2317
    {
2314
        my $branches =
2318
        my @branches = GetIndependentGroupModificationRights();
2315
          GetIndependentGroupModificationRights( { stringify => 1 } );
2319
        $query .=
2316
        $query .= qq{ AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( $branches ) ) };
2320
          " AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( "
2321
          . join( ',', ('?') x @branches ) . " ) ) ";
2322
        push( @query_params, @branches );
2317
    }
2323
    }
2318
    $query .= " ORDER BY id";
2324
    $query .= " ORDER BY id";
2319
    my $sth = $dbh->prepare($query);
2325
    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 2759-2767 sub PrepareItemrecordDisplay { Link Here
2759
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2759
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2760
                        if (   ( C4::Context->preference("IndependentBranches") )
2760
                        if (   ( C4::Context->preference("IndependentBranches") )
2761
                            && !C4::Context->IsSuperLibrarian() ) {
2761
                            && !C4::Context->IsSuperLibrarian() ) {
2762
                            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2762
                            my @branches =
2763
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode IN ( $branches ) ORDER BY branchname" );
2763
                              GetIndependentGroupModificationRights();
2764
                            $sth->execute();
2764
                            my $sql =
2765
                                "SELECT branchcode,branchname FROM branches WHERE branchcode IN ("
2766
                              . join( ',', ('?') x @branches )
2767
                              . ") ORDER BY branchname";
2768
                            my $sth = $dbh->prepare($sql);
2769
                            $sth->execute(@branches);
2765
                            push @authorised_values, ""
2770
                            push @authorised_values, ""
2766
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2771
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2767
                            while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
2772
                            while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
(-)a/C4/Members.pm (-9 / +15 lines)
Lines 1314-1332 sub checkuniquemember { Link Here
1314
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1314
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1315
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1315
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1316
1316
1317
    my @params;
1318
    if ($collectivity) {
1319
        push( @params, uc($surname) );
1320
    }
1321
    elsif ($dateofbirth) {
1322
        push( @params, uc($surname), ucfirst($firstname), $dateofbirth );
1323
    }
1324
    else {
1325
        push( @params, uc($surname), ucfirst($firstname) );
1326
    }
1327
1317
    if ( C4::Context->preference('IndependentBranches') ) {
1328
    if ( C4::Context->preference('IndependentBranches') ) {
1318
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1329
        my @branches = GetIndependentGroupModificationRights();
1319
        $request .= " AND branchcode IN ( $branches )";
1330
        $request .= " AND branchcode IN ( " . join(',', ('?') x @branches) ." )";
1331
        push( @params, @branches );
1320
    }
1332
    }
1321
1333
1322
    my $sth = $dbh->prepare($request);
1334
    my $sth = $dbh->prepare($request);
1323
    if ($collectivity) {
1335
    $sth->execute( @params );
1324
        $sth->execute( uc($surname) );
1325
    } elsif($dateofbirth){
1326
        $sth->execute( uc($surname), ucfirst($firstname), $dateofbirth );
1327
    }else{
1328
        $sth->execute( uc($surname), ucfirst($firstname));
1329
    }
1330
    my @data = $sth->fetchrow;
1336
    my @data = $sth->fetchrow;
1331
    ( $data[0] ) and return $data[0], $data[1];
1337
    ( $data[0] ) and return $data[0], $data[1];
1332
    return 0;
1338
    return 0;
(-)a/C4/Serials.pm (-23 / +36 lines)
Lines 237-257 sub GetSerialInformation { Link Here
237
               subscription.*,
237
               subscription.*,
238
               subscription.subscriptionid as subsid
238
               subscription.subscriptionid as subsid
239
    |;
239
    |;
240
    my @branches;
240
    if (   C4::Context->preference('IndependentBranches')
241
    if (   C4::Context->preference('IndependentBranches')
241
        && C4::Context->userenv
242
        && C4::Context->userenv
242
        && C4::Context->userenv->{'flags'} % 2 != 1
243
        && C4::Context->userenv->{'flags'} % 2 != 1
243
        && C4::Context->userenv->{'branch'} ) {
244
        && C4::Context->userenv->{'branch'} ) {
244
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
245
        @branches = GetIndependentGroupModificationRights();
245
        $query .= qq|
246
        $query .= "
246
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
247
            , (
247
        |;
248
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) ." ) )
249
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
250
            ) AS cannotedit
251
        ";
248
    }
252
    }
249
    $query .= qq|
253
    $query .= qq|
250
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
254
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
251
        WHERE  serialid = ?
255
        WHERE  serialid = ?
252
    |;
256
    |;
253
    my $rq = $dbh->prepare($query);
257
    my $rq = $dbh->prepare($query);
254
    $rq->execute($serialid);
258
    $rq->execute($serialid, @branches);
255
    my $data = $rq->fetchrow_hashref;
259
    my $data = $rq->fetchrow_hashref;
256
260
257
    # create item information if we have serialsadditems for this subscription
261
    # create item information if we have serialsadditems for this subscription
Lines 354-370 sub GetSubscription { Link Here
354
                subscription.biblionumber as bibnum
358
                subscription.biblionumber as bibnum
355
    |;
359
    |;
356
360
361
    my @branches;
357
    if (   C4::Context->preference('IndependentBranches')
362
    if (   C4::Context->preference('IndependentBranches')
358
        && C4::Context->userenv
363
        && C4::Context->userenv
359
        && C4::Context->userenv->{'flags'} % 2 != 1
364
        && C4::Context->userenv->{'flags'} % 2 != 1
360
        && C4::Context->userenv->{'branch'} )
365
        && C4::Context->userenv->{'branch'} )
361
    {
366
    {
362
        my $branches =
367
        @branches = GetIndependentGroupModificationRights();
363
          GetIndependentGroupModificationRights( { stringify => 1 } );
364
368
365
        $query .= qq|
369
        $query .= "
366
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
370
            , (
367
        |;
371
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) ." ) )
372
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
373
            ) AS cannotedit
374
        ";
368
    }
375
    }
369
376
370
    $query .= qq|
377
    $query .= qq|
Lines 377-383 sub GetSubscription { Link Here
377
384
378
    $debug and warn "query : $query\nsubsid :$subscriptionid";
385
    $debug and warn "query : $query\nsubsid :$subscriptionid";
379
    my $sth = $dbh->prepare($query);
386
    my $sth = $dbh->prepare($query);
380
    $sth->execute($subscriptionid);
387
    $sth->execute($subscriptionid, @branches);
381
    my $subscription = $sth->fetchrow_hashref;
388
    my $subscription = $sth->fetchrow_hashref;
382
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
389
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
383
    return $subscription;
390
    return $subscription;
Lines 412-428 sub GetFullSubscription { Link Here
412
            subscription.subscriptionid AS subscriptionid
419
            subscription.subscriptionid AS subscriptionid
413
    |;
420
    |;
414
421
422
    my @branches;
415
    if (   C4::Context->preference('IndependentBranches')
423
    if (   C4::Context->preference('IndependentBranches')
416
        && C4::Context->userenv
424
        && C4::Context->userenv
417
        && C4::Context->userenv->{'flags'} % 2 != 1
425
        && C4::Context->userenv->{'flags'} % 2 != 1
418
        && C4::Context->userenv->{'branch'} )
426
        && C4::Context->userenv->{'branch'} )
419
    {
427
    {
420
        my $branches =
428
        @branches = GetIndependentGroupModificationRights();
421
          GetIndependentGroupModificationRights( { stringify => 1 } );
422
429
423
        $query .= qq|
430
        $query .= "
424
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
431
            , (
425
        |;
432
                ( subscription.branchcode NOT IN ( " . join(',', ('?') x @branches) . " ) )
433
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
434
            ) AS cannotedit
435
        ";
426
    }
436
    }
427
437
428
    $query .= qq|
438
    $query .= qq|
Lines 438-444 sub GetFullSubscription { Link Here
438
          |;
448
          |;
439
    $debug and warn "GetFullSubscription query: $query";
449
    $debug and warn "GetFullSubscription query: $query";
440
    my $sth = $dbh->prepare($query);
450
    my $sth = $dbh->prepare($query);
441
    $sth->execute($subscriptionid);
451
    $sth->execute( $subscriptionid, @branches );
442
    my $subscriptions = $sth->fetchall_arrayref( {} );
452
    my $subscriptions = $sth->fetchall_arrayref( {} );
443
    for my $subscription ( @$subscriptions ) {
453
    for my $subscription ( @$subscriptions ) {
444
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
454
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
Lines 595-611 sub GetFullSubscriptionsFromBiblionumber { Link Here
595
            subscription.subscriptionid AS subscriptionid
605
            subscription.subscriptionid AS subscriptionid
596
    |;
606
    |;
597
607
608
    my @branches;
598
    if (   C4::Context->preference('IndependentBranches')
609
    if (   C4::Context->preference('IndependentBranches')
599
        && C4::Context->userenv
610
        && C4::Context->userenv
600
        && C4::Context->userenv->{'flags'} != 1
611
        && C4::Context->userenv->{'flags'} != 1
601
        && C4::Context->userenv->{'branch'} )
612
        && C4::Context->userenv->{'branch'} )
602
    {
613
    {
603
        my $branches =
614
        @branches = GetIndependentGroupModificationRights();
604
          GetIndependentGroupModificationRights( { stringify => 1 } );
605
615
606
        $query .= qq|
616
        $query .= "
607
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
617
            , (
608
        |;
618
                ( subscription.branchcode NOT IN (" . join(',', ('?') x @branches) . ") )
619
                AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL
620
            ) AS cannotedit
621
        ";
609
    }
622
    }
610
623
611
    $query .= qq|
624
    $query .= qq|
Lines 620-626 sub GetFullSubscriptionsFromBiblionumber { Link Here
620
          serial.subscriptionid
633
          serial.subscriptionid
621
          |;
634
          |;
622
    my $sth = $dbh->prepare($query);
635
    my $sth = $dbh->prepare($query);
623
    $sth->execute($biblionumber);
636
    $sth->execute($biblionumber, @branches);
624
    my $subscriptions = $sth->fetchall_arrayref( {} );
637
    my $subscriptions = $sth->fetchall_arrayref( {} );
625
    for my $subscription ( @$subscriptions ) {
638
    for my $subscription ( @$subscriptions ) {
626
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
639
        $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 155-162 if ( $run_report ) { Link Here
155
155
156
156
157
    if (C4::Context->preference('IndependentBranches')){
157
    if (C4::Context->preference('IndependentBranches')){
158
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
158
        my @branches = GetIndependentGroupModificationRights();
159
        $strsth .= " AND items.holdingbranch IN ( $branches ) ";
159
        $strsth .= " AND items.holdingbranch IN ( " . join(',', ('?') x @branches) . " ) ";
160
        push( @query_params, @branches );
160
    }
161
    }
161
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
162
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
162
163
(-)a/circ/reserveratios.pl (-2 / +3 lines)
Lines 114-121 my $strsth = Link Here
114
";
114
";
115
115
116
if ( C4::Context->preference('IndependentBranches') ) {
116
if ( C4::Context->preference('IndependentBranches') ) {
117
    my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
117
    my @branches = GetIndependentGroupModificationRights();
118
    $strsth .= " AND items.holdingbranch IN ( $branches ) ";
118
    $strsth .= " AND items.holdingbranch IN (" . join(',', ('?') x @branches) . ") ";
119
    push( @query_params, @branches );
119
}
120
}
120
121
121
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC";
122
$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