From a2b057758d83c3530c38ced02921c82185f3251f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Mar 2019 12:21:38 -0500 Subject: [PATCH] Bug 20128: Add permission for advanced cataloging editor To test: 1 - Have a borrower with edit_catalogue permission and one with editcatalogue top level 2 - Confirm they can both access the advanced editor from the 'Cataloguing' home page or from the basic editor 3 - Apply patch 4 - Update database 5 - Confirm borrower with 'edit_catalogue' has 'advanced_editor' permission 6 - Confirm borrowers can access advanced editor as above 7 - Remove 'advanced_editor' permission from borrower 8 - Ensure they cannot access the advanced editor 9 - Ensure links to 'Edit record' from search results go to basic editor Signed-off-by: Liz Rea Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- cataloguing/addbiblio.pl | 2 +- cataloguing/editor.pl | 7 ++++++- ...20128_add_permission_for_advanced_editor.perl | 16 ++++++++++++++++ .../prog/en/includes/permissions.inc | 5 +++++ .../prog/en/modules/cataloguing/addbiblio.tt | 2 +- .../prog/en/modules/cataloguing/addbooks.tt | 2 +- 6 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug20128_add_permission_for_advanced_editor.perl diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 67dde9800e..8c60a11a3b 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -737,7 +737,7 @@ if ($frameworkcode eq 'FA'){ 'stickyduedate' => $fa_stickyduedate, 'duedatespec' => $fa_duedatespec, ); -} elsif ( $op ne "delete" && C4::Context->preference('EnableAdvancedCatalogingEditor') && $input->cookie( 'catalogue_editor_' . $loggedinuser ) eq 'advanced' && !$breedingid ) { +} elsif ( $op ne "delete" && C4::Context->preference('EnableAdvancedCatalogingEditor') && C4::Auth::haspermission($loggedinuser,{'editcatalogue'=>'advanced_editor'}) && $input->cookie( 'catalogue_editor_' . $loggedinuser ) eq 'advanced' && !$breedingid ) { # Only use the advanced editor for non-fast-cataloging. # breedingid is not handled because those would only come off a Z39.50 # search initiated by the basic editor. diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl index 42f35b3f47..a0e6c83c5c 100755 --- a/cataloguing/editor.pl +++ b/cataloguing/editor.pl @@ -40,7 +40,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( query => $input, type => 'intranet', authnotrequired => 0, - flagsrequired => { editcatalogue => 'edit_catalogue' }, + flagsrequired => { + editcatalogue => { + 'edit_catalogue' => 1, + 'advanced_editor' => 1 + }, + } } ); diff --git a/installer/data/mysql/atomicupdate/bug20128_add_permission_for_advanced_editor.perl b/installer/data/mysql/atomicupdate/bug20128_add_permission_for_advanced_editor.perl new file mode 100644 index 0000000000..c383eecb52 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug20128_add_permission_for_advanced_editor.perl @@ -0,0 +1,16 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE permissions (module_bit, code, description) + VALUES + (9,'advanced_editor','Use the advanced cataloging editor') + }); + if( C4::Context->preference('EnableAdvancedCatalogingEditor') ){ + $dbh->do(q{ + INSERT INTO user_permissions (borrowernumber, module_bit, code) + SELECT borrowernumber, 9, 'advanced_editor' FROM borrowers WHERE borrowernumber IN (SELECT DISTINCT borrowernumber FROM user_permissions WHERE code = 'edit_catalogue'); + }); + } + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 20128: Add permission for Advanced Cataloging Editor)\n"; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 1763079fe9..0e40101085 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -271,6 +271,11 @@ Edit catalog (Modify bibliographic/holdings data) ([% name | html %]) + [%- CASE 'advanced_editor' -%] + + Use the advanced cataloging editor (requires edit_catalogue) + + ([% name | html %]) [%- CASE 'edit_items' -%] Edit items 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 6b1a95ba01..2aa091ed5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -511,7 +511,7 @@ function Changefwk() {