|
Lines 168-175
sub AddItemFromMarc {
Link Here
|
| 168 |
|
168 |
|
| 169 |
=head2 AddItem |
169 |
=head2 AddItem |
| 170 |
|
170 |
|
| 171 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
171 |
my ( $biblionumber, $biblioitemnumber, $itemnumber ) |
| 172 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); |
172 |
= AddItem( $item, $biblionumber[ , $dbh, $frameworkcode, $unlinked_item_subfields, $plugins ] ); |
| 173 |
|
173 |
|
| 174 |
Given a hash containing item column names as keys, |
174 |
Given a hash containing item column names as keys, |
| 175 |
create a new Koha item record. |
175 |
create a new Koha item record. |
|
Lines 178-190
The first two optional parameters (C<$dbh> and C<$frameworkcode>)
Link Here
|
| 178 |
do not need to be supplied for general use; they exist |
178 |
do not need to be supplied for general use; they exist |
| 179 |
simply to allow them to be picked up from AddItemFromMarc. |
179 |
simply to allow them to be picked up from AddItemFromMarc. |
| 180 |
|
180 |
|
| 181 |
The final optional parameter, C<$unlinked_item_subfields>, contains |
181 |
The optional C<$unlinked_item_subfields> parameter contains |
| 182 |
an arrayref containing subfields present in the original MARC |
182 |
an arrayref containing subfields present in the original MARC |
| 183 |
representation of the item (e.g., from the item editor) that are |
183 |
representation of the item (e.g., from the item editor) that are |
| 184 |
not mapped to C<items> columns directly but should instead |
184 |
not mapped to C<items> columns directly but should instead |
| 185 |
be stored in C<items.more_subfields_xml> and included in |
185 |
be stored in C<items.more_subfields_xml> and included in |
| 186 |
the biblio items tag for display and indexing. |
186 |
the biblio items tag for display and indexing. |
| 187 |
|
187 |
|
|
|
188 |
The optional C<$plugins> parameter contains an arrayref containing |
| 189 |
a list of plugin objects. If it is not passed they will get queried |
| 190 |
on the plugin hooks. |
| 191 |
|
| 188 |
=cut |
192 |
=cut |
| 189 |
|
193 |
|
| 190 |
sub AddItem { |
194 |
sub AddItem { |
|
Lines 197-202
sub AddItem {
Link Here
|
| 197 |
if (@_) { |
201 |
if (@_) { |
| 198 |
$unlinked_item_subfields = shift; |
202 |
$unlinked_item_subfields = shift; |
| 199 |
} |
203 |
} |
|
|
204 |
my $plugins = shift; |
| 200 |
|
205 |
|
| 201 |
# needs old biblionumber and biblioitemnumber |
206 |
# needs old biblionumber and biblioitemnumber |
| 202 |
$item->{'biblionumber'} = $biblionumber; |
207 |
$item->{'biblionumber'} = $biblionumber; |
|
Lines 225-231
sub AddItem {
Link Here
|
| 225 |
logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) |
230 |
logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) |
| 226 |
if C4::Context->preference("CataloguingLog"); |
231 |
if C4::Context->preference("CataloguingLog"); |
| 227 |
|
232 |
|
| 228 |
_after_item_action_hooks({ action => 'create', item_id => $itemnumber }); |
233 |
_after_item_action_hooks({ action => 'create', item_id => $itemnumber, plugins => $plugins }); |
| 229 |
|
234 |
|
| 230 |
return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber ); |
235 |
return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber ); |
| 231 |
} |
236 |
} |
|
Lines 443-450
ModItem(
Link Here
|
| 443 |
$biblionumber, |
448 |
$biblionumber, |
| 444 |
$itemnumber, |
449 |
$itemnumber, |
| 445 |
{ |
450 |
{ |
| 446 |
[ unlinked_item_subfields => $unlinked_item_subfields, ] |
451 |
[ unlinked_item_subfields => $unlinked_item_subfields, ], |
| 447 |
[ log_action => 1, ] |
452 |
[ log_action => 1, ], |
|
|
453 |
[ plugins => [ $plugin_1, ... ] ] |
| 448 |
} |
454 |
} |
| 449 |
); |
455 |
); |
| 450 |
|
456 |
|
|
Lines 471-482
and set the value.
Link Here
|
| 471 |
If log_action is set to false, the action will not be logged. |
477 |
If log_action is set to false, the action will not be logged. |
| 472 |
If log_action is true or undefined, the action will be logged. |
478 |
If log_action is true or undefined, the action will be logged. |
| 473 |
|
479 |
|
|
|
480 |
If plugins is passed an arrayref, then it is passed to the plugin |
| 481 |
hooks so no plugin query needs to take place. |
| 482 |
|
| 474 |
=cut |
483 |
=cut |
| 475 |
|
484 |
|
| 476 |
sub ModItem { |
485 |
sub ModItem { |
| 477 |
my ( $item, $biblionumber, $itemnumber, $additional_params ) = @_; |
486 |
my ( $item, $biblionumber, $itemnumber, $additional_params ) = @_; |
| 478 |
my $log_action = $additional_params->{log_action} // 1; |
487 |
my $log_action = $additional_params->{log_action} // 1; |
| 479 |
my $unlinked_item_subfields = $additional_params->{unlinked_item_subfields}; |
488 |
my $unlinked_item_subfields = $additional_params->{unlinked_item_subfields}; |
|
|
489 |
my $plugins = $additional_params->{plugins}; |
| 480 |
|
490 |
|
| 481 |
return unless %$item; |
491 |
return unless %$item; |
| 482 |
$item->{'itemnumber'} = $itemnumber or return; |
492 |
$item->{'itemnumber'} = $itemnumber or return; |
|
Lines 531-537
sub ModItem {
Link Here
|
| 531 |
# item status is possible |
541 |
# item status is possible |
| 532 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); |
542 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); |
| 533 |
|
543 |
|
| 534 |
_after_item_action_hooks({ action => 'modify', item_id => $itemnumber }); |
544 |
_after_item_action_hooks({ action => 'modify', item_id => $itemnumber, plugins => $plugins }); |
| 535 |
|
545 |
|
| 536 |
logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) ) |
546 |
logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) ) |
| 537 |
if $log_action && C4::Context->preference("CataloguingLog"); |
547 |
if $log_action && C4::Context->preference("CataloguingLog"); |
|
Lines 592-598
sub ModDateLastSeen {
Link Here
|
| 592 |
|
602 |
|
| 593 |
=head2 DelItem |
603 |
=head2 DelItem |
| 594 |
|
604 |
|
| 595 |
DelItem({ itemnumber => $itemnumber, [ biblionumber => $biblionumber ] } ); |
605 |
DelItem({ itemnumber => $itemnumber, [ biblionumber => $biblionumber, plugins => [ $plugin_1, ... ] ] } ); |
| 596 |
|
606 |
|
| 597 |
Exported function (core API) for deleting an item record in Koha. |
607 |
Exported function (core API) for deleting an item record in Koha. |
| 598 |
|
608 |
|
|
Lines 603-608
sub DelItem {
Link Here
|
| 603 |
|
613 |
|
| 604 |
my $itemnumber = $params->{itemnumber}; |
614 |
my $itemnumber = $params->{itemnumber}; |
| 605 |
my $biblionumber = $params->{biblionumber}; |
615 |
my $biblionumber = $params->{biblionumber}; |
|
|
616 |
my $plugins = $params->{plugins}; |
| 606 |
|
617 |
|
| 607 |
unless ($biblionumber) { |
618 |
unless ($biblionumber) { |
| 608 |
my $item = Koha::Items->find( $itemnumber ); |
619 |
my $item = Koha::Items->find( $itemnumber ); |
|
Lines 617-623
sub DelItem {
Link Here
|
| 617 |
|
628 |
|
| 618 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); |
629 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); |
| 619 |
|
630 |
|
| 620 |
_after_item_action_hooks({ action => 'delete', item_id => $itemnumber }); |
631 |
_after_item_action_hooks({ action => 'delete', item_id => $itemnumber, plugins => $plugins }); |
| 621 |
|
632 |
|
| 622 |
#search item field code |
633 |
#search item field code |
| 623 |
logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); |
634 |
logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); |
|
Lines 2653-2664
sub _after_item_action_hooks {
Link Here
|
| 2653 |
|
2664 |
|
| 2654 |
my $item_id = $args->{item_id}; |
2665 |
my $item_id = $args->{item_id}; |
| 2655 |
my $action = $args->{action}; |
2666 |
my $action = $args->{action}; |
|
|
2667 |
my $plugins = $args->{plugins}; |
| 2656 |
|
2668 |
|
| 2657 |
if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) { |
2669 |
if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) { |
| 2658 |
|
2670 |
|
| 2659 |
my @plugins = Koha::Plugins->new->GetPlugins({ |
2671 |
my @plugins; |
| 2660 |
method => 'after_item_action', |
2672 |
|
| 2661 |
}); |
2673 |
if ( $plugins and |
|
|
2674 |
ref($plugins) eq 'ARRAY' ) { |
| 2675 |
@plugins = grep { $_->can('after_item_action') } @{ $plugins }; |
| 2676 |
} |
| 2677 |
else { |
| 2678 |
# We haven't been passed a plugins list, get it ourselves |
| 2679 |
@plugins = Koha::Plugins->new->GetPlugins({ |
| 2680 |
method => 'after_item_action', |
| 2681 |
}); |
| 2682 |
} |
| 2662 |
|
2683 |
|
| 2663 |
if (@plugins) { |
2684 |
if (@plugins) { |
| 2664 |
|
2685 |
|
| 2665 |
- |
|
|