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

(-)a/Koha/Patron.pm (-5 / +57 lines)
Lines 1450-1459 Return true if the patron (usually the logged in user) can see the patron's info Link Here
1450
1450
1451
sub can_see_patrons_from {
1451
sub can_see_patrons_from {
1452
    my ( $self, $branchcode ) = @_;
1452
    my ( $self, $branchcode ) = @_;
1453
1454
    return $self->can_see_things_from(
1455
        {
1456
            branchcode => $branchcode,
1457
            permission => 'borrowers',
1458
            subpermission => 'view_borrower_infos_from_any_libraries',
1459
        }
1460
    );
1461
}
1462
1463
=head3 can_see_things_from
1464
1465
my $can_see = $thing->can_see_things_from( $branchcode );
1466
1467
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing
1468
1469
=cut
1470
1471
sub can_see_things_from {
1472
    my ( $self, $params ) = @_;
1473
    my $branchcode    = $params->{branchcode};
1474
    my $permission    = $params->{permission};
1475
    my $subpermission = $params->{subpermission};
1476
1453
    my $can = 0;
1477
    my $can = 0;
1454
    if ( $self->branchcode eq $branchcode ) {
1478
    if ( $self->branchcode eq $branchcode ) {
1455
        $can = 1;
1479
        $can = 1;
1456
    } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
1480
    } elsif ( $self->has_permission( { $permission => $subpermission } ) ) {
1457
        $can = 1;
1481
        $can = 1;
1458
    } elsif ( my $library_groups = $self->library->library_groups ) {
1482
    } elsif ( my $library_groups = $self->library->library_groups ) {
1459
        while ( my $library_group = $library_groups->next ) {
1483
        while ( my $library_group = $library_groups->next ) {
Lines 1506-1512 An empty array means no restriction, the patron can see patron's infos from any Link Here
1506
=cut
1530
=cut
1507
1531
1508
sub libraries_where_can_see_patrons {
1532
sub libraries_where_can_see_patrons {
1509
    my ( $self ) = @_;
1533
    my ($self) = @_;
1534
1535
    return $self->libraries_where_can_see_things(
1536
        {
1537
            permission    => 'borrowers',
1538
            subpermission => 'view_borrower_infos_from_any_libraries',
1539
            group_feature => 'ft_hide_patron_info',
1540
        }
1541
    );
1542
}
1543
1544
=head3 libraries_where_can_see_things
1545
1546
my $libraries = $thing-libraries_where_can_see_things;
1547
1548
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian
1549
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ).
1550
1551
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library)
1552
1553
An empty array means no restriction, the thing can see thing's infos from any libraries.
1554
1555
=cut
1556
1557
sub libraries_where_can_see_things {
1558
    my ( $self, $params ) = @_;
1559
    my $permission    = $params->{permission};
1560
    my $subpermission = $params->{subpermission};
1561
    my $group_feature = $params->{group_feature};
1562
1510
    my $userenv = C4::Context->userenv;
1563
    my $userenv = C4::Context->userenv;
1511
1564
1512
    return () unless $userenv; # For tests, but userenv should be defined in tests...
1565
    return () unless $userenv; # For tests, but userenv should be defined in tests...
Lines 1518-1528 sub libraries_where_can_see_patrons { Link Here
1518
    else {
1571
    else {
1519
        unless (
1572
        unless (
1520
            $self->has_permission(
1573
            $self->has_permission(
1521
                { borrowers => 'view_borrower_infos_from_any_libraries' }
1574
                { $permission => $subpermission }
1522
            )
1575
            )
1523
          )
1576
          )
1524
        {
1577
        {
1525
            my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 });
1578
            my $library_groups = $self->library->library_groups({ $group_feature => 1 });
1526
            if ( $library_groups->count )
1579
            if ( $library_groups->count )
1527
            {
1580
            {
1528
                while ( my $library_group = $library_groups->next ) {
1581
                while ( my $library_group = $library_groups->next ) {
1529
- 

Return to bug 20256