|
Lines 25-34
use Pod::Usage;
Link Here
|
| 25 |
|
25 |
|
| 26 |
use C4::AuthoritiesMarc qw/AddAuthority DelAuthority GetAuthority merge/; |
26 |
use C4::AuthoritiesMarc qw/AddAuthority DelAuthority GetAuthority merge/; |
| 27 |
|
27 |
|
| 28 |
my ( @authid, $commit, $delete, $help, $merge, $reference, $renumber, $verbose ); |
28 |
my ( @authid, $confirm, $delete, $help, $merge, $reference, $renumber, $verbose ); |
| 29 |
GetOptions( |
29 |
GetOptions( |
| 30 |
'authid:s' => \@authid, |
30 |
'authid:s' => \@authid, |
| 31 |
'commit' => \$commit, |
31 |
'confirm' => \$confirm, |
| 32 |
'delete' => \$delete, |
32 |
'delete' => \$delete, |
| 33 |
'help' => \$help, |
33 |
'help' => \$help, |
| 34 |
'merge' => \$merge, |
34 |
'merge' => \$merge, |
|
Lines 38-44
GetOptions(
Link Here
|
| 38 |
); |
38 |
); |
| 39 |
|
39 |
|
| 40 |
@authid = map { split /[,]/, $_; } @authid; |
40 |
@authid = map { split /[,]/, $_; } @authid; |
| 41 |
print "No changes will be made\n" unless $commit; |
41 |
print "No changes will be made\n" unless $confirm; |
| 42 |
pod2usage(1) if $help; |
42 |
pod2usage(1) if $help; |
| 43 |
|
43 |
|
| 44 |
if ( $delete and $merge and $renumber ) { |
44 |
if ( $delete and $merge and $renumber ) { |
|
Lines 59-65
if( $delete ) {
Link Here
|
| 59 |
sub delete_auth { |
59 |
sub delete_auth { |
| 60 |
my ( $auths ) = @_; |
60 |
my ( $auths ) = @_; |
| 61 |
foreach my $authid ( uniq(@$auths) ) { |
61 |
foreach my $authid ( uniq(@$auths) ) { |
| 62 |
if( $commit ) { |
62 |
if( $confirm ) { |
| 63 |
DelAuthority({ authid => $authid }); # triggers a merge (read: cleanup) |
63 |
DelAuthority({ authid => $authid }); # triggers a merge (read: cleanup) |
| 64 |
print "Removing $authid\n" if $verbose; |
64 |
print "Removing $authid\n" if $verbose; |
| 65 |
} else { |
65 |
} else { |
|
Lines 75-81
sub merge_auth {
Link Here
|
| 75 |
|
75 |
|
| 76 |
my $marc_ref = GetAuthority( $reference ) || die "Reference record $reference not found\n"; |
76 |
my $marc_ref = GetAuthority( $reference ) || die "Reference record $reference not found\n"; |
| 77 |
# First update all linked biblios of reference |
77 |
# First update all linked biblios of reference |
| 78 |
merge({ mergefrom => $reference, MARCfrom => $marc_ref, mergeto => $reference, MARCto => $marc_ref, override_limit => 1 }) if $commit; |
78 |
merge({ mergefrom => $reference, MARCfrom => $marc_ref, mergeto => $reference, MARCto => $marc_ref, override_limit => 1 }) if $confirm; |
| 79 |
|
79 |
|
| 80 |
# Merge all authid's into reference |
80 |
# Merge all authid's into reference |
| 81 |
my $marc; |
81 |
my $marc; |
|
Lines 86-92
sub merge_auth {
Link Here
|
| 86 |
print "Authority id $authid ignored, does not exist.\n"; |
86 |
print "Authority id $authid ignored, does not exist.\n"; |
| 87 |
next; |
87 |
next; |
| 88 |
} |
88 |
} |
| 89 |
if( $commit ) { |
89 |
if( $confirm ) { |
| 90 |
merge({ |
90 |
merge({ |
| 91 |
mergefrom => $authid, |
91 |
mergefrom => $authid, |
| 92 |
MARCfrom => $marc, |
92 |
MARCfrom => $marc, |
|
Lines 107-113
sub renumber {
Link Here
|
| 107 |
foreach my $authid ( uniq(@$auths) ) { |
107 |
foreach my $authid ( uniq(@$auths) ) { |
| 108 |
if( my $authority = Koha::Authorities->find($authid) ) { |
108 |
if( my $authority = Koha::Authorities->find($authid) ) { |
| 109 |
my $marc = GetAuthority( $authid ); |
109 |
my $marc = GetAuthority( $authid ); |
| 110 |
if( $commit ) { |
110 |
if( $confirm ) { |
| 111 |
AddAuthority( $marc, $authid, $authority->authtypecode ); |
111 |
AddAuthority( $marc, $authid, $authority->authtypecode ); |
| 112 |
# AddAuthority contains an update of 001, 005 etc. |
112 |
# AddAuthority contains an update of 001, 005 etc. |
| 113 |
print "Renumbered $authid\n" if $verbose; |
113 |
print "Renumbered $authid\n" if $verbose; |
|
Lines 150-156
update_authorities.pl -c -authid 1,2,3 -renumber
Link Here
|
| 150 |
authid: List authority numbers separated by commas or repeat the |
150 |
authid: List authority numbers separated by commas or repeat the |
| 151 |
parameter. |
151 |
parameter. |
| 152 |
|
152 |
|
| 153 |
commit: Needed to commit changes. |
153 |
confirm: Needed to commit changes. |
| 154 |
|
154 |
|
| 155 |
delete: Delete the listed authority numbers and remove its references from |
155 |
delete: Delete the listed authority numbers and remove its references from |
| 156 |
linked biblio records. |
156 |
linked biblio records. |
| 157 |
- |
|
|