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

(-)a/Koha/Patron.pm (-2 / +2 lines)
Lines 1818-1825 sub can_see_patrons_from { Link Here
1818
1818
1819
    return $self->can_see_things_from(
1819
    return $self->can_see_things_from(
1820
        {
1820
        {
1821
            branchcode => $branchcode,
1821
            branchcode    => $branchcode,
1822
            permission => 'borrowers',
1822
            permission    => 'borrowers',
1823
            subpermission => 'view_borrower_infos_from_any_libraries',
1823
            subpermission => 'view_borrower_infos_from_any_libraries',
1824
            group_feature => 'ft_hide_patron_info',
1824
            group_feature => 'ft_hide_patron_info',
1825
        }
1825
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt (-2 / +2 lines)
Lines 440-449 Link Here
440
            [% UNLESS group.branchcode %]
440
            [% UNLESS group.branchcode %]
441
              <ul>
441
              <ul>
442
                [% IF group.ft_hide_patron_info %]
442
                [% IF group.ft_hide_patron_info %]
443
                    <li>Hide patron's info for librarians outside of this group.</li>
443
                    <li>Limit patron visibility to libraries within this group for members.</li>
444
                [% END %]
444
                [% END %]
445
                [% IF group.ft_limit_item_editing %]
445
                [% IF group.ft_limit_item_editing %]
446
                    <li>Limit item editing to librarians inside of this group.</li>
446
                    <li>Limit item editing to items owned inside of this group.</li>
447
                [% END %]
447
                [% END %]
448
                [% IF group.ft_search_groups_opac %]
448
                [% IF group.ft_search_groups_opac %]
449
                    <li>Use for OPAC search groups</li>
449
                    <li>Use for OPAC search groups</li>
(-)a/t/db_dependent/Koha/Patrons.t (-19 / +13 lines)
Lines 83-90 is( Koha::Patrons->search->count, $nb_of_patrons + 2, 'The 2 patrons should have Link Here
83
my $retrieved_patron_1 = Koha::Patrons->find( $new_patron_1->borrowernumber );
83
my $retrieved_patron_1 = Koha::Patrons->find( $new_patron_1->borrowernumber );
84
is( $retrieved_patron_1->cardnumber, $new_patron_1->cardnumber, 'Find a patron by borrowernumber should return the correct patron' );
84
is( $retrieved_patron_1->cardnumber, $new_patron_1->cardnumber, 'Find a patron by borrowernumber should return the correct patron' );
85
85
86
87
88
subtest 'library' => sub {
86
subtest 'library' => sub {
89
    plan tests => 2;
87
    plan tests => 2;
90
    is( $retrieved_patron_1->library->branchcode, $library->{branchcode}, 'Koha::Patron->library should return the correct library' );
88
    is( $retrieved_patron_1->library->branchcode, $library->{branchcode}, 'Koha::Patron->library should return the correct library' );
Lines 1319-1330 subtest Link Here
1319
    # group2
1317
    # group2
1320
    #   + library21
1318
    #   + library21
1321
    $nb_of_patrons = Koha::Patrons->search->count;
1319
    $nb_of_patrons = Koha::Patrons->search->count;
1322
    my $group_1 =
1320
    my $group_1    = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store;
1323
        Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )
1321
    my $group_2    = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store;
1324
        ->store;
1325
    my $group_2 =
1326
        Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )
1327
        ->store;
1328
    my $library_11 = $builder->build( { source => 'Branch' } );
1322
    my $library_11 = $builder->build( { source => 'Branch' } );
1329
    my $library_12 = $builder->build( { source => 'Branch' } );
1323
    my $library_12 = $builder->build( { source => 'Branch' } );
1330
    my $library_21 = $builder->build( { source => 'Branch' } );
1324
    my $library_21 = $builder->build( { source => 'Branch' } );
Lines 1336-1351 subtest Link Here
1336
    Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store;
1330
    Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store;
1337
1331
1338
    my $sth =
1332
    my $sth =
1339
        C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)|)
1333
        C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)|);
1340
        ;
1334
1341
             # 2 patrons from library_11 (group1)
1335
    # 2 patrons from library_11 (group1)
1342
             # patron_11_1 see patron's infos from outside its group
1336
    # patron_11_1 see patron's infos from outside its group
1343
             # Setting flags => undef to not be considered as superlibrarian
1337
    # Setting flags => undef to not be considered as superlibrarian
1344
    my $patron_11_1 = $builder->build(
1338
    my $patron_11_1 = $builder->build(
1345
        { source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } );
1339
        { source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } );
1346
    $patron_11_1 = Koha::Patrons->find( $patron_11_1->{borrowernumber} );
1340
    $patron_11_1 = Koha::Patrons->find( $patron_11_1->{borrowernumber} );
1347
    $sth->execute( $patron_11_1->borrowernumber, 4, 'edit_borrowers' );
1341
    $sth->execute( $patron_11_1->borrowernumber, 4, 'edit_borrowers' );
1348
    $sth->execute( $patron_11_1->borrowernumber, 4,'view_borrower_infos_from_any_libraries' );
1342
    $sth->execute( $patron_11_1->borrowernumber, 4, 'view_borrower_infos_from_any_libraries' );
1349
1343
1350
    # patron_11_2 can only see patron's info from its group
1344
    # patron_11_2 can only see patron's info from its group
1351
    my $patron_11_2 = $builder->build(
1345
    my $patron_11_2 = $builder->build(
Lines 1376-1387 subtest Link Here
1376
        };
1370
        };
1377
        my @branchcodes = $patron_11_1->libraries_where_can_see_things($params);
1371
        my @branchcodes = $patron_11_1->libraries_where_can_see_things($params);
1378
        is_deeply(
1372
        is_deeply(
1379
            \@branchcodes, [ ],
1373
            \@branchcodes, [],
1380
            q|patron_11_1 has view_borrower_infos_from_any_libraries => No restriction|
1374
            q|patron_11_1 has view_borrower_infos_from_any_libraries => No restriction|
1381
        );
1375
        );
1382
        @branchcodes = $patron_11_1->libraries_where_can_see_things($params);
1376
        @branchcodes = $patron_11_1->libraries_where_can_see_things($params);
1383
        is_deeply(
1377
        is_deeply(
1384
            \@branchcodes, [ ],
1378
            \@branchcodes, [],
1385
            q|confirming second/cached request is the same patron_11_1 has view_borrower_infos_from_any_libraries => No restriction|
1379
            q|confirming second/cached request is the same patron_11_1 has view_borrower_infos_from_any_libraries => No restriction|
1386
        );
1380
        );
1387
1381
Lines 1415-1421 subtest Link Here
1415
        );
1409
        );
1416
        $group_1->ft_limit_item_editing(1)->store();
1410
        $group_1->ft_limit_item_editing(1)->store();
1417
1411
1418
        $patron_11_2  = Koha::Patrons->find( $patron_11_2->borrowernumber );
1412
        $patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber );
1413
1419
        #FIXME We refetch the patron because library lists are cached in an extra hash key
1414
        #FIXME We refetch the patron because library lists are cached in an extra hash key
1420
        # in libraries_where_can_see_things
1415
        # in libraries_where_can_see_things
1421
1416
Lines 1425-1431 subtest Link Here
1425
        );
1420
        );
1426
1421
1427
        $sth->execute( $patron_11_2->borrowernumber, 9, 'edit_any_item' );
1422
        $sth->execute( $patron_11_2->borrowernumber, 9, 'edit_any_item' );
1428
        $patron_11_2  = Koha::Patrons->find( $patron_11_2->borrowernumber );
1423
        $patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber );
1429
1424
1430
        ok(
1425
        ok(
1431
            $patron_11_2->can_edit_items_from( $library_21->branchcode ),
1426
            $patron_11_2->can_edit_items_from( $library_21->branchcode ),
1432
- 

Return to bug 37392