Bugzilla – Attachment 129710 Details for
Bug 29886
Add Koha::Suggestions->search_limited
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29886: Add Koha::Suggestions->search_limited
Bug-29886-Add-KohaSuggestions-searchlimited.patch (text/plain), 1.74 KB, created by
David Nind
on 2022-01-21 18:47:53 UTC
(
hide
)
Description:
Bug 29886: Add Koha::Suggestions->search_limited
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-01-21 18:47:53 UTC
Size:
1.74 KB
patch
obsolete
>From 2c9b350c2636274913a23450c2f7aea754411bd3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 14 Jan 2022 13:03:54 -0300 >Subject: [PATCH] Bug 29886: Add Koha::Suggestions->search_limited > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Suggestions.pm | 34 +++++++++++++++++++++++++++++++--- > 1 file changed, 31 insertions(+), 3 deletions(-) > >diff --git a/Koha/Suggestions.pm b/Koha/Suggestions.pm >index 03262bb5f1..5fadfd163b 100644 >--- a/Koha/Suggestions.pm >+++ b/Koha/Suggestions.pm >@@ -21,7 +21,6 @@ use Modern::Perl; > > > use Koha::Database; >- > use Koha::Suggestion; > > use base qw(Koha::Objects); >@@ -32,11 +31,40 @@ Koha::Suggestions - Koha Suggestion object set class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods >+ >+=head3 search_limited >+ >+ my $suggestions = Koha::Suggestions->search_limited( $params, $attributes ); >+ >+Returns all the suggestions the logged in user is allowed to see. > > =cut > >-=head3 type >+sub search_limited { >+ my ( $self, $params, $attributes ) = @_; >+ >+ my $resultset = $self; >+ >+ # filter on user branch >+ if ( C4::Context->preference('IndependentBranches') >+ && !C4::Context->IsSuperLibrarian() ) >+ { >+ # If IndependentBranches is set and the logged in user is not superlibrarian >+ # Then we want to filter by the user's library (i.e. cannot see suggestions >+ # from other libraries) >+ my $userenv = C4::Context->userenv; >+ >+ $resultset = $self->search({ branchcode => $userenv->{branch} }) >+ if $userenv && $userenv->{branch}; >+ } >+ >+ return $resultset->search( $params, $attributes); >+} >+ >+=head2 Internal methods >+ >+=head3 _type > > =cut > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29886
:
129508
|
129509
|
129709
|
129710
|
130294
|
130295
|
130296