Lines 1436-1441
sub can_see_patrons_from {
Link Here
|
1436 |
); |
1436 |
); |
1437 |
} |
1437 |
} |
1438 |
|
1438 |
|
|
|
1439 |
=head3 libraries_where_can_see_patrons |
1440 |
|
1441 |
my $libraries = $patron-libraries_where_can_see_patrons; |
1442 |
|
1443 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
1444 |
The branchcodes are arbitrarily returned sorted. |
1445 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1446 |
|
1447 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
1448 |
|
1449 |
=cut |
1450 |
|
1451 |
sub libraries_where_can_see_patrons { |
1452 |
my ($self) = @_; |
1453 |
|
1454 |
return $self->libraries_where_can_see_things( |
1455 |
{ |
1456 |
permission => 'borrowers', |
1457 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1458 |
group_feature => 'ft_hide_patron_info', |
1459 |
} |
1460 |
); |
1461 |
} |
1462 |
|
1463 |
=head3 can_edit_item |
1464 |
|
1465 |
my $can_edit = $patron->can_edit_item( $item ); |
1466 |
|
1467 |
Return true if the patron (usually the logged in user) can edit the given item |
1468 |
|
1469 |
The parameter can be a Koha::Item, an item hashref, or a branchcode. |
1470 |
|
1471 |
=cut |
1472 |
|
1473 |
sub can_edit_item { |
1474 |
my ( $self, $item ) = @_; |
1475 |
|
1476 |
my $userenv = C4::Context->userenv(); |
1477 |
|
1478 |
my $ref = ref($item); |
1479 |
|
1480 |
my $branchcode = |
1481 |
$ref eq 'Koha::Item' ? $item->homebranch |
1482 |
: $ref eq 'HASH' ? $item->{homebranch} |
1483 |
: $ref eq q{} ? $item |
1484 |
: undef; |
1485 |
|
1486 |
return unless $branchcode; |
1487 |
|
1488 |
return 1 if C4::Context->IsSuperLibrarian(); |
1489 |
|
1490 |
if ( C4::Context->preference('IndependentBranches') ) { |
1491 |
return $userenv->{branch} eq $branchcode; |
1492 |
} |
1493 |
|
1494 |
return $self->can_edit_items_from($branchcode); |
1495 |
} |
1496 |
|
1497 |
=head3 can_edit_items_from |
1498 |
|
1499 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
1500 |
|
1501 |
Return true if this user can edit items from the give home branchcode |
1502 |
|
1503 |
=cut |
1504 |
|
1505 |
sub can_edit_items_from { |
1506 |
my ( $self, $branchcode ) = @_; |
1507 |
|
1508 |
return $self->can_see_things_from( |
1509 |
{ |
1510 |
branchcode => $branchcode, |
1511 |
permission => 'editcatalogue', |
1512 |
subpermission => 'edit_any_item', |
1513 |
} |
1514 |
); |
1515 |
} |
1516 |
|
1517 |
=head3 libraries_where_can_edit_items |
1518 |
|
1519 |
my $libraries = $patron->libraries_where_can_edit_items; |
1520 |
|
1521 |
Return the list of branchcodes(!) of libraries the patron is allowed to items for. |
1522 |
The branchcodes are arbitrarily returned sorted. |
1523 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1524 |
|
1525 |
An empty array means no restriction, the user can edit any item. |
1526 |
|
1527 |
=cut |
1528 |
|
1529 |
sub libraries_where_can_edit_items { |
1530 |
my ($self) = @_; |
1531 |
|
1532 |
return $self->libraries_where_can_see_things( |
1533 |
{ |
1534 |
permission => 'editcatalogue', |
1535 |
subpermission => 'edit_any_item', |
1536 |
group_feature => 'ft_limit_item_editing', |
1537 |
} |
1538 |
); |
1539 |
} |
1540 |
|
1439 |
=head3 can_see_things_from |
1541 |
=head3 can_see_things_from |
1440 |
|
1542 |
|
1441 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1543 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1442 |
- |
|
|