From 2e08f626f58401c6733886ebaf963eb695e32862 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 6 Apr 2009 09:45:56 -0500 Subject: [PATCH] remove incomplete bib bulk editing code Per discussion I had with Henri, removing experimental bulk editing from the staff search results code, as feature is incomplete and can be dangerous if one tries to use it on a large search result set. Signed-off-by: Galen Charlton --- C4/Koha.pm | 44 ------ C4/Search.pm | 125 ------------------ catalogue/search.pl | 31 ----- .../prog/en/modules/catalogue/results.tmpl | 31 ----- t/lib/KohaTest/Koha.pm | 1 - t/lib/KohaTest/Search.pm | 1 - 6 files changed, 233 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 9c370202cb..418b8156ca 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -52,7 +52,6 @@ BEGIN { &GetAuthorisedValueCategories &GetKohaAuthorisedValues &GetAuthValCode - &GetManagedTagSubfields &GetNormalizedUPC &GetNormalizedISBN &GetNormalizedEAN @@ -1069,49 +1068,6 @@ sub GetKohaAuthorisedValues { } } -=head2 GetManagedTagSubfields - -=over 4 - -$res = GetManagedTagSubfields(); - -=back - -Returns a reference to a big hash of hash, with the Marc structure fro the given frameworkcode - -NOTE: This function is used only by the (incomplete) bulk editing feature. Since -that feature currently does not deal with items and biblioitems changes -correctly, those tags are specifically excluded from the list prepared -by this function. - -For future reference, if a bulk item editing feature is implemented at some point, it -needs some design thought -- for example, circulation status fields should not -be changed willy-nilly. - -=cut - -sub GetManagedTagSubfields{ - my $dbh=C4::Context->dbh; - my $rq=$dbh->prepare(qq| -SELECT - DISTINCT CONCAT( marc_subfield_structure.tagfield, tagsubfield ) AS tagsubfield, - marc_subfield_structure.liblibrarian as subfielddesc, - marc_tag_structure.liblibrarian as tagdesc -FROM marc_subfield_structure - LEFT JOIN marc_tag_structure - ON marc_tag_structure.tagfield = marc_subfield_structure.tagfield - AND marc_tag_structure.frameworkcode = marc_subfield_structure.frameworkcode -WHERE marc_subfield_structure.tab>=0 -AND marc_tag_structure.tagfield NOT IN (SELECT tagfield FROM marc_subfield_structure WHERE kohafield like 'items.%') -AND marc_tag_structure.tagfield NOT IN (SELECT tagfield FROM marc_subfield_structure WHERE kohafield = 'biblioitems.itemtype') -AND marc_subfield_structure.kohafield <> 'biblio.biblionumber' -AND marc_subfield_structure.kohafield <> 'biblioitems.biblioitemnumber' -ORDER BY marc_subfield_structure.tagfield, tagsubfield|); - $rq->execute; - my $data=$rq->fetchall_arrayref({}); - return $data; -} - =head2 display_marc_indicators =over 4 diff --git a/C4/Search.pm b/C4/Search.pm index 571edf734c..59d0a08b64 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -61,7 +61,6 @@ This module provides searching functions for Koha's bibliographic databases &getRecords &buildQuery &NZgetRecords - &ModBiblios ); # make all your functions, whether exported or not; @@ -2139,130 +2138,6 @@ sub NZorder { } } -=head2 ModBiblios - -($countchanged,$listunchanged) = ModBiblios($listbiblios, $tagsubfield,$initvalue,$targetvalue,$test); - -this function changes all the values $initvalue in subfield $tag$subfield in any record in $listbiblios -test parameter if set donot perform change to records in database. - -=over 2 - -=item C - - * $listbiblios is an array ref to marcrecords to be changed - * $tagsubfield is the reference of the subfield to change. - * $initvalue is the value to search the record for - * $targetvalue is the value to set the subfield to - * $test is to be set only not to perform changes in database. - -=item C - * $countchanged counts all the changes performed. - * $listunchanged contains the list of all the biblionumbers of records unchanged. - -=item C - -=back - -my ($countchanged, $listunchanged) = EditBiblios($results->{RECORD}, $tagsubfield,$initvalue,$targetvalue);; -#If one wants to display unchanged records, you should get biblios foreach @$listunchanged -$template->param(countchanged => $countchanged, loopunchanged=>$listunchanged); - -=cut - -sub ModBiblios { - my ( $listbiblios, $tagsubfield, $initvalue, $targetvalue, $test ) = @_; - my $countmatched; - my @unmatched; - my ( $tag, $subfield ) = ( $1, $2 ) - if ( $tagsubfield =~ /^(\d{1,3})([a-z0-9A-Z@])?$/ ); - if ( ( length($tag) < 3 ) && $subfield =~ /0-9/ ) { - $tag = $tag . $subfield; - undef $subfield; - } - my ( $bntag, $bnsubf ) = GetMarcFromKohaField('biblio.biblionumber', ''); - my ( $itemtag, $itemsubf ) = GetMarcFromKohaField('items.itemnumber', ''); - if ($tag eq $itemtag) { - # do not allow the embedded item tag to be - # edited from here - warn "Attempting to edit item tag via C4::Search::ModBiblios -- not allowed"; - return (0, []); - } - foreach my $usmarc (@$listbiblios) { - my $record; - $record = eval { MARC::Record->new_from_usmarc($usmarc) }; - my $biblionumber; - if ($@) { - - # usmarc is not a valid usmarc May be a biblionumber - # FIXME - sorry, please let's figure out whether - # this function is to be passed a list of - # record numbers or a list of MARC::Record - # objects. The former is probably better - # because the MARC records supplied by Zebra - # may be not current. - $record = GetMarcBiblio($usmarc); - $biblionumber = $usmarc; - } - else { - if ( $bntag >= 010 ) { - $biblionumber = $record->subfield( $bntag, $bnsubf ); - } - else { - $biblionumber = $record->field($bntag)->data; - } - } - - #GetBiblionumber is to be written. - #Could be replaced by TransformMarcToKoha (But Would be longer) - if ( $record->field($tag) ) { - my $modify = 0; - foreach my $field ( $record->field($tag) ) { - if ($subfield) { - if ( - $field->delete_subfield( - 'code' => $subfield, - 'match' => qr($initvalue) - ) - ) - { - $countmatched++; - $modify = 1; - $field->update( $subfield, $targetvalue ) - if ($targetvalue); - } - } - else { - if ( $tag >= 010 ) { - if ( $field->delete_field($field) ) { - $countmatched++; - $modify = 1; - } - } - else { - $field->data = $targetvalue - if ( $field->data =~ qr($initvalue) ); - } - } - } - - # warn $record->as_formatted; - if ($modify) { - ModBiblio( $record, $biblionumber, - GetFrameworkCode($biblionumber) ) - unless ($test); - } - else { - push @unmatched, $biblionumber; - } - } - else { - push @unmatched, $biblionumber; - } - } - return ( $countmatched, \@unmatched ); -} - END { } # module clean-up code here (global destructor) 1; diff --git a/catalogue/search.pl b/catalogue/search.pl index 902318a91d..a5beb6d0b4 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -481,37 +481,6 @@ if ($@ || $error) { exit; } -# FIXME: This belongs in tools/ not in the primary search results page -my $op=$cgi->param("operation"); -if ($op eq "bulkedit"){ - my ($countchanged,$listunchanged)= - ModBiblios($results_hashref->{'biblioserver'}->{"RECORDS"}, - $params->{"tagsubfield"}, - $params->{"inputvalue"}, - $params->{"targetvalue"}, - $params->{"test"} - ); - $template->param(bulkeditresults=>1, - tagsubfield=>$params->{"tagsubfield"}, - inputvalue=>$params->{"inputvalue"}, - targetvalue=>$params->{"targetvalue"}, - countchanged=>$countchanged, - countunchanged=>scalar(@$listunchanged), - listunchanged=>$listunchanged); - - if (C4::Context->userenv->{'flags'}==1 ||(C4::Context->userenv->{'flags'} & ( 2**9 ) )){ - #Edit Catalogue Permissions - my $editable_subfields = GetManagedTagSubfields(); - # change '--' to '—' to avoid escaping issues - for (my $i = 0; $i <= $#{$editable_subfields}; $i++) { - $editable_subfields->[$i]->{subfielddesc} =~ s/--/—/g; - $editable_subfields->[$i]->{tagdesc} =~ s/--/—/g; - } - $template->param(bulkedit => 1); - $template->param(tagsubfields=>$editable_subfields); - } -} - # At this point, each server has given us a result set # now we build that set for template display my @sup_results_array; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl index 5acb1059de..abaf52e775 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl @@ -194,37 +194,6 @@ $(window).load(function() { - - -
- Bulk edit -
- - -
- tagsubfield : Change To
- biblios changed
- biblios unchanged
-
- - - diff --git a/t/lib/KohaTest/Koha.pm b/t/lib/KohaTest/Koha.pm index c1773d955d..b1774a2c62 100644 --- a/t/lib/KohaTest/Koha.pm +++ b/t/lib/KohaTest/Koha.pm @@ -41,7 +41,6 @@ sub methods : Test( 1 ) { GetAuthorisedValues GetAuthorisedValueCategories GetKohaAuthorisedValues - GetManagedTagSubfields display_marc_indicators ); diff --git a/t/lib/KohaTest/Search.pm b/t/lib/KohaTest/Search.pm index 44d7885907..ef27acd4dc 100644 --- a/t/lib/KohaTest/Search.pm +++ b/t/lib/KohaTest/Search.pm @@ -29,7 +29,6 @@ sub methods : Test( 1 ) { NZoperatorOR NZoperatorNOT NZorder - ModBiblios ); can_ok( $self->testing_class, @methods ); -- 2.39.5