Bugzilla – Attachment 22172 Details for
Bug 11084
Delete biblios on Leader 05 =d
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11084 - Delete biblios on Leader 05 =d
Bug-11084---Delete-biblios-on-Leader-05-d.patch (text/plain), 4.59 KB, created by
Kyle M Hall (khall)
on 2013-10-21 18:44:37 UTC
(
hide
)
Description:
Bug 11084 - Delete biblios on Leader 05 =d
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-10-21 18:44:37 UTC
Size:
4.59 KB
patch
obsolete
>From 84abaccc7080bbfa33c6cbc18ea9d0a3fdb799a6 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Sun, 20 Oct 2013 14:02:52 -0400 >Subject: [PATCH] Bug 11084 - Delete biblios on Leader 05 =d >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Position 05 of the leader in MARC 21 indicates the record's status. >A lower case âdâ indicates that the record is to be deleted >(http://www.loc.gov/marc/authority/adleader.html). > >This patch adds a cronjob script that may be run nightly to delete >records where position 05 of the leader is set to 'd'. > >Test Plan: >1) Edit one or more records, and set the leader position 05 to 'd'. >2) Run misc/cronjobs/deleted_fixed_field_5.pl -c -v >3) Those records should either be deleted, or an error message should > state why the were not. >--- > C4/Items.pm | 5 ++- > misc/cronjobs/delete_fixed_field_5.pl | 84 +++++++++++++++++++++++++++++++++ > 2 files changed, 88 insertions(+), 1 deletions(-) > create mode 100755 misc/cronjobs/delete_fixed_field_5.pl > >diff --git a/C4/Items.pm b/C4/Items.pm >index 8116c22..7291448 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2204,6 +2204,9 @@ Exported function (core API) for deleting an item record in Koha if there no cur > > sub DelItemCheck { > my ( $dbh, $biblionumber, $itemnumber ) = @_; >+ >+ $dbh ||= C4::Context->dbh; >+ > my $error; > > my $countanalytics=GetAnalyticsCount($itemnumber); >@@ -2219,7 +2222,7 @@ sub DelItemCheck { > if ($onloan){ > $error = "book_on_loan" > } >- elsif ( !( C4::Context->userenv->{flags} & 1 ) >+ elsif ( C4::Context->userenv && !( C4::Context->userenv->{flags} & 1 ) > and C4::Context->preference("IndependentBranches") > and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) ) > { >diff --git a/misc/cronjobs/delete_fixed_field_5.pl b/misc/cronjobs/delete_fixed_field_5.pl >new file mode 100755 >index 0000000..479871b >--- /dev/null >+++ b/misc/cronjobs/delete_fixed_field_5.pl >@@ -0,0 +1,84 @@ >+#!/usr/bin/perl >+ >+#----------------------------------- >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+#----------------------------------- >+ >+use Modern::Perl; >+ >+BEGIN { >+ >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/../kohalib.pl" }; >+} >+ >+use Getopt::Long; >+ >+use C4::Biblio; >+use C4::Items; >+use Koha::Database; >+ >+my $delete_items; >+my $confirm; >+my $test; >+my $verbose; >+my $help; >+ >+GetOptions( >+ 'i|di|delete-items' => \$delete_items, >+ 'c|confirm' => \$confirm, >+ 't|test' => \$test, >+ 'v|verbose' => \$verbose, >+ 'h|help' => \$help, >+); >+ >+if ( $help || !$confirm ) { >+ say >+q{delete_fixed_field_5.pl - Attempt to delete any records with the leader character 5 equals 'd'}; >+ say q{usage: delete_fixec_field_5.pl --confirm --verbose}; >+ exit(); >+} >+ >+my $schema = Koha::Database->new()->schema(); >+my @biblioitems = >+ $schema->resultset('Biblioitem')->search( { marc => { LIKE => '_____d%' } } ); >+ >+foreach my $biblioitem (@biblioitems) { >+ my $biblionumber = $biblioitem->get_column('biblionumber'); >+ >+ say "Working on " >+ . $biblioitem->biblionumber->title() >+ . " ( $biblionumber )" >+ if $verbose; >+ >+ if ($delete_items) { >+ say "Attempting to delete items for this record" if $verbose; >+ foreach my $item ( $biblioitem->items() ) { >+ my $error = $test ? "Test mode enabled" : DelItemCheck( undef, $biblionumber, $item->itemnumber() ); >+ $error = undef if ( $error eq '1' ); >+ >+ say "ERROR - Cannot delete item: barcode " . $item->barcode() . ", itemnumber " . $item->itemnumber() . ": $error" if $error; >+ } >+ >+ } >+ >+ my $error = $test ? q{Test mode enabled} : DelBiblio($biblionumber); >+ say "ERROR - Cannot delete biblionumber $biblionumber: $error" if $error; >+} >-- >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 11084
:
22088
|
22089
|
22172
|
22634
|
36837
|
36838
|
36840
|
37714
|
37954
|
38336
|
38337
|
38361
|
38362
|
38363
|
38364
|
46021
|
46022
|
46023
|
46024