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

(-)a/Koha/Patron.pm (-5 / +57 lines)
Lines 1484-1493 Return true if the patron (usually the logged in user) can see the patron's info Link Here
1484
1484
1485
sub can_see_patrons_from {
1485
sub can_see_patrons_from {
1486
    my ( $self, $branchcode ) = @_;
1486
    my ( $self, $branchcode ) = @_;
1487
1488
    return $self->can_see_things_from(
1489
        {
1490
            branchcode => $branchcode,
1491
            permission => 'borrowers',
1492
            subpermission => 'view_borrower_infos_from_any_libraries',
1493
        }
1494
    );
1495
}
1496
1497
=head3 can_see_things_from
1498
1499
my $can_see = $thing->can_see_things_from( $branchcode );
1500
1501
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing
1502
1503
=cut
1504
1505
sub can_see_things_from {
1506
    my ( $self, $params ) = @_;
1507
    my $branchcode    = $params->{branchcode};
1508
    my $permission    = $params->{permission};
1509
    my $subpermission = $params->{subpermission};
1510
1487
    my $can = 0;
1511
    my $can = 0;
1488
    if ( $self->branchcode eq $branchcode ) {
1512
    if ( $self->branchcode eq $branchcode ) {
1489
        $can = 1;
1513
        $can = 1;
1490
    } elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) {
1514
    } elsif ( $self->has_permission( { $permission => $subpermission } ) ) {
1491
        $can = 1;
1515
        $can = 1;
1492
    } elsif ( my $library_groups = $self->library->library_groups ) {
1516
    } elsif ( my $library_groups = $self->library->library_groups ) {
1493
        while ( my $library_group = $library_groups->next ) {
1517
        while ( my $library_group = $library_groups->next ) {
Lines 1540-1546 An empty array means no restriction, the patron can see patron's infos from any Link Here
1540
=cut
1564
=cut
1541
1565
1542
sub libraries_where_can_see_patrons {
1566
sub libraries_where_can_see_patrons {
1543
    my ( $self ) = @_;
1567
    my ($self) = @_;
1568
1569
    return $self->libraries_where_can_see_things(
1570
        {
1571
            permission    => 'borrowers',
1572
            subpermission => 'view_borrower_infos_from_any_libraries',
1573
            group_feature => 'ft_hide_patron_info',
1574
        }
1575
    );
1576
}
1577
1578
=head3 libraries_where_can_see_things
1579
1580
my $libraries = $thing-libraries_where_can_see_things;
1581
1582
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian
1583
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ).
1584
1585
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library)
1586
1587
An empty array means no restriction, the thing can see thing's infos from any libraries.
1588
1589
=cut
1590
1591
sub libraries_where_can_see_things {
1592
    my ( $self, $params ) = @_;
1593
    my $permission    = $params->{permission};
1594
    my $subpermission = $params->{subpermission};
1595
    my $group_feature = $params->{group_feature};
1596
1544
    my $userenv = C4::Context->userenv;
1597
    my $userenv = C4::Context->userenv;
1545
1598
1546
    return () unless $userenv; # For tests, but userenv should be defined in tests...
1599
    return () unless $userenv; # For tests, but userenv should be defined in tests...
Lines 1552-1562 sub libraries_where_can_see_patrons { Link Here
1552
    else {
1605
    else {
1553
        unless (
1606
        unless (
1554
            $self->has_permission(
1607
            $self->has_permission(
1555
                { borrowers => 'view_borrower_infos_from_any_libraries' }
1608
                { $permission => $subpermission }
1556
            )
1609
            )
1557
          )
1610
          )
1558
        {
1611
        {
1559
            my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 });
1612
            my $library_groups = $self->library->library_groups({ $group_feature => 1 });
1560
            if ( $library_groups->count )
1613
            if ( $library_groups->count )
1561
            {
1614
            {
1562
                while ( my $library_group = $library_groups->next ) {
1615
                while ( my $library_group = $library_groups->next ) {
1563
- 

Return to bug 20256