Lines 1348-1357
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
1348 |
|
1348 |
|
1349 |
sub can_see_patrons_from { |
1349 |
sub can_see_patrons_from { |
1350 |
my ( $self, $branchcode ) = @_; |
1350 |
my ( $self, $branchcode ) = @_; |
|
|
1351 |
|
1352 |
return $self->can_see_things_from( |
1353 |
{ |
1354 |
branchcode => $branchcode, |
1355 |
permission => 'borrowers', |
1356 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1357 |
} |
1358 |
); |
1359 |
} |
1360 |
|
1361 |
=head3 can_see_things_from |
1362 |
|
1363 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1364 |
|
1365 |
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing |
1366 |
|
1367 |
=cut |
1368 |
|
1369 |
sub can_see_things_from { |
1370 |
my ( $self, $params ) = @_; |
1371 |
my $branchcode = $params->{branchcode}; |
1372 |
my $permission = $params->{permission}; |
1373 |
my $subpermission = $params->{subpermission}; |
1374 |
|
1351 |
my $can = 0; |
1375 |
my $can = 0; |
1352 |
if ( $self->branchcode eq $branchcode ) { |
1376 |
if ( $self->branchcode eq $branchcode ) { |
1353 |
$can = 1; |
1377 |
$can = 1; |
1354 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1378 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
1355 |
$can = 1; |
1379 |
$can = 1; |
1356 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1380 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1357 |
while ( my $library_group = $library_groups->next ) { |
1381 |
while ( my $library_group = $library_groups->next ) { |
Lines 1404-1410
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
1404 |
=cut |
1428 |
=cut |
1405 |
|
1429 |
|
1406 |
sub libraries_where_can_see_patrons { |
1430 |
sub libraries_where_can_see_patrons { |
1407 |
my ( $self ) = @_; |
1431 |
my ($self) = @_; |
|
|
1432 |
|
1433 |
return $self->libraries_where_can_see_things( |
1434 |
{ |
1435 |
permission => 'borrowers', |
1436 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1437 |
group_feature => 'ft_hide_patron_info', |
1438 |
} |
1439 |
); |
1440 |
} |
1441 |
|
1442 |
=head3 libraries_where_can_see_things |
1443 |
|
1444 |
my $libraries = $thing-libraries_where_can_see_things; |
1445 |
|
1446 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
1447 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
1448 |
|
1449 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
1450 |
|
1451 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
1452 |
|
1453 |
=cut |
1454 |
|
1455 |
sub libraries_where_can_see_things { |
1456 |
my ( $self, $params ) = @_; |
1457 |
my $permission = $params->{permission}; |
1458 |
my $subpermission = $params->{subpermission}; |
1459 |
my $group_feature = $params->{group_feature}; |
1460 |
|
1408 |
my $userenv = C4::Context->userenv; |
1461 |
my $userenv = C4::Context->userenv; |
1409 |
|
1462 |
|
1410 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1463 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
Lines 1416-1426
sub libraries_where_can_see_patrons {
Link Here
|
1416 |
else { |
1469 |
else { |
1417 |
unless ( |
1470 |
unless ( |
1418 |
$self->has_permission( |
1471 |
$self->has_permission( |
1419 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1472 |
{ $permission => $subpermission } |
1420 |
) |
1473 |
) |
1421 |
) |
1474 |
) |
1422 |
{ |
1475 |
{ |
1423 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1476 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
1424 |
if ( $library_groups->count ) |
1477 |
if ( $library_groups->count ) |
1425 |
{ |
1478 |
{ |
1426 |
while ( my $library_group = $library_groups->next ) { |
1479 |
while ( my $library_group = $library_groups->next ) { |
1427 |
- |
|
|