Bugzilla – Attachment 155691 Details for
Bug 31503
Allow several consent types on the consents tab of OPAC account page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31503: (follow-up) Add 'feature_enabled' to Koha::Plugins
Bug-31503-follow-up-Add-featureenabled-to-KohaPlug.patch (text/plain), 2.36 KB, created by
Martin Renvoize (ashimema)
on 2023-09-15 15:12:19 UTC
(
hide
)
Description:
Bug 31503: (follow-up) Add 'feature_enabled' to Koha::Plugins
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-09-15 15:12:19 UTC
Size:
2.36 KB
patch
obsolete
>From c0a0f64c67a88b4f6f26cca28dc4585755cfed4f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 15 Sep 2023 16:09:56 +0100 >Subject: [PATCH] Bug 31503: (follow-up) Add 'feature_enabled' to Koha::Plugins > >This patch adds a 'feature_enabled' accessor to the Koha::Plugins class. >Passing the plugin method name for the plugin feature you're looking for >will return a boolean denoting whether any enabled plugins carry said >method. > >Incuded in the patch is an addition to the TT KohaPlugins plugin to >enable quick access to this function. >--- > Koha/Plugins.pm | 24 ++++++++++++++++++++++++ > Koha/Template/Plugin/KohaPlugins.pm | 17 +++++++++++++++++ > 2 files changed, 41 insertions(+) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index a3c47006b5..520f2febf2 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -139,6 +139,30 @@ sub get_enabled_plugins { > return @$enabled_plugins; > } > >+ >+=head2 feature_enabled >+ >+Returns a boolean denoting whether a plugin based feature is enabled or not. >+ >+ $enabled = Koha::Plugins->feature_enabled('method_name'); >+ >+=cut >+ >+sub feature_enabled { >+ my ( $class, $method ) = @_; >+ >+ return 0 unless C4::Context->config('enable_plugins'); >+ >+ my $key = "ENABLED_PLUGIN_FEATURE_" . $method; >+ my $feature = Koha::Cache::Memory::Lite->get_from_cache($key); >+ unless ( defined($feature) ) { >+ my @plugins = $class->get_enabled_plugins(); >+ my $enabled = any { $_->can($method) } @plugins; >+ Koha::Cache::Memory::Lite->set_in_cache( $key, $enabled ); >+ } >+ return $feature; >+} >+ > =head2 GetPlugins > > This will return a list of all available plugins, optionally limited by >diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm >index 7d527b34e3..35ac34bcf3 100644 >--- a/Koha/Template/Plugin/KohaPlugins.pm >+++ b/Koha/Template/Plugin/KohaPlugins.pm >@@ -282,4 +282,21 @@ sub get_plugins_opac_cover_images { > return join( "\n", @data ); > } > >+=head3 feature_enabled >+ >+ [% KohaPlugins.feature_enabled('method_name') %] >+ >+This method returns true if the passed plugin hook method name is found to be installed and enabled as part of a plugin. >+ >+=cut >+ >+sub feature_enabled { >+ my ($self, $method) = @_; >+ >+ my $p = Koha::Plugins->new(); >+ return 0 unless $p; >+ >+ return $p->feature_enabled($method); >+} >+ > 1; >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31503
:
140047
|
140048
|
140049
|
140050
|
140080
|
140081
|
140082
|
140083
|
140084
|
140085
|
140087
|
140088
|
140089
|
140090
|
140666
|
140667
|
140668
|
140669
|
140670
|
140671
|
140672
|
141216
|
141217
|
141218
|
141219
|
141220
|
141221
|
141222
|
141263
|
141264
|
141265
|
141266
|
141267
|
141268
|
141269
|
141302
|
141570
|
155000
|
155001
|
155002
|
155003
|
155177
|
155178
|
155179
|
155180
|
155189
|
155190
|
155191
|
155656
|
155657
|
155658
|
155659
|
155660
|
155661
|
155691
|
155694
|
155783
|
155784
|
155785
|
155786
|
155787
|
155788
|
155789
|
155790
|
155791
|
157117
|
157118
|
157119
|
157120
|
157121
|
157122
|
157123
|
157124
|
157125
|
157126
|
157773
|
157774
|
157775
|
157776
|
157777
|
157778
|
157779
|
157780
|
157781
|
157782
|
157783