From 4f97ef56671264c7f466ce808e063839b2e304d1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 29 Feb 2024 18:08:41 +0000 Subject: [PATCH] Bug 36206: Add 'admin' plugins option This patch adds an admin plugins class to the plugins system and displays such plugins under the 'Plugins' section in the Administration page. Signed-off-by: Lucas Gass --- admin/admin-home.pl | 7 +++++++ .../data/mysql/atomicupdate/bug_36206.pl | 20 +++++++++++++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/permissions.inc | 5 +++++ .../prog/en/modules/admin/admin-home.tt | 6 ++++++ 5 files changed, 39 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_36206.pl diff --git a/admin/admin-home.pl b/admin/admin-home.pl index 6595841e70..95338b0bf5 100755 --- a/admin/admin-home.pl +++ b/admin/admin-home.pl @@ -35,6 +35,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +if ( C4::Context->config('enable_plugins') ) { + my @admin_plugins = Koha::Plugins->new()->GetPlugins({ + method => 'admin', + }); + $template->param( admin_plugins => \@admin_plugins ); +} + $template->param( mana_url => $mana_url, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_36206.pl b/installer/data/mysql/atomicupdate/bug_36206.pl new file mode 100644 index 0000000000..c371d51ac2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_36206.pl @@ -0,0 +1,20 @@ +use Modern::Perl; + +return { + bug_number => "32602", + description => "Add administrative plugins type", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my $permission_added = $dbh->do( + q{ + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 19, 'admin', 'Use administrative plugins'); + } + ); + + if ( $permission_added == 1 ) { + say $out "Added new permission 'edit_any_item'"; + } + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 729c075548..394024a992 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -138,6 +138,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (19, 'manage', 'Manage plugins ( install / uninstall )'), (19, 'tool', 'Use tool plugins'), (19, 'report', 'Use report plugins'), + (19, 'admin', 'Use administrative plugins'), (19, 'configure', 'Configure plugins'), (20, 'delete_public_lists', 'Delete public lists'), (20, 'edit_public_lists', 'Edit public lists'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 742e6e1c35..205f6afcfe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -737,6 +737,11 @@ Use tool plugins ([% name | html %]) + [%- CASE 'admin' -%] + + Use adminitstrative plugins + + ([% name | html %]) [%- CASE 'delete_public_lists' -%] Delete public lists diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt index 1320214b65..4c215d27fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt @@ -153,6 +153,12 @@
Manage plugins
View, manage, configure and run plugins.
+ [% IF ( CAN_user_plugins_admin && admin_plugins ) %] + [% FOREACH plugin IN admin_plugins %] +
[% plugin.metadata.name | html %]
+
[% plugin.metadata.description | html %]
+ [% END %] + [% END %]
[% END %] -- 2.30.2