Lines 1500-1509
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
1500 |
|
1500 |
|
1501 |
sub can_see_patrons_from { |
1501 |
sub can_see_patrons_from { |
1502 |
my ( $self, $branchcode ) = @_; |
1502 |
my ( $self, $branchcode ) = @_; |
|
|
1503 |
|
1504 |
return $self->can_see_things_from( |
1505 |
{ |
1506 |
branchcode => $branchcode, |
1507 |
permission => 'borrowers', |
1508 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1509 |
} |
1510 |
); |
1511 |
} |
1512 |
|
1513 |
=head3 can_see_things_from |
1514 |
|
1515 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1516 |
|
1517 |
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing |
1518 |
|
1519 |
=cut |
1520 |
|
1521 |
sub can_see_things_from { |
1522 |
my ( $self, $params ) = @_; |
1523 |
my $branchcode = $params->{branchcode}; |
1524 |
my $permission = $params->{permission}; |
1525 |
my $subpermission = $params->{subpermission}; |
1526 |
|
1503 |
my $can = 0; |
1527 |
my $can = 0; |
1504 |
if ( $self->branchcode eq $branchcode ) { |
1528 |
if ( $self->branchcode eq $branchcode ) { |
1505 |
$can = 1; |
1529 |
$can = 1; |
1506 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1530 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
1507 |
$can = 1; |
1531 |
$can = 1; |
1508 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1532 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1509 |
while ( my $library_group = $library_groups->next ) { |
1533 |
while ( my $library_group = $library_groups->next ) { |
Lines 1556-1562
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
1556 |
=cut |
1580 |
=cut |
1557 |
|
1581 |
|
1558 |
sub libraries_where_can_see_patrons { |
1582 |
sub libraries_where_can_see_patrons { |
1559 |
my ( $self ) = @_; |
1583 |
my ($self) = @_; |
|
|
1584 |
|
1585 |
return $self->libraries_where_can_see_things( |
1586 |
{ |
1587 |
permission => 'borrowers', |
1588 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1589 |
group_feature => 'ft_hide_patron_info', |
1590 |
} |
1591 |
); |
1592 |
} |
1593 |
|
1594 |
=head3 libraries_where_can_see_things |
1595 |
|
1596 |
my $libraries = $thing-libraries_where_can_see_things; |
1597 |
|
1598 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
1599 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
1600 |
|
1601 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
1602 |
|
1603 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
1604 |
|
1605 |
=cut |
1606 |
|
1607 |
sub libraries_where_can_see_things { |
1608 |
my ( $self, $params ) = @_; |
1609 |
my $permission = $params->{permission}; |
1610 |
my $subpermission = $params->{subpermission}; |
1611 |
my $group_feature = $params->{group_feature}; |
1612 |
|
1560 |
my $userenv = C4::Context->userenv; |
1613 |
my $userenv = C4::Context->userenv; |
1561 |
|
1614 |
|
1562 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1615 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
Lines 1568-1578
sub libraries_where_can_see_patrons {
Link Here
|
1568 |
else { |
1621 |
else { |
1569 |
unless ( |
1622 |
unless ( |
1570 |
$self->has_permission( |
1623 |
$self->has_permission( |
1571 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1624 |
{ $permission => $subpermission } |
1572 |
) |
1625 |
) |
1573 |
) |
1626 |
) |
1574 |
{ |
1627 |
{ |
1575 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1628 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
1576 |
if ( $library_groups->count ) |
1629 |
if ( $library_groups->count ) |
1577 |
{ |
1630 |
{ |
1578 |
while ( my $library_group = $library_groups->next ) { |
1631 |
while ( my $library_group = $library_groups->next ) { |
1579 |
- |
|
|