Bug 36206 - Administrative plugins
Summary: Administrative plugins
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL: https://github.com/PTFS-Europe/koha-p...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-29 17:23 UTC by Martin Renvoize (ashimema)
Modified: 2024-07-24 21:00 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/936
Text to go in the release notes:
This adds a new type of administrative plugin that supplements the existing tool and report plugins. When installed, an entry for this plugin will be shown on the administration module start page.
Version(s) released in:
24.05.00
Circulation function:


Attachments
Bug 36206: Add 'admin' plugins option (4.59 KB, patch)
2024-02-29 19:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: Expose administration page to users with plugins_admin permission (2.99 KB, patch)
2024-03-01 08:04 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: Add 'Run administration tool' to plugin actions (2.59 KB, patch)
2024-03-01 08:09 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: Add 'Run administration tool' to plugin actions (2.59 KB, patch)
2024-03-01 08:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: (follow-up) Change file permission (552 bytes, patch)
2024-03-05 17:01 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36206: Add 'admin' plugins option (4.60 KB, patch)
2024-03-05 17:02 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36206: Expose administration page to users with plugins_admin permission (3.01 KB, patch)
2024-03-05 17:02 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36206: Add 'Run administration tool' to plugin actions (2.64 KB, patch)
2024-03-05 17:02 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36206: (follow-up) Change file permission (607 bytes, patch)
2024-03-05 17:02 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 36206: Add 'admin' plugins option (4.66 KB, patch)
2024-03-15 18:20 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 36206: Expose administration page to users with plugins_admin permission (3.06 KB, patch)
2024-03-15 18:20 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 36206: Add 'Run administration tool' to plugin actions (2.70 KB, patch)
2024-03-15 18:20 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 36206: (follow-up) Change file permission (663 bytes, patch)
2024-03-15 18:20 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 36206: (QA follow-up) Tidy admin-home.pl (1.60 KB, patch)
2024-03-15 18:20 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 36206: (follow-up) Fix Typos (1.52 KB, patch)
2024-04-25 12:14 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: (follow-up) More conditions on display (1.03 KB, patch)
2024-04-25 12:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 36206: (follow-up) Fix Permissions.t (1.08 KB, patch)
2024-04-26 20:18 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2024-02-29 17:23:01 UTC
It would be beneficial to have an 'administrative' plugin type akin to 'tools' and 'reports' plugins. This would allow for adding an administrative plugin to the administration pages as opposed to having to expose it under tools.
Comment 1 Martin Renvoize (ashimema) 2024-02-29 19:00:43 UTC
Created attachment 162615 [details] [review]
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.
Comment 2 Martin Renvoize (ashimema) 2024-02-29 19:02:10 UTC
There's a new branch on the crontab plugin to use to test this against.. I'll enlist those trialing it for me to test ;P
Comment 3 Martin Renvoize (ashimema) 2024-03-01 08:04:38 UTC
Created attachment 162639 [details] [review]
Bug 36206: Expose administration page to users with plugins_admin permission

This patch updates the intranet home page logic such that the
administration button appears for those users with just the 'admin'
subpermission of plugins to allow them to access such plugins.

We also update the display logic found inside the admin-home page so
that user see plugin management appropriately.
Comment 4 Martin Renvoize (ashimema) 2024-03-01 08:09:13 UTC
Created attachment 162640 [details] [review]
Bug 36206: Add 'Run administration tool' to plugin actions

This patch adds the new 'Run administration tool' option to the plugin
actions dropdown menu for plugins with such a function.
Comment 5 Martin Renvoize (ashimema) 2024-03-01 08:10:24 UTC
Created attachment 162641 [details] [review]
Bug 36206: Add 'Run administration tool' to plugin actions

This patch adds the new 'Run administration tool' option to the plugin
actions dropdown menu for plugins with such a function.
Comment 6 Martin Renvoize (ashimema) 2024-03-01 10:27:54 UTC
Currently this is easiest to test using the in-development crontab manager plugin, admin_plugin branch: https://github.com/PTFS-Europe/koha-plugin-crontab/tree/admin_plugin
Comment 7 David Cook 2024-03-04 06:11:07 UTC
(In reply to Martin Renvoize from comment #6)
> Currently this is easiest to test using the in-development crontab manager
> plugin, admin_plugin branch:
> https://github.com/PTFS-Europe/koha-plugin-crontab/tree/admin_plugin

Can't locate Config/Crontab.pm in @INC (you may need to install the Config::Cron
tab module)

sudo apt-get install libconfig-crontab-perl

sudo sh install_plugins.sh

No crontab found, installing default at /var/lib/koha/kohadev/koha-plugin-crontab/Koha/Plugin/Com/PTFSEurope/Crontab.pm line 140.
Writing crontab: # This crontab file is managed by the Koha Crontab manager plugin

# BLOCKID: 0
PERL5LIB=/usr/share/koha/lib
KOHA_CRON_PATH=/usr/share/koha/bin/cronjobs
KOHA_CONF=/etc/koha/sites/kohadev/koha-conf.xml
Installed Crontab version {VERSION}
All plugins successfully re-initialised
Comment 8 David Cook 2024-03-04 06:16:13 UTC
Sorry, mate, but I couldn't get this to work. 

Might be that I wasn't testing it correctly. Can you add a rock-solid test plan for it?
Comment 9 Martin Renvoize (ashimema) 2024-03-04 08:15:37 UTC
(In reply to David Cook from comment #7)
> (In reply to Martin Renvoize from comment #6)
> > Currently this is easiest to test using the in-development crontab manager
> > plugin, admin_plugin branch:
> > https://github.com/PTFS-Europe/koha-plugin-crontab/tree/admin_plugin
> 
> Can't locate Config/Crontab.pm in @INC (you may need to install the
> Config::Cron
> tab module)
> 
> sudo apt-get install libconfig-crontab-perl
> 
> sudo sh install_plugins.sh
> 
> No crontab found, installing default at
> /var/lib/koha/kohadev/koha-plugin-crontab/Koha/Plugin/Com/PTFSEurope/Crontab.
> pm line 140.
> Writing crontab: # This crontab file is managed by the Koha Crontab manager
> plugin
> 
> # BLOCKID: 0
> PERL5LIB=/usr/share/koha/lib
> KOHA_CRON_PATH=/usr/share/koha/bin/cronjobs
> KOHA_CONF=/etc/koha/sites/kohadev/koha-conf.xml
> Installed Crontab version {VERSION}
> All plugins successfully re-initialised

Yeah, I also have a work-in-progress branch that attempts to use Module::Load::Conditional to output a nicer warning in the UI when the library is missing... that or I'm considering bundling Config::Crontab into the plugin itself.. so far I've not come up with a nice solution for plugins that have cpan dependencies.. any idea's on a nice way to handle such cases would be awesome.

Anyway, it looks like you managed to get there on the install and the default template was installed (it'll check for local crontab and load that, or it'll load a very basic template if one isn't found.. local crontab = whatever you may have added to a crontab using koha-shell for example.
Comment 10 Martin Renvoize (ashimema) 2024-03-05 16:38:00 UTC
Grr... attaching a plugin here is too large for Bugzilla!
Comment 11 Martin Renvoize (ashimema) 2024-03-05 16:42:25 UTC
Please use : https://github.com/PTFS-Europe/dev-koha-plugin-kitchen-sink/blob/admin/build/koha-plugin-kitchen-sink.kpz to test.

The plugin can be installed as usual with this patchset applied to Koha.

Once installed, it will appear on the administration page under 'Plugins' with the plugin name as the definition list title and the plugin description as the definition list definition.

You should also be able to access the example admin page via the 'Manage plugins' page, from the 'actions' menu at the right side of the plugins table.
Comment 12 Lucas Gass (lukeg) 2024-03-05 17:01:49 UTC
Created attachment 162779 [details] [review]
Bug 36206: (follow-up) Change file permission
Comment 13 Lucas Gass (lukeg) 2024-03-05 17:02:35 UTC
Created attachment 162780 [details] [review]
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 <lucas@bywatersolutions.com>
Comment 14 Lucas Gass (lukeg) 2024-03-05 17:02:38 UTC
Created attachment 162781 [details] [review]
Bug 36206: Expose administration page to users with plugins_admin permission

This patch updates the intranet home page logic such that the
administration button appears for those users with just the 'admin'
subpermission of plugins to allow them to access such plugins.

We also update the display logic found inside the admin-home page so
that user see plugin management appropriately.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 15 Lucas Gass (lukeg) 2024-03-05 17:02:40 UTC
Created attachment 162782 [details] [review]
Bug 36206: Add 'Run administration tool' to plugin actions

This patch adds the new 'Run administration tool' option to the plugin
actions dropdown menu for plugins with such a function.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 16 Lucas Gass (lukeg) 2024-03-05 17:02:42 UTC
Created attachment 162783 [details] [review]
Bug 36206: (follow-up) Change file permission

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 17 Kyle M Hall (khall) 2024-03-15 18:20:00 UTC
Created attachment 163270 [details] [review]
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 <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 18 Kyle M Hall (khall) 2024-03-15 18:20:07 UTC
Created attachment 163271 [details] [review]
Bug 36206: Expose administration page to users with plugins_admin permission

This patch updates the intranet home page logic such that the
administration button appears for those users with just the 'admin'
subpermission of plugins to allow them to access such plugins.

We also update the display logic found inside the admin-home page so
that user see plugin management appropriately.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 19 Kyle M Hall (khall) 2024-03-15 18:20:09 UTC
Created attachment 163272 [details] [review]
Bug 36206: Add 'Run administration tool' to plugin actions

This patch adds the new 'Run administration tool' option to the plugin
actions dropdown menu for plugins with such a function.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 20 Kyle M Hall (khall) 2024-03-15 18:20:12 UTC
Created attachment 163273 [details] [review]
Bug 36206: (follow-up) Change file permission

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 21 Kyle M Hall (khall) 2024-03-15 18:20:14 UTC
Created attachment 163274 [details] [review]
Bug 36206: (QA follow-up) Tidy admin-home.pl

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 22 Katrin Fischer 2024-04-22 06:17:50 UTC
Requires some small fixes:

1) Database update:
+            say $out "Added new permission 'edit_any_item'";

2) Logic on the admin page

The changed logic here introduces a regression:

Before the change "headings" only displayed if the user had permissions and plugins were enabled. 

Now the heading will always display as soon as plugins are enabled, even to users without any plugin related permissions. 

3) Typo in permissions.inc

+        <span class="sub_permission admin_subpermission">
+            Use adminitstrative plugins

I would have fixed 1 + 3 inline, but I didn't want to fiddle with 2 right now. 

Please fix.
Comment 23 Martin Renvoize (ashimema) 2024-04-25 12:14:03 UTC
Created attachment 165533 [details] [review]
Bug 36206: (follow-up) Fix Typos
Comment 24 Martin Renvoize (ashimema) 2024-04-25 12:18:15 UTC
Created attachment 165534 [details] [review]
Bug 36206: (follow-up) More conditions on display
Comment 25 Katrin Fischer 2024-04-26 11:48:11 UTC
Thanks for the follow-up!
Comment 26 Katrin Fischer 2024-04-26 12:17:00 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 27 Katrin Fischer 2024-04-26 13:33:18 UTC
Please fix!

    #   Failed test 'Expected permissions generated for superlibrarian'
    #   at /kohadevbox/koha/t/Koha/Auth/Permissions.t line 289.
     #     Structures begin differing at:
    #          $got->{CAN_user_plugins_admin} = '1'
    #     $expected->{CAN_user_plugins_admin} = Does not exist
     # Looks like you failed 1 test of 1.
Comment 28 Tomás Cohen Arazi (tcohen) 2024-04-26 20:18:22 UTC
Created attachment 165695 [details] [review]
Bug 36206: (follow-up) Fix Permissions.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 29 Tomás Cohen Arazi (tcohen) 2024-04-26 20:22:17 UTC
(In reply to Katrin Fischer from comment #27)
> Please fix!
> 
>     #   Failed test 'Expected permissions generated for superlibrarian'
>     #   at /kohadevbox/koha/t/Koha/Auth/Permissions.t line 289.
>      #     Structures begin differing at:
>     #          $got->{CAN_user_plugins_admin} = '1'
>     #     $expected->{CAN_user_plugins_admin} = Does not exist
>      # Looks like you failed 1 test of 1.

Done and pushed.
Comment 30 Martin Renvoize (ashimema) 2024-04-27 06:33:01 UTC
Thanks for jumping on that one Tomas
Comment 31 Fridolin Somers 2024-05-24 07:45:12 UTC
Great :D

Maybe add some text in https://wiki.koha-community.org/wiki/Koha_plugins
Comment 32 Fridolin Somers 2024-05-24 07:45:26 UTC
Not backported to 23.11.x