Lines 1510-1560
sub can_see_patrons_from {
Link Here
|
1510 |
); |
1510 |
); |
1511 |
} |
1511 |
} |
1512 |
|
1512 |
|
1513 |
=head3 can_edit_item |
1513 |
=head3 can_edit_items_from |
1514 |
|
|
|
1515 |
my $can_edit = $patron->can_edit_item( $item ); |
1516 |
|
1514 |
|
1517 |
Return true if the patron (usually the logged in user) can edit the given item |
1515 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
1518 |
|
1516 |
|
1519 |
The parameter can be a Koha::Item, an item hashref, or a branchcode. |
1517 |
Return true if the I<Koha::Patron> can edit items from the given branchcode |
1520 |
|
1518 |
|
1521 |
=cut |
1519 |
=cut |
1522 |
|
1520 |
|
1523 |
sub can_edit_item { |
1521 |
sub can_edit_items_from { |
1524 |
my ( $self, $item ) = @_; |
1522 |
my ( $self, $branchcode ) = @_; |
1525 |
|
|
|
1526 |
my $userenv = C4::Context->userenv(); |
1527 |
|
1528 |
my $ref = ref($item); |
1529 |
|
1530 |
my $branchcode = |
1531 |
$ref eq 'Koha::Item' ? $item->homebranch |
1532 |
: $ref eq 'HASH' ? $item->{homebranch} |
1533 |
: $ref eq q{} ? $item |
1534 |
: undef; |
1535 |
|
1536 |
return unless $branchcode; |
1537 |
|
1523 |
|
1538 |
return 1 if C4::Context->IsSuperLibrarian(); |
1524 |
return 1 if C4::Context->IsSuperLibrarian(); |
1539 |
|
1525 |
|
|
|
1526 |
my $userenv = C4::Context->userenv(); |
1540 |
if ( $userenv && C4::Context->preference('IndependentBranches') ) { |
1527 |
if ( $userenv && C4::Context->preference('IndependentBranches') ) { |
1541 |
return $userenv->{branch} eq $branchcode; |
1528 |
return $userenv->{branch} eq $branchcode; |
1542 |
} |
1529 |
} |
1543 |
|
1530 |
|
1544 |
return $self->can_edit_items_from($branchcode); |
|
|
1545 |
} |
1546 |
|
1547 |
=head3 can_edit_items_from |
1548 |
|
1549 |
my $can_edit = $patron->can_edit_items_from( $branchcode ); |
1550 |
|
1551 |
Return true if the I<Koha::Patron> can edit items from the given branchcode |
1552 |
|
1553 |
=cut |
1554 |
|
1555 |
sub can_edit_items_from { |
1556 |
my ( $self, $branchcode ) = @_; |
1557 |
|
1558 |
return $self->can_see_things_from( |
1531 |
return $self->can_see_things_from( |
1559 |
{ |
1532 |
{ |
1560 |
branchcode => $branchcode, |
1533 |
branchcode => $branchcode, |
Lines 1622-1631
Return true if the I<Koha::Patron> can perform some action on the given thing
Link Here
|
1622 |
|
1595 |
|
1623 |
sub can_see_things_from { |
1596 |
sub can_see_things_from { |
1624 |
my ( $self, $params ) = @_; |
1597 |
my ( $self, $params ) = @_; |
|
|
1598 |
|
1625 |
my $branchcode = $params->{branchcode}; |
1599 |
my $branchcode = $params->{branchcode}; |
1626 |
my $permission = $params->{permission}; |
1600 |
my $permission = $params->{permission}; |
1627 |
my $subpermission = $params->{subpermission}; |
1601 |
my $subpermission = $params->{subpermission}; |
1628 |
|
1602 |
|
|
|
1603 |
return 1 if C4::Context->IsSuperLibrarian(); |
1604 |
|
1629 |
my $can = 0; |
1605 |
my $can = 0; |
1630 |
if ( $self->branchcode eq $branchcode ) { |
1606 |
if ( $self->branchcode eq $branchcode ) { |
1631 |
$can = 1; |
1607 |
$can = 1; |