Koha/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt
Martin Renvoize ea22082649
Bug 25672: Convert to restricting to listed repositories only
I think instead of a plain on/off switch we should use it in combination
with the plugin_repo's and set it to restrict to only those repos' (i.e.
disable uploads entirely if no repo's are listed, or just allow those
repo's when there are).

This patch achieves that, but only if plugins are installed via the
plugin browser method. We disable all direct upload avenues, so install
is blocked for other cases.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-31 11:02:43 -03:00

276 lines
17 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE KohaDates %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% t("Plugins") | html %] &rsaquo;
[% IF ( method == 'tool' ) %]
[% t("Tools") | html %]
[% ELSE %]
[% t("Administration") | html %]
[% END %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="plugins_plugins_home" class="plugins">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
[% IF ( method == 'tool' ) %]
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
[% ELSE %]
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
[% END %]
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Plugins</span>
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
<h1>Plugins</h1>
<div class="details">
[% IF ( CAN_user_plugins_manage ) %]
<div class="btn-toolbar" id="toolbar">
[% IF ( !plugins_restricted ) %]
<a href="/cgi-bin/koha/plugins/plugins-upload.pl" id="upload_plugin" class="btn btn-default"><i class="fa fa-upload"></i> Upload plugin</a>
[% END %]
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa-solid fa-eye"></i> View plugins by class <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl">View all plugins</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=report">View report plugins</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=tool">View tool plugins</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=to_marc">View MARC conversion plugins</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=opac_online_payment">View online payment plugins</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=intranet_catalog_biblio_enhancements">View bibliographic record enhancement plugins for the staff interface</a></li>
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=ill_availability_services">View ILL availability plugins</a></li>
</ul>
</div>
[% IF can_search %]
<div class="btn-group">
<form class="form-inline" id="plugin-search-form">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" name="plugin-search" id="plugin-repo-search" placeholder="Search for plugins" value="[% search_term | html %]"/>
<div class="input-group-btn">
<button class="btn btn-default" type="button" id="plugin-search-button"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
</form>
</div>
[% END %]
</div>
[% END %]
[% IF search_results %]
<h2>Search results</h2>
<div class="page-section">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Organization</th>
<th>Latest version</th>
<th>&nbsp;</th>
</tr>
</thead>
[% FOREACH sr IN search_results %]
<tr>
<td><a href="[% sr.result.html_url | url %]" target="_new">[% sr.result.name | html %]</a></td>
<td>[% sr.result.description | html %]</td>
<td>[% sr.repo.name | html %]</td>
<td>[% sr.result.tag_name | html %]</td>
<td><a class="btn btn-default btn-sm btn-install-plugin" href="/cgi-bin/koha/plugins/plugins-upload.pl?op=Upload&uploadfile=[% sr.result.install_name | uri %]&uploadlocation=[% sr.result.install_url | uri %]"><i class="fa fa-download"></i> Install</a></td>
</tr>
[% END %]
</table>
</div><!-- /.page-section -->
[% END %]
[% UNLESS ( plugins ) %]
[% UNLESS ( method ) %]
<div class="dialog message">No plugins installed</div>
[% ELSE %]
[% IF method == 'tool' %]
<div class="dialog message">No plugins that can be used as a tool are installed</div>
[% ELSIF method == 'report' %]
<div class="dialog message">No plugins that can create a report are installed</div>
[% ELSIF method == 'to_marc' %]
<div class="dialog message">No plugins that can convert files to MARC records are installed</div>
[% ELSIF method == 'opac_online_payment' %]
<div class="dialog message">No plugins that can process online payments via the public catalog are installed</div>
[% ELSIF method == 'intranet_catalog_biblio_enhancements' %]
<div class="dialog message">No plugins that can enhance the bibliographic records in the staff interface are installed</div>
[% ELSIF method == 'ill_availability_services' %]
<div class="dialog message">No plugins that can show ILL availability results are installed</div>
[% ELSE %]
<div class="dialog message">Unknown plugin type <em>[% method | html %]</em></div>
[% END %]
[% END %]
[% ELSE %]
<div class="page-section">
<table id="installed_plugins">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Author</th>
<th>Plugin version</th>
<th>Minimum Koha version</th>
<th>Maximum Koha version</th>
<th>Last updated</th>
<th>Status</th>
[% IF ( CAN_user_plugins_configure || CAN_user_plugins_manage || CAN_user_plugins_report || CAN_user_plugins_tool ) %]
<th class="noExport NoSort">Actions</th>
[% END %]
</tr>
</thead>
[% FOREACH plugin IN plugins %]
[% IF plugin.error %]
<tr class="warn">
<td>
<strong>[% plugin.name | html %]</strong>
<span class="label label-warning">ERRORS</span>
</td>
[% IF ( CAN_user_plugins_configure || CAN_user_plugins_manage || CAN_user_plugins_report || CAN_user_plugins_tool ) %]
<td colspan="7">Error found whilst attempting to load plugin</td>
[% ELSE %]
<td colspan="6">Error found whilst attempting to load plugin</td>
[% END %]
</tr>
[% ELSE %]
<tr>
<td>
<strong>[% plugin.metadata.name | html %]</strong>
</td>
<td>
[% plugin.metadata.description | html %]
[% IF ( plugin.metadata.minimum_version && koha_version < plugin.metadata.minimum_version ) %]
<div class="dialog alert">
Warning: This plugin was written for a newer version of Koha. Use at your own risk.
</div>
[% END %]
[% IF ( plugin.metadata.maximum_version && koha_version > plugin.metadata.maximum_version ) %]
<div class="dialog alert">
Warning: This plugin was written for an older version of Koha. Use at your own risk.
</div>
[% END %]
</td>
<td>[% plugin.metadata.author | html %]</td>
<td>[% plugin.metadata.version | html %]</td>
<td>[% plugin.metadata.minimum_version | html %]</td>
<td>[% plugin.metadata.maximum_version | html %]</td>
<td>[% plugin.metadata.date_updated | $KohaDates %]</td>
<td>
[% IF ( plugin.is_enabled ) %]
<span class="bg-success">Enabled</span>
[% ELSE %]
<span class="bg-warning">Disabled</span>
[% END %]
</td>
[% IF ( CAN_user_plugins_configure || CAN_user_plugins_manage || CAN_user_plugins_report || CAN_user_plugins_tool ) %]
<td class="actions">
<div class="btn-group dropup">
<a class="btn btn-default btn-xs dropdown-toggle" id="pluginactions[% plugin.class | html %]" role="button" data-toggle="dropdown" href="#">
Actions <b class="caret"></b>
</a>
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="pluginactions[% plugin.class | html %]">
[% IF ( CAN_user_plugins_report ) %]
[% IF plugin.can('report') %]
<li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=report"><i class="fa fa-table fa-fw"></i> Run report</a></li>
[% END %]
[% END %]
[% IF ( CAN_user_plugins_tool ) %]
[% IF plugin.can('tool') %]
<li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=tool"><i class="fa fa-wrench fa-fw"></i> Run tool</a></li>
[% END %]
[% END %]
[% IF ( CAN_user_plugins_configure ) %]
[% IF plugin.can('configure') %]
<li><a href="/cgi-bin/koha/plugins/run.pl?class=[% plugin.class | uri %]&method=configure"><i class="fa fa-cog fa-fw"></i> Configure</a></li>
[% END %]
[% END %]
[% IF ( CAN_user_plugins_manage ) %]
<li><a class="uninstall_plugin" data-plugin-name="[% plugin.metadata.name | html %]" href="/cgi-bin/koha/plugins/plugins-uninstall.pl?class=[% plugin.class | html %]"><i class="fa fa-trash-can fa-fw"></i> Uninstall</a></li>
[% IF ( plugin.is_enabled ) %]
<li><a class="enable_plugin" data-plugin-name="[% plugin.metadata.name | html %]" href="/cgi-bin/koha/plugins/plugins-enable.pl?class=[% plugin.class | html %]&method=disable"><i class="fa fa-pause fa-fw"></i> Disable</a></li>
[% ELSE %]
<li><a class="enable_plugin" data-plugin-name="[% plugin.metadata.name | html %]" href="/cgi-bin/koha/plugins/plugins-enable.pl?class=[% plugin.class | html %]&method=enable"><i class="fa fa-play fa-fw"></i> Enable</a></li>
[% END %]
[% END %]
</ul>
</div>
</td>
[% END %]
</tr>
[% END %]
[% END %]
</table>
</div><!-- /.page-section -->
[% END %]
</div>
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% IF ( method == 'tool' ) %]
[% INCLUDE 'tools-menu.inc' %]
[% ELSE %]
[% INCLUDE 'admin-menu.inc' %]
[% END %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
<script>
$(document).ready(function(){
$(".uninstall_plugin").on("click", function(){
$(".dropdown").removeClass("open");
var plugin_name = $(this).data("plugin-name");
return confirmDelete( _("Are you sure you want to uninstall the plugin %s?").format( plugin_name ) );
});
$("#plugin-search-button").on("click", function(){
$("#plugin-search-form").submit();
});
KohaTable("installed_plugins", {
"bPaginate": false
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]