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