Lines 1426-1435
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
1426 |
|
1426 |
|
1427 |
sub can_see_patrons_from { |
1427 |
sub can_see_patrons_from { |
1428 |
my ( $self, $branchcode ) = @_; |
1428 |
my ( $self, $branchcode ) = @_; |
|
|
1429 |
|
1430 |
return $self->can_see_things_from( |
1431 |
{ |
1432 |
branchcode => $branchcode, |
1433 |
permission => 'borrowers', |
1434 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1435 |
} |
1436 |
); |
1437 |
} |
1438 |
|
1439 |
=head3 can_see_things_from |
1440 |
|
1441 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1442 |
|
1443 |
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing |
1444 |
|
1445 |
=cut |
1446 |
|
1447 |
sub can_see_things_from { |
1448 |
my ( $self, $params ) = @_; |
1449 |
my $branchcode = $params->{branchcode}; |
1450 |
my $permission = $params->{permission}; |
1451 |
my $subpermission = $params->{subpermission}; |
1452 |
|
1429 |
my $can = 0; |
1453 |
my $can = 0; |
1430 |
if ( $self->branchcode eq $branchcode ) { |
1454 |
if ( $self->branchcode eq $branchcode ) { |
1431 |
$can = 1; |
1455 |
$can = 1; |
1432 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1456 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
1433 |
$can = 1; |
1457 |
$can = 1; |
1434 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1458 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1435 |
while ( my $library_group = $library_groups->next ) { |
1459 |
while ( my $library_group = $library_groups->next ) { |
Lines 1482-1488
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
1482 |
=cut |
1506 |
=cut |
1483 |
|
1507 |
|
1484 |
sub libraries_where_can_see_patrons { |
1508 |
sub libraries_where_can_see_patrons { |
1485 |
my ( $self ) = @_; |
1509 |
my ($self) = @_; |
|
|
1510 |
|
1511 |
return $self->libraries_where_can_see_things( |
1512 |
{ |
1513 |
permission => 'borrowers', |
1514 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1515 |
group_feature => 'ft_hide_patron_info', |
1516 |
} |
1517 |
); |
1518 |
} |
1519 |
|
1520 |
=head3 libraries_where_can_see_things |
1521 |
|
1522 |
my $libraries = $thing-libraries_where_can_see_things; |
1523 |
|
1524 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
1525 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
1526 |
|
1527 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
1528 |
|
1529 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
1530 |
|
1531 |
=cut |
1532 |
|
1533 |
sub libraries_where_can_see_things { |
1534 |
my ( $self, $params ) = @_; |
1535 |
my $permission = $params->{permission}; |
1536 |
my $subpermission = $params->{subpermission}; |
1537 |
my $group_feature = $params->{group_feature}; |
1538 |
|
1486 |
my $userenv = C4::Context->userenv; |
1539 |
my $userenv = C4::Context->userenv; |
1487 |
|
1540 |
|
1488 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1541 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
Lines 1494-1504
sub libraries_where_can_see_patrons {
Link Here
|
1494 |
else { |
1547 |
else { |
1495 |
unless ( |
1548 |
unless ( |
1496 |
$self->has_permission( |
1549 |
$self->has_permission( |
1497 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1550 |
{ $permission => $subpermission } |
1498 |
) |
1551 |
) |
1499 |
) |
1552 |
) |
1500 |
{ |
1553 |
{ |
1501 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1554 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
1502 |
if ( $library_groups->count ) |
1555 |
if ( $library_groups->count ) |
1503 |
{ |
1556 |
{ |
1504 |
while ( my $library_group = $library_groups->next ) { |
1557 |
while ( my $library_group = $library_groups->next ) { |
1505 |
- |
|
|