|
Lines 734-763
sub DelAuthority {
Link Here
|
| 734 |
$sth->execute($authid); |
734 |
$sth->execute($authid); |
| 735 |
} |
735 |
} |
| 736 |
|
736 |
|
|
|
737 |
=head2 ModAuthority |
| 738 |
|
| 739 |
$authid= &ModAuthority($authid,$record,$authtypecode) |
| 740 |
|
| 741 |
Modifies authority record, optionally updates attached biblios. |
| 742 |
|
| 743 |
=cut |
| 744 |
|
| 737 |
sub ModAuthority { |
745 |
sub ModAuthority { |
| 738 |
my ($authid,$record,$authtypecode,$merge)=@_; |
746 |
my ($authid,$record,$authtypecode)=@_; # deprecated $merge parameter removed |
|
|
747 |
|
| 739 |
my $dbh=C4::Context->dbh; |
748 |
my $dbh=C4::Context->dbh; |
| 740 |
#Now rewrite the $record to table with an add |
749 |
#Now rewrite the $record to table with an add |
| 741 |
my $oldrecord=GetAuthority($authid); |
750 |
my $oldrecord=GetAuthority($authid); |
| 742 |
$authid=AddAuthority($record,$authid,$authtypecode); |
751 |
$authid=AddAuthority($record,$authid,$authtypecode); |
| 743 |
|
752 |
|
| 744 |
### If a library thinks that updating all biblios is a long process and wishes to leave that to a cron job to use merge_authotities.p |
753 |
# If a library thinks that updating all biblios is a long process and wishes |
| 745 |
### they should have a system preference "dontmerge=1" otherwise by default biblios will be updated |
754 |
# to leave that to a cron job, use misc/migration_tools/merge_authority.pl. |
| 746 |
### the $merge flag is now depreceated and will be removed at code cleaning |
755 |
# In that case set system preference "dontmerge" to 1. Otherwise biblios will |
| 747 |
if (C4::Context->preference('MergeAuthoritiesOnUpdate') ){ |
756 |
# be updated. |
|
|
757 |
unless(C4::Context->preference('dontmerge') eq '1'){ |
| 748 |
&merge($authid,$oldrecord,$authid,$record); |
758 |
&merge($authid,$oldrecord,$authid,$record); |
| 749 |
} else { |
759 |
} else { |
| 750 |
# save the file in tmp/modified_authorities |
760 |
# save a record in need_merge_authorities table |
| 751 |
my $cgidir = C4::Context->intranetdir ."/cgi-bin"; |
761 |
my $sqlinsert="INSERT INTO need_merge_authorities (authid, done) ". |
| 752 |
unless (opendir(DIR,"$cgidir")) { |
762 |
"VALUES (?,?)"; |
| 753 |
$cgidir = C4::Context->intranetdir."/"; |
763 |
$dbh->do($sqlinsert,undef,($authid,0)); |
| 754 |
closedir(DIR); |
|
|
| 755 |
} |
| 756 |
|
| 757 |
my $filename = $cgidir."/tmp/modified_authorities/$authid.authid"; |
| 758 |
open AUTH, "> $filename"; |
| 759 |
print AUTH $authid; |
| 760 |
close AUTH; |
| 761 |
} |
764 |
} |
| 762 |
logaction( "AUTHORITIES", "MODIFY", $authid, "BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
765 |
logaction( "AUTHORITIES", "MODIFY", $authid, "BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
| 763 |
return $authid; |
766 |
return $authid; |
|
Lines 1323-1329
sub merge {
Link Here
|
| 1323 |
push @reccache, $marcdata; |
1326 |
push @reccache, $marcdata; |
| 1324 |
$z++; |
1327 |
$z++; |
| 1325 |
} |
1328 |
} |
| 1326 |
$oConnection->destroy(); |
1329 |
#$oConnection->destroy(); #see Bugzilla 6094 Uncommenting this line makes that the second subsequent call of merge crashes on the Zconn call line little before this line |
| 1327 |
} |
1330 |
} |
| 1328 |
#warn scalar(@reccache)." biblios to update"; |
1331 |
#warn scalar(@reccache)." biblios to update"; |
| 1329 |
# Get All candidate Tags for the change |
1332 |
# Get All candidate Tags for the change |