Bugzilla – Attachment 8540 Details for
Bug 7729
svc API should allow modification of items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
svc/bib: support appending ?items=1 to the URL to fetch or modify items
svcbib-support-appending-items1-to-the-URL-to-fetc.patch (text/plain), 2.39 KB, created by
MJ Ray (software.coop)
on 2012-03-22 16:42:42 UTC
(
hide
)
Description:
svc/bib: support appending ?items=1 to the URL to fetch or modify items
Filename:
MIME Type:
Creator:
MJ Ray (software.coop)
Created:
2012-03-22 16:42:42 UTC
Size:
2.39 KB
patch
obsolete
>From 19c711551ffec90ab116bf812a6f6771605dd52e Mon Sep 17 00:00:00 2001 >From: MJ Ray <mjr@phonecoop.coop> >Date: Thu, 22 Mar 2012 16:40:39 +0000 >Subject: [PATCH] svc/bib: support appending ?items=1 to the URL to fetch or modify items > >http://bugs.koha-community.org/show_bug.cgi?id=7729 >--- > svc/bib | 27 ++++++++++++++++++++++----- > 1 files changed, 22 insertions(+), 5 deletions(-) > >diff --git a/svc/bib b/svc/bib >index 4808559..8f6a168 100755 >--- a/svc/bib >+++ b/svc/bib >@@ -1,6 +1,7 @@ > #!/usr/bin/perl > > # Copyright 2007 LibLime >+# Copyright 2012 software.coop and MJ Ray > # > # This file is part of Koha. > # >@@ -24,6 +25,7 @@ use warnings; > use CGI; > use C4::Auth qw/check_api_auth/; > use C4::Biblio; >+use C4::Items; > use XML::Simple; > > my $query = new CGI; >@@ -58,7 +60,7 @@ exit 0; > sub fetch_bib { > my $query = shift; > my $biblionumber = shift; >- my $record = GetMarcBiblio($biblionumber); >+ my $record = GetMarcBiblio( $biblionumber, $query->url_param('items') ); > if (defined $record) { > print $query->header(-type => 'text/xml'); > print $record->as_xml_record(); >@@ -86,13 +88,28 @@ sub update_bib { > $result->{'status'} = "failed"; > $result->{'error'} = $@; > } else { >+ my $fullrecord = $record->clone(); >+ my ( $itemtag, $itemsubfield ) = >+ GetMarcFromKohaField( "items.itemnumber", '' ); >+ > # delete any item tags >- my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", ''); >- foreach my $field ($record->field($itemtag)) { >+ foreach my $field ( $record->field($itemtag) ) { > $record->delete_field($field); > } >- ModBiblio($record, $biblionumber, ''); >- my $new_record = GetMarcBiblio($biblionumber); >+ >+ if ( $query->url_param('items') ) { >+ foreach my $field ( $fullrecord->field($itemtag) ) { >+ my $one_item_record = $record->clone(); >+ $one_item_record->add_fields($field); >+ ModItemFromMarc( $one_item_record, $biblionumber, >+ $field->subfield($itemsubfield) ); >+ } >+ } >+ >+ ModBiblio( $record, $biblionumber, '' ); >+ my $new_record = >+ GetMarcBiblio( $biblionumber, $query->url_param('items') ); >+ > $result->{'status'} = "ok"; > $result->{'biblionumber'} = $biblionumber; > my $xml = $new_record->as_xml_record(); >-- >1.7.2.5
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 7729
:
8540
|
8544
|
9182
|
10738