Lines 1510-1515
sub can_see_patrons_from {
Link Here
|
1510 |
); |
1510 |
); |
1511 |
} |
1511 |
} |
1512 |
|
1512 |
|
|
|
1513 |
=head3 libraries_where_can_see_patrons |
1514 |
|
1515 |
my $libraries = $patron-libraries_where_can_see_patrons; |
1516 |
|
1517 |
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. |
1518 |
The branchcodes are arbitrarily returned sorted. |
1519 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1520 |
|
1521 |
An empty array means no restriction, the patron can see patron's infos from any libraries. |
1522 |
|
1523 |
=cut |
1524 |
|
1525 |
sub libraries_where_can_see_patrons { |
1526 |
my ($self) = @_; |
1527 |
|
1528 |
return $self->libraries_where_can_see_things( |
1529 |
{ |
1530 |
permission => 'borrowers', |
1531 |
subpermission => 'view_borrower_infos_from_any_libraries', |
1532 |
group_feature => 'ft_hide_patron_info', |
1533 |
} |
1534 |
); |
1535 |
} |
1536 |
|
1537 |
=head3 can_edit_item |
1538 |
|
1539 |
my $can_edit = $patron->can_edit_item( $item ); |
1540 |
|
1541 |
Return true if the patron (usually the logged in user) can edit the given item |
1542 |
|
1543 |
The parameter can be a Koha::Item, an item hashref, or a branchcode. |
1544 |
|
1545 |
=cut |
1546 |
|
1547 |
sub can_edit_item { |
1548 |
my ( $self, $item ) = @_; |
1549 |
|
1550 |
my $userenv = C4::Context->userenv(); |
1551 |
|
1552 |
my $ref = ref($item); |
1553 |
|
1554 |
my $branchcode = |
1555 |
$ref eq 'Koha::Item' ? $item->homebranch |
1556 |
: $ref eq 'HASH' ? $item->{homebranch} |
1557 |
: $ref eq q{} ? $item |
1558 |
: undef; |
1559 |
|
1560 |
return unless $branchcode; |
1561 |
|
1562 |
return 1 if C4::Context->IsSuperLibrarian(); |
1563 |
|
1564 |
if ( C4::Context->preference('IndependentBranches') ) { |
1565 |
return $userenv->{branch} eq $branchcode; |
1566 |
} |
1567 |
|
1568 |
return $self->can_edit_items_from($branchcode); |
1569 |
} |
1570 |
|
1571 |
=head3 can_edit_items_from |
1572 |
|
1573 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
1574 |
|
1575 |
Return true if this user can edit items from the give home branchcode |
1576 |
|
1577 |
=cut |
1578 |
|
1579 |
sub can_edit_items_from { |
1580 |
my ( $self, $branchcode ) = @_; |
1581 |
|
1582 |
return $self->can_see_things_from( |
1583 |
{ |
1584 |
branchcode => $branchcode, |
1585 |
permission => 'editcatalogue', |
1586 |
subpermission => 'edit_any_item', |
1587 |
} |
1588 |
); |
1589 |
} |
1590 |
|
1591 |
=head3 libraries_where_can_edit_items |
1592 |
|
1593 |
my $libraries = $patron->libraries_where_can_edit_items; |
1594 |
|
1595 |
Return the list of branchcodes(!) of libraries the patron is allowed to items for. |
1596 |
The branchcodes are arbitrarily returned sorted. |
1597 |
We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library) |
1598 |
|
1599 |
An empty array means no restriction, the user can edit any item. |
1600 |
|
1601 |
=cut |
1602 |
|
1603 |
sub libraries_where_can_edit_items { |
1604 |
my ($self) = @_; |
1605 |
|
1606 |
return $self->libraries_where_can_see_things( |
1607 |
{ |
1608 |
permission => 'editcatalogue', |
1609 |
subpermission => 'edit_any_item', |
1610 |
group_feature => 'ft_limit_item_editing', |
1611 |
} |
1612 |
); |
1613 |
} |
1614 |
|
1513 |
=head3 can_see_things_from |
1615 |
=head3 can_see_things_from |
1514 |
|
1616 |
|
1515 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1617 |
my $can_see = $thing->can_see_things_from( $branchcode ); |
1516 |
- |
|
|