View | Details | Raw Unified | Return to bug 29886
Collapse All | Expand All

(-)a/Koha/Suggestions.pm (-4 / +31 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
22
23
use Koha::Database;
23
use Koha::Database;
24
25
use Koha::Suggestion;
24
use Koha::Suggestion;
26
25
27
use base qw(Koha::Objects);
26
use base qw(Koha::Objects);
Lines 32-42 Koha::Suggestions - Koha Suggestion object set class Link Here
32
31
33
=head1 API
32
=head1 API
34
33
35
=head2 Class Methods
34
=head2 Class methods
35
36
=head3 search_limited
37
38
    my $suggestions = Koha::Suggestions->search_limited( $params, $attributes );
39
40
Returns all the suggestions the logged in user is allowed to see.
36
41
37
=cut
42
=cut
38
43
39
=head3 type
44
sub search_limited {
45
    my ( $self, $params, $attributes ) = @_;
46
47
    my $resultset = $self;
48
49
    # filter on user branch
50
    if (   C4::Context->preference('IndependentBranches')
51
        && !C4::Context->IsSuperLibrarian() )
52
    {
53
        # If IndependentBranches is set and the logged in user is not superlibrarian
54
        # Then we want to filter by the user's library (i.e. cannot see suggestions
55
        # from other libraries)
56
        my $userenv = C4::Context->userenv;
57
58
        $resultset = $self->search({ branchcode => $userenv->{branch} })
59
            if $userenv && $userenv->{branch};
60
    }
61
62
    return $resultset->search( $params, $attributes);
63
}
64
65
=head2 Internal methods
66
67
=head3 _type
40
68
41
=cut
69
=cut
42
70
43
- 

Return to bug 29886