From f7b3c0395ff55e5b5b98a371f59d2522acc347fd Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 6 Dec 2013 13:35:49 -0500 Subject: [PATCH] Bug 11351 - Add support for SIP2 media types Koha's SIP2 server implementation does not currently support the SIP2 protocol field "media type" ( CK ). This patch implements the SIP2 media type by allowing an arbitrary mapping of itemtypes to SIP2 media types. Test Plan: 1) Apply this patch 2) Run updatedatabase 3) Edit an itemtype, select a SIP media type, and save the changes 4) Make a SIP2 Item Information Request 5) Verify that the CK field of the Item Information Response contains the correct media type code. --- C4/SIP/ILS/Item.pm | 6 ++- admin/itemtypes.pl | 8 ++- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++ .../prog/en/modules/admin/itemtypes.tt | 71 ++++++++++++++++++++ 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index ba85cd7..a9a5c64 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -21,6 +21,7 @@ use C4::Items; use C4::Circulation; use C4::Members; use C4::Reserves; +use Koha::Database; our $VERSION = 3.07.00.049; @@ -86,7 +87,10 @@ sub new { $item->{permanent_location}= $item->{homebranch}; $item->{'collection_code'} = $item->{ccode}; $item->{ 'call_number' } = $item->{itemcallnumber}; - # $item->{'destination_loc'} = ? + + my $it = C4::Context->preference('item-level_itypes') ? $item->{itype} : $item->{itemtype}; + my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it ); + $item->{sip_media_type} = $item->sip_media_type() if $itemtype; # check if its on issue and if so get the borrower my $issue = GetItemIssue($item->{'itemnumber'}); diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 3c33073..df91e7b 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -121,6 +121,7 @@ if ( $op eq 'add_form' ) { checkinmsgtype => $data->{'checkinmsgtype'}, imagesets => $imagesets, remote_image => $remote_image, + sip_media_type => $data->{sip_media_type}, ); # END $OP eq ADD_FORM @@ -145,6 +146,7 @@ elsif ( $op eq 'add_validate' ) { , summary = ? , checkinmsg = ? , checkinmsgtype = ? + , sip_media_type = ? WHERE itemtype = ? '; $sth = $dbh->prepare($query2); @@ -162,15 +164,16 @@ elsif ( $op eq 'add_validate' ) { $input->param('summary'), $input->param('checkinmsg'), $input->param('checkinmsgtype'), + $input->param('sip_media_type'), $input->param('itemtype') ); } else { # add a new itemtype & not modif an old my $query = " INSERT INTO itemtypes - (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype) + (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type) VALUES - (?,?,?,?,?,?,?,?); + (?,?,?,?,?,?,?,?,?); "; my $sth = $dbh->prepare($query); my $image = $input->param('image'); @@ -185,6 +188,7 @@ elsif ( $op eq 'add_validate' ) { $input->param('summary'), $input->param('checkinmsg'), $input->param('checkinmsgtype'), + $input->param('sip_media_type'), ); } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 07160c8..a37b8ff 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1235,6 +1235,7 @@ CREATE TABLE `itemtypes` ( -- defines the item types summary text, -- information from the summary field, may include HTML checkinmsg VARCHAR(255), -- message that is displayed when an item with the given item type is checked in checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message" + sip_media_type VARCHAR( 3 ) NOT NULL DEFAULT "", -- SIP2 protocol media type for this itemtype PRIMARY KEY (`itemtype`), UNIQUE KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 19893b4..9301a85 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7824,6 +7824,14 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if(CheckVersion($DBversion)) { + $dbh->do(q{ + ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) NOT NULL DEFAULT "" + }); + print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n"; + SetVersion($DBversion); +} =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 57847eb..d2c5876 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -246,6 +246,77 @@ Item types administration + + [% IF sip_media_type == '000' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '001' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '002' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '003' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '004' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '005' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '006' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '007' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '008' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '009' %] + + [% ELSE %] + + [% END %] + + [% IF sip_media_type == '010' %] + + [% ELSE %] + + [% END %] + + +
  • Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype :

    -- 1.7.2.5