From 5bcf79cfe7fbcdb9aea19b18a6527d8e1b1c9b09 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 1 May 2024 23:33:47 +0200 Subject: [PATCH] Bug 36372: provide an interface to set the source of a record from the staff interface Test plan : - apply Cypress patch - running cypress patch in ktd will fail - apply both code patches, cypress tests will pass - open any record in the staff interface - with superlibrarian user, click on the "Edit" button group. - you should be able to click on the "Set record source" below the "Edit record button". - you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources. - change a users permissions to have cataloguing permissions but without the "set_record_source" permissions. - login as this forementionned user and go to any record view. - the "Set record source" button should now be greyed out and not possible to click.# Signed-off-by: Janusz Kaczmarek --- cataloguing/record_source.pl | 68 +++++++++++++++++++ .../prog/en/includes/cat-toolbar.inc | 8 ++- .../en/modules/cataloguing/record_source.tt | 65 ++++++++++++++++++ .../integration/Catalogue/Detail_spec.ts | 6 +- 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100755 cataloguing/record_source.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt diff --git a/cataloguing/record_source.pl b/cataloguing/record_source.pl new file mode 100755 index 00000000000..d9fbd87242c --- /dev/null +++ b/cataloguing/record_source.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# Copyright 2004-2010 BibLibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user haspermission ); +use C4::Biblio qw( ModBiblio ); +use C4::Context; +use Koha::DateUtils qw( dt_from_string ); +use Koha::Biblios; +use Koha::RecordSources; +use Koha::SearchEngine; +use Koha::SearchEngine::Indexer; +use URI::Escape qw( uri_escape_utf8 ); + +# ======================== +# MAIN +#========================= +my $input = CGI->new; +my $biblionumber = $input->param('biblionumber'); +my $record_source_id = $input->param('record_source_id') // ''; +my $save = $input->param('save') // ''; +my $biblio = Koha::Biblios->find($biblionumber); + +if ($save) { + $biblio->metadata->set( { record_source_id => $record_source_id } )->store; + my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); + print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); +} + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "cataloguing/record_source.tt", + query => $input, + type => "intranet", + flagsrequired => { editcatalogue => 'set_record_sources' }, + } +); + +my $record_sources = Koha::RecordSources->search(); + +$template->param( + biblio => $biblio, + record_sources => $record_sources, + current_source => { record_source_id => $biblio->metadata->record_source_id }, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 4b99bbea279..6bd62709f79 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -35,7 +35,7 @@ [% END %] -[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] +[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_editcatalogue_set_record_sources ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]