Bugzilla – Attachment 139046 Details for
Bug 31109
Add ability to lock bibliographic record or alert staff when another user is in the same bibliographic record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31109: POC
Bug-31109-POC.patch (text/plain), 7.61 KB, created by
Nick Clemens (kidclamp)
on 2022-08-12 12:34:12 UTC
(
hide
)
Description:
Bug 31109: POC
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-08-12 12:34:12 UTC
Size:
7.61 KB
patch
obsolete
>From ed0224a650850cb93dd37f733b34c7aa86615ac8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 12 Aug 2022 12:32:58 +0000 >Subject: [PATCH] Bug 31109: POC > >This patch tries to use the 005 to determine if the record has been altered before saving > >We would need to adjust other areas, and maybe return a diff? > >Just a POC to play with >--- > C4/Biblio.pm | 54 ++++++++++++------- > catalogue/search.pl | 2 +- > cataloguing/addbiblio.pl | 25 ++++++++- > .../prog/en/modules/cataloguing/addbiblio.tt | 14 ++++- > 4 files changed, 72 insertions(+), 23 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index e2df601995..160c663356 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -361,11 +361,6 @@ sub ModBiblio { > return 0; > } > >- if ( C4::Context->preference("CataloguingLog") ) { >- my $biblio = Koha::Biblios->find($biblionumber); >- logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $biblio->metadata->record->as_formatted ); >- } >- > if ( !$options->{disable_autolink} && C4::Context->preference('BiblioAddsAuthorities') ) { > BiblioAutoLink( $record, $frameworkcode ); > } >@@ -417,27 +412,46 @@ sub ModBiblio { > # update MARC subfield that stores biblioitems.cn_sort > _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode ); > >- # update the MARC record (that now contains biblio and items) with the new record data >- ModBiblioMarc( $record, $biblionumber, { skip_record_index => $skip_record_index } ); >+ my $schema = Koha::Database->schema; >+ my $result = 0; >+ $schema->txn_do(sub{ >+ >+ my $biblio = Koha::Biblios->find($biblionumber); >+ my $orig_rec = $biblio->metadata->record; >+ if( $orig_rec->field('005')->as_string eq $record->field('005')->as_string ){ >+ >+ if ( C4::Context->preference("CataloguingLog") ) { >+ logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $orig_rec->as_formatted ); >+ } > >- # modify the other koha tables >- _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); >- _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio ); >+ # update the MARC record (that now contains biblio and items) with the new record data >+ ModBiblioMarc( $record, $biblionumber, { skip_record_index => $skip_record_index } ); > >- _after_biblio_action_hooks({ action => 'modify', biblio_id => $biblionumber }); >+ # modify the other koha tables >+ _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); >+ _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio ); > >- # update OAI-PMH sets >- if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { >- C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record); >- } >+ _after_biblio_action_hooks({ action => 'modify', biblio_id => $biblionumber }); > >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >- { >- biblio_ids => [ $biblionumber ] >+ # update OAI-PMH sets >+ if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { >+ C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record); >+ } >+ >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => [ $biblionumber ] >+ } >+ ) unless $options->{skip_holds_queue} or !C4::Context->preference('RealTimeHoldsQueue'); >+ >+ $result = 1; >+ >+ } else { >+ $result = -1; > } >- ) unless $options->{skip_holds_queue} or !C4::Context->preference('RealTimeHoldsQueue'); >+ }); > >- return 1; >+ return $result; > } > > =head2 _strip_item_fields >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 0bb34b10d6..5ce1ba8d41 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -586,7 +586,7 @@ for (my $i=0;$i<@servers;$i++) { > } > > ## If there's just one result, redirect to the detail page unless doing an index scan >- if ($total == 1 && !$scan) { >+ if ($total == 1 && !$scan && 0) { > my $biblionumber = $newresults[0]->{biblionumber}; > my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); > my $views = { C4::Search::enabled_staff_search_views }; >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 92abe81082..5f7fca7d30 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -868,7 +868,7 @@ if ( $op eq "addbiblio" ) { > my $oldbibitemnum; > if ( $is_a_modif ) { > my $member = Koha::Patrons->find($loggedinuser); >- ModBiblio( >+ my $success = ModBiblio( > $record, > $biblionumber, > $frameworkcode, >@@ -880,6 +880,29 @@ if ( $op eq "addbiblio" ) { > } > } > ); >+ unless( $success > 0 ){ >+ $success ||= 1; >+ build_tabs ($template, $record, $dbh,$encoding,$input); >+ $template->param( >+ biblionumber => $biblionumber, >+ biblioitemnumber => $biblioitemnumber, >+ duplicatebiblionumber => $duplicatebiblionumber, >+ duplicatebibid => $duplicatebiblionumber, >+ duplicatetitle => $duplicatetitle, >+ mod_error => $success >+ ); >+ $template->param( >+ popup => $mode, >+ frameworkcode => $frameworkcode, >+ itemtype => $frameworkcode, >+ borrowernumber => $loggedinuser, >+ tab => scalar $input->param('tab') >+ ); >+ $template->{'VARS'}->{'searchid'} = $searchid; >+ >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+ } > } > else { > ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index cb6a16f905..10816fe2f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -822,7 +822,7 @@ function PopupMARCFieldDoc(field) { > [% END %] > </h1> > >- [% UNLESS ( number ) %] >+ [% UNLESS ( number && !mod_error ) %] > <!-- show duplicate warning on tab 0 only --> > [% IF ( duplicatebiblionumber ) %] > <div class="dialog alert"> >@@ -848,6 +848,18 @@ function PopupMARCFieldDoc(field) { > </form> > </div> <!-- /.dialog.alert --> > [% END # /IF duplicatebiblionumber %] >+ [% IF (mod_error == -1 ) %] >+ <div class="dialog alert"> >+ <h3>Record edited elsewhere</h3> >+ <p>Someone else beat you to it!</p> >+ </div> >+ [% ELSIF (mod_error == 1) %] >+ <div class="dialog alert"> >+ <h3>Error</h3> >+ <p>Something is not right!</p> >+ </div> >+ [% END %] >+ > [% END # /UNLESS number %] > > [% IF ( done ) %] >-- >2.30.2
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 31109
: 139046