|
Lines 1340-1349
Return true if the patron (usually the logged in user) can see the patron's info
Link Here
|
| 1340 |
|
1340 |
|
| 1341 |
sub can_see_patrons_from { |
1341 |
sub can_see_patrons_from { |
| 1342 |
my ( $self, $branchcode ) = @_; |
1342 |
my ( $self, $branchcode ) = @_; |
|
|
1343 |
|
| 1344 |
return $self->can_see_things_from( |
| 1345 |
{ |
| 1346 |
branchcode => $branchcode, |
| 1347 |
permission => 'borrowers', |
| 1348 |
subpermission => 'view_borrower_infos_from_any_libraries', |
| 1349 |
} |
| 1350 |
); |
| 1351 |
} |
| 1352 |
|
| 1353 |
=head3 can_see_things_from |
| 1354 |
|
| 1355 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
| 1356 |
|
| 1357 |
Return true if this "patron" ( usually the logged in user ) can perform some action on the given thing |
| 1358 |
|
| 1359 |
=cut |
| 1360 |
|
| 1361 |
sub can_see_things_from { |
| 1362 |
my ( $self, $params ) = @_; |
| 1363 |
my $branchcode = $params->{branchcode}; |
| 1364 |
my $permission = $params->{permission}; |
| 1365 |
my $subpermission = $params->{subpermission}; |
| 1366 |
|
| 1343 |
my $can = 0; |
1367 |
my $can = 0; |
| 1344 |
if ( $self->branchcode eq $branchcode ) { |
1368 |
if ( $self->branchcode eq $branchcode ) { |
| 1345 |
$can = 1; |
1369 |
$can = 1; |
| 1346 |
} elsif ( $self->has_permission( { borrowers => 'view_borrower_infos_from_any_libraries' } ) ) { |
1370 |
} elsif ( $self->has_permission( { $permission => $subpermission } ) ) { |
| 1347 |
$can = 1; |
1371 |
$can = 1; |
| 1348 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
1372 |
} elsif ( my $library_groups = $self->library->library_groups ) { |
| 1349 |
while ( my $library_group = $library_groups->next ) { |
1373 |
while ( my $library_group = $library_groups->next ) { |
|
Lines 1369-1375
An empty array means no restriction, the patron can see patron's infos from any
Link Here
|
| 1369 |
=cut |
1393 |
=cut |
| 1370 |
|
1394 |
|
| 1371 |
sub libraries_where_can_see_patrons { |
1395 |
sub libraries_where_can_see_patrons { |
| 1372 |
my ( $self ) = @_; |
1396 |
my ($self) = @_; |
|
|
1397 |
|
| 1398 |
return $self->libraries_where_can_see_things( |
| 1399 |
{ |
| 1400 |
permission => 'borrowers', |
| 1401 |
subpermission => 'view_borrower_infos_from_any_libraries', |
| 1402 |
group_feature => 'ft_hide_patron_info', |
| 1403 |
} |
| 1404 |
); |
| 1405 |
} |
| 1406 |
|
| 1407 |
=head3 libraries_where_can_see_things |
| 1408 |
|
| 1409 |
my $libraries = $thing-libraries_where_can_see_things; |
| 1410 |
|
| 1411 |
Returns a list of libraries where an aribitarary action is allowd to be taken by the logged in librarian |
| 1412 |
against an object based on some branchcode related to the object ( patron branchcode, item homebranch, etc ). |
| 1413 |
|
| 1414 |
We are supposing here that the object is related to the logged in librarian (use of C4::Context::only_my_library) |
| 1415 |
|
| 1416 |
An empty array means no restriction, the thing can see thing's infos from any libraries. |
| 1417 |
|
| 1418 |
=cut |
| 1419 |
|
| 1420 |
sub libraries_where_can_see_things { |
| 1421 |
my ( $self, $params ) = @_; |
| 1422 |
my $permission = $params->{permission}; |
| 1423 |
my $subpermission = $params->{subpermission}; |
| 1424 |
my $group_feature = $params->{group_feature}; |
| 1425 |
|
| 1373 |
my $userenv = C4::Context->userenv; |
1426 |
my $userenv = C4::Context->userenv; |
| 1374 |
|
1427 |
|
| 1375 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
1428 |
return () unless $userenv; # For tests, but userenv should be defined in tests... |
|
Lines 1381-1391
sub libraries_where_can_see_patrons {
Link Here
|
| 1381 |
else { |
1434 |
else { |
| 1382 |
unless ( |
1435 |
unless ( |
| 1383 |
$self->has_permission( |
1436 |
$self->has_permission( |
| 1384 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
1437 |
{ $permission => $subpermission } |
| 1385 |
) |
1438 |
) |
| 1386 |
) |
1439 |
) |
| 1387 |
{ |
1440 |
{ |
| 1388 |
my $library_groups = $self->library->library_groups({ ft_hide_patron_info => 1 }); |
1441 |
my $library_groups = $self->library->library_groups({ $group_feature => 1 }); |
| 1389 |
if ( $library_groups->count ) |
1442 |
if ( $library_groups->count ) |
| 1390 |
{ |
1443 |
{ |
| 1391 |
while ( my $library_group = $library_groups->next ) { |
1444 |
while ( my $library_group = $library_groups->next ) { |
| 1392 |
- |
|
|