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 |
|