View | Details | Raw Unified | Return to bug 29008
Collapse All | Expand All

(-)a/Koha/Plugins/Base.pm (+43 lines)
Lines 382-387 sub disable { Link Here
382
    return $self;
382
    return $self;
383
}
383
}
384
384
385
=head2 is_for_newer_koha
386
387
Returns 1 if plugin is for newer Koha version, otherwise returns 0
388
389
=cut
390
391
sub is_for_newer_koha {
392
    my ($self)         = @_;
393
    my $actual_version = Koha::version;
394
    my $min_version    = $self->get_metadata->{minimum_version};
395
    return 0 unless $min_version;
396
    return ( _version_to_number($actual_version) < _version_to_number($min_version) ) ? 1 : 0;
397
}
398
399
=head2 is_for_older_koha
400
401
Returns 1 if plugin is for older Koha version, otherwise returns 0
402
403
=cut
404
405
sub is_for_older_koha {
406
    my ($self)         = @_;
407
    my $actual_version = Koha::version;
408
    my $max_version    = $self->get_metadata->{maximum_version};
409
    return 0 unless $max_version;
410
    return ( _version_to_number($actual_version) > _version_to_number($max_version) ) ? 1 : 0;
411
}
412
413
=head2 _version_to_number
414
415
Utility method to convert a Koha version into a float number.
416
For example 21.05.00.006 into 21.0500006
417
418
=cut
419
420
sub _version_to_number {
421
    my $koha_version = shift;
422
    return 0 unless defined($koha_version);
423
    # Version in metadata may be 18.11, 20.05.02, 21.05.00.006 ...
424
    $koha_version =~ s/^([^\.]*\.[^\.]*)\.?([^\.]*)\.?([^\.]*)$/$1$2$3/;
425
    return $koha_version;
426
}
427
385
1;
428
1;
386
__END__
429
__END__
387
430
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt (-2 / +2 lines)
Lines 153-165 Link Here
153
                                    <td>
153
                                    <td>
154
                                        [% plugin.metadata.description | html %]
154
                                        [% plugin.metadata.description | html %]
155
155
156
                                        [% IF ( plugin.metadata.minimum_version && koha_version < plugin.metadata.minimum_version ) %]
156
                                        [% IF ( plugin.is_for_newer_koha ) %]
157
                                            <div class="dialog alert">
157
                                            <div class="dialog alert">
158
                                                Warning: This plugin was written for a newer version of Koha. Use at your own risk.
158
                                                Warning: This plugin was written for a newer version of Koha. Use at your own risk.
159
                                            </div>
159
                                            </div>
160
                                        [% END %]
160
                                        [% END %]
161
161
162
                                        [% IF ( plugin.metadata.maximum_version && koha_version > plugin.metadata.maximum_version ) %]
162
                                        [% IF ( plugin.is_for_older_koha ) %]
163
                                            <div class="dialog alert">
163
                                            <div class="dialog alert">
164
                                                Warning: This plugin was written for an older version of Koha. Use at your own risk.
164
                                                Warning: This plugin was written for an older version of Koha. Use at your own risk.
165
                                            </div>
165
                                            </div>
(-)a/plugins/plugins-home.pl (-2 lines)
Lines 46-52 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
46
if ($plugins_enabled) {
46
if ($plugins_enabled) {
47
47
48
    $template->param(
48
    $template->param(
49
        koha_version => C4::Context->preference("Version"),
50
        method       => $method,
49
        method       => $method,
51
    );
50
    );
52
51
53
- 

Return to bug 29008