Bug 41253: Item Modification by Age should have its own permission
Adds a new permission to control access to the Item Modification by Age tool in the Cataloging Module. Previously access to this tool was controlled by the items_batchmod permission. This can be an issue for consortiums where staff members should be able to batch change items that belong to their library, but who shouldn't be able to define item aging rules. Staff with automatic item aging tool access can use authorized values to change items that belong to other libraries. This patch introduces a dedicated permission (items_modification_by_age) to restrict access to the tool to users with this permission. - new permission definition via atomicupdate - removal of dependency on items_batchmod for tool access - updated permission UI display - updated cataloguing-home button visibility - updated flagsrequired check in tool script Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
17cd7f3517
commit
9403a95104
|
|
@ -0,0 +1,51 @@
|
||||||
|
use Modern::Perl;
|
||||||
|
use Koha::Installer::Output qw(say_warning say_success say_info);
|
||||||
|
|
||||||
|
return {
|
||||||
|
bug_number => "41253",
|
||||||
|
description => "Add items_modification_by_age permission",
|
||||||
|
up => sub {
|
||||||
|
my ($args) = @_;
|
||||||
|
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||||
|
|
||||||
|
$dbh->do(
|
||||||
|
q{
|
||||||
|
INSERT IGNORE INTO permissions (module_bit, code, description)
|
||||||
|
VALUES (13, 'items_modification_by_age', 'Define rules for automatic item aging')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
say $out "Added new permission 'items_modification_by_age'";
|
||||||
|
|
||||||
|
my $sth = $dbh->prepare(
|
||||||
|
q{
|
||||||
|
SELECT borrowernumber
|
||||||
|
FROM user_permissions
|
||||||
|
WHERE code = 'items_batchmod'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$sth->execute();
|
||||||
|
|
||||||
|
my @borrowernumbers;
|
||||||
|
while ( my ($borrowernumber) = $sth->fetchrow_array ) {
|
||||||
|
push @borrowernumbers, $borrowernumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@borrowernumbers) {
|
||||||
|
|
||||||
|
my $insert_sth = $dbh->prepare(
|
||||||
|
q{
|
||||||
|
INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
|
||||||
|
VALUES (?, 13, 'items_modification_by_age')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach my $borrowernumber (@borrowernumbers) {
|
||||||
|
$insert_sth->execute($borrowernumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
say_success( $out, "Granted items_modification_by_age to users with items_batchmod" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -126,6 +126,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
|
||||||
(13, 'items_batchmod', 'Perform batch modification of items'),
|
(13, 'items_batchmod', 'Perform batch modification of items'),
|
||||||
(13, 'items_batchmod_restricted', 'Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)'),
|
(13, 'items_batchmod_restricted', 'Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)'),
|
||||||
(13, 'items_batchdel', 'Perform batch deletion of items'),
|
(13, 'items_batchdel', 'Perform batch deletion of items'),
|
||||||
|
(13, 'items_modification_by_age', 'Define rules for automatic item aging'),
|
||||||
(13, 'manage_csv_profiles', 'Manage CSV export profiles'),
|
(13, 'manage_csv_profiles', 'Manage CSV export profiles'),
|
||||||
(13, 'moderate_tags', 'Moderate patron tags'),
|
(13, 'moderate_tags', 'Moderate patron tags'),
|
||||||
(13, 'rotating_collections', 'Manage rotating collections'),
|
(13, 'rotating_collections', 'Manage rotating collections'),
|
||||||
|
|
|
||||||
|
|
@ -436,6 +436,9 @@
|
||||||
Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)
|
Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)
|
||||||
</span>
|
</span>
|
||||||
<span class="permissioncode">([% name | html %])</span>
|
<span class="permissioncode">([% name | html %])</span>
|
||||||
|
[%- CASE 'items_modification_by_age' -%]
|
||||||
|
<span class="sub_permission items_modification_by_age"> Define rules for automatic item aging </span>
|
||||||
|
<span class="permissioncode">([% name | html %])</span>
|
||||||
[%- CASE 'label_creator' -%]
|
[%- CASE 'label_creator' -%]
|
||||||
<span class="sub_permission label_creator_subpermission"> Create printable labels and barcodes from catalog and patron data </span>
|
<span class="sub_permission label_creator_subpermission"> Create printable labels and barcodes from catalog and patron data </span>
|
||||||
<span class="permissioncode">([% name | html %])</span>
|
<span class="permissioncode">([% name | html %])</span>
|
||||||
|
|
|
||||||
|
|
@ -165,10 +165,10 @@
|
||||||
</ul>
|
</ul>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
[% IF ( CAN_user_tools_items_batchmod || ( CAN_user_stockrotation_manage_rotas && Koha.Preference('StockRotation') ) ) %]
|
[% IF ( CAN_user_tools_items_modification_by_age || ( CAN_user_stockrotation_manage_rotas && Koha.Preference('StockRotation') ) ) %]
|
||||||
<h3>Automation</h3>
|
<h3>Automation</h3>
|
||||||
<ul class="buttons-list">
|
<ul class="buttons-list">
|
||||||
[% IF ( CAN_user_tools_items_batchmod ) %]
|
[% IF ( CAN_user_tools_items_modification_by_age ) %]
|
||||||
<li>
|
<li>
|
||||||
<a class="circ-button" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl"><i class="fa-solid fa-calendar-days"></i> Item modifications by age</a>
|
<a class="circ-button" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl"><i class="fa-solid fa-calendar-days"></i> Item modifications by age</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||||
template_name => "tools/automatic_item_modification_by_age.tt",
|
template_name => "tools/automatic_item_modification_by_age.tt",
|
||||||
query => $cgi,
|
query => $cgi,
|
||||||
type => "intranet",
|
type => "intranet",
|
||||||
flagsrequired => { tools => 'items_batchmod' },
|
flagsrequired => { tools => 'items_modification_by_age' },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue