View | Details | Raw Unified | Return to bug 18071
Collapse All | Expand All

(-)a/misc/maintenance/update_authorities.pl (-1 / +78 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright Rijksmuseum 2017
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Getopt::Long;
23
use List::MoreUtils qw/uniq/;
24
use Pod::Usage;
25
26
use C4::AuthoritiesMarc qw/DelAuthority merge/;
27
28
my ( @authid, $delete, $help, $verbose );
29
GetOptions(
30
    'authid:s' => \@authid,
31
    'delete'   => \$delete,
32
    'help'     => \$help,
33
    'verbose'  => \$verbose,
34
    # TODO Add more options under BZ 18071
35
);
36
37
if( $delete ) {
38
    @authid = map { split /[,]/, $_; } @authid;
39
    foreach my $authid ( uniq(@authid) ) {
40
        DelAuthority( $authid ); # triggers a merge (read: cleanup)
41
        print "Removing $authid\n" if $verbose;
42
    }
43
} elsif( $help ) {
44
    pod2usage(1);
45
} else {
46
    pod2usage(1);
47
}
48
49
=head1 NAME
50
51
update_authorities.pl
52
53
=head1 DESCRIPTION
54
55
Script to perform various authority related maintenance tasks.
56
This version supports deleting an authority record and updating all linked
57
biblio records.
58
On BZ report 18071 we will add functions like: updating 001, triggering merge.
59
60
=head1 SYNOPSIS
61
62
update_authorities.pl -authid 1,2,3 -delete
63
64
update_authorities.pl -authid 1 -authid 2 -authid 3 -delete
65
66
=head1 OPTIONS
67
68
authid: List authority numbers separated by commas or repeat the
69
parameter.
70
71
delete: Delete the listed authority numbers and remove its references from
72
linked biblio records.
73
74
=head1 AUTHOR
75
76
Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands
77
78
=cut

Return to bug 18071