Bugzilla – Attachment 56292 Details for
Bug 16825
Add API route for getting an item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16825: (followup) Add API route for getting an item
Bug-16825-followup-Add-API-route-for-getting-an-it.patch (text/plain), 2.05 KB, created by
Lari Taskula
on 2016-10-12 14:30:32 UTC
(
hide
)
Description:
Bug 16825: (followup) Add API route for getting an item
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2016-10-12 14:30:32 UTC
Size:
2.05 KB
patch
obsolete
>From 794e7896d5af55d51f27e644e389be450ff7cc08 Mon Sep 17 00:00:00 2001 >From: Jiri Kozlovsky <mail@jkozlovsky.cz> >Date: Mon, 1 Aug 2016 15:36:05 +0200 >Subject: [PATCH] Bug 16825: (followup) Add API route for getting an item > >Added on top of last patch the OpacHiddenItems syspref restriction for >users who are not staff. They see "Item Not Found" when trying to view >item hidden from OPAC. Only staff can see those > >GET /api/v1/items/{itemnumber} Gets one Item > >This patch adds route to get one item from koha.items table. This table >has a column "itemnotes_nonpublic", which should not be returned if the user >has no catalogue permission. > >To test: >1. Open a browser tab on Koha staff and log in (to create CGISESSID > cookie). >2. Send GET request to http://yourlibrary/api/v1/items/YYY > where YYY is an existing itemnumber. >3. Make sure the returned data is correct. >4. Run unit tests in t/db_dependent/api/v1/items.t > >Signed-off-by: Jiri Kozlovsky <mail@jkozlovsky.cz> >Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> > >Signed-off-by: Lari Taskula <larit@student.uef.fi> >--- > Koha/REST/V1/Item.pm | 9 +++++++++ > 1 file changed, 9 insertions(+) > >diff --git a/Koha/REST/V1/Item.pm b/Koha/REST/V1/Item.pm >index 03fd333..e300ecb 100644 >--- a/Koha/REST/V1/Item.pm >+++ b/Koha/REST/V1/Item.pm >@@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; > use Mojo::JSON; > > use C4::Auth qw( haspermission ); >+use C4::Items qw( GetHiddenItemnumbers ); > > use Koha::Items; > >@@ -36,6 +37,14 @@ sub get { > # Hide non-public itemnotes if user has no staff access > my $user = $c->stash('koha.user'); > unless ($user && haspermission($user->userid, {catalogue => 1})) { >+ >+ my @hiddenitems = C4::Items::GetHiddenItemnumbers( ({ itemnumber => $itemnumber}) ); >+ my %hiddenitems = map { $_ => 1 } @hiddenitems; >+ >+ # Pretend it was not found as it's hidden from OPAC to regular users >+ return $c->$cb({error => "Item not found"}, 404) >+ if $hiddenitems{$itemnumber}; >+ > $item->set({ itemnotes_nonpublic => undef }); > } > >-- >1.9.1
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 16825
:
52943
|
52947
|
53035
|
53108
|
53111
|
53222
|
53837
|
53921
|
53923
|
54052
|
54686
|
54687
|
56122
|
56123
|
56124
|
56125
|
56131
|
56133
|
56290
|
56292
|
56293
|
61176
|
64275
|
65007
|
67865
|
91051
|
91061
|
91124
|
91399
|
91401
|
92639