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

(-)a/Koha/Patron.pm (-5 / +57 lines)
Lines 1356-1365 Return true if the patron (usually the logged in user) can see the patron's info Link Here
1356
1356
1357
sub can_see_patrons_from {
1357
sub can_see_patrons_from {
1358
    my ( $self, $branchcode ) = @_;
1358
    my ( $self, $branchcode ) = @_;
1359
1360
    return $self->can_see_things_from(
1361
        {
1362
            branchcode => $branchcode,
1363
            permission => 'borrowers',
1364
            subpermission => 'view_borrower_infos_from_any_libraries',
1365
        }
1366
    );
1367
}
1368
1369
=head3 can_see_things_from
1370
1371
my $can_see = $thing->can_see_things_from( $branchcode );
1372
1373
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing
1374
1375
=cut
1376
1377
sub can_see_things_from {
1378
    my ( $self, $params ) = @_;
1379
    my $branchcode    = $params->{branchcode};
1380
    my $permission    = $params->{permission};
1381
    my $subpermission = $params->{subpermission};
1382
1359
    my $can = 0;
1383
    my $can = 0;
1360
    if ( $self->branchcode eq $branchcode ) {
1384
    if ( $self->branchcode eq $branchcode ) {
1361
        $can = 1;
1385
        $can = 1;
1362
    } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
1386
    } elsif ( $self->has_permission( { $permission => $subpermission } ) ) {
1363
        $can = 1;
1387
        $can = 1;
1364
    } elsif ( my $library_groups = $self->library->library_groups ) {
1388
    } elsif ( my $library_groups = $self->library->library_groups ) {
1365
        while ( my $library_group = $library_groups->next ) {
1389
        while ( my $library_group = $library_groups->next ) {
Lines 1412-1418 An empty array means no restriction, the patron can see patron's infos from any Link Here
1412
=cut
1436
=cut
1413
1437
1414
sub libraries_where_can_see_patrons {
1438
sub libraries_where_can_see_patrons {
1415
    my ( $self ) = @_;
1439
    my ($self) = @_;
1440
1441
    return $self->libraries_where_can_see_things(
1442
        {
1443
            permission    => 'borrowers',
1444
            subpermission => 'view_borrower_infos_from_any_libraries',
1445
            group_feature => 'ft_hide_patron_info',
1446
        }
1447
    );
1448
}
1449
1450
=head3 libraries_where_can_see_things
1451
1452
my $libraries = $thing-libraries_where_can_see_things;
1453
1454
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian
1455
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ).
1456
1457
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library)
1458
1459
An empty array means no restriction, the thing can see thing's infos from any libraries.
1460
1461
=cut
1462
1463
sub libraries_where_can_see_things {
1464
    my ( $self, $params ) = @_;
1465
    my $permission    = $params->{permission};
1466
    my $subpermission = $params->{subpermission};
1467
    my $group_feature = $params->{group_feature};
1468
1416
    my $userenv = C4::Context->userenv;
1469
    my $userenv = C4::Context->userenv;
1417
1470
1418
    return () unless $userenv; # For tests, but userenv should be defined in tests...
1471
    return () unless $userenv; # For tests, but userenv should be defined in tests...
Lines 1424-1434 sub libraries_where_can_see_patrons { Link Here
1424
    else {
1477
    else {
1425
        unless (
1478
        unless (
1426
            $self->has_permission(
1479
            $self->has_permission(
1427
                { borrowers => 'view_borrower_infos_from_any_libraries' }
1480
                { $permission => $subpermission }
1428
            )
1481
            )
1429
          )
1482
          )
1430
        {
1483
        {
1431
            my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 });
1484
            my $library_groups = $self->library->library_groups({ $group_feature => 1 });
1432
            if ( $library_groups->count )
1485
            if ( $library_groups->count )
1433
            {
1486
            {
1434
                while ( my $library_group = $library_groups->next ) {
1487
                while ( my $library_group = $library_groups->next ) {
1435
- 

Return to bug 20256