diff --git a/mysql/module_overrides.pl b/mysql/module_overrides.pl new file mode 100644 index 000000000..8717dcb67 --- /dev/null +++ b/mysql/module_overrides.pl @@ -0,0 +1,19 @@ + +do 'mysql-lib.pl'; + +# Override function to substitute module's name +sub module_overrides +{ +my ($rv) = @_; +my $mysql_version; +chop($mysql_version = &read_file_contents( + "$module_config_directory/version")); +$mysql_version ||= &get_mysql_version(); +if ($mysql_version =~ /mariadb/i) { + foreach my $t (keys %{$rv}) { + $rv->{$t} =~ s/MySQL/MariaDB/g; + } + } +} + +1; \ No newline at end of file diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 783a678c8..a57bfa520 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -5614,6 +5614,9 @@ if ($rv{'longdesc'}) { $rv{'index_link'} = 'index.cgi'; } +# Apply module overrides +&get_module_overrides($_[0], \%rv); + # Call theme-specific override function if (defined(&theme_get_module_info)) { %rv = &theme_get_module_info(\%rv, $_[0], $_[1], $_[2]); @@ -5622,6 +5625,30 @@ if (defined(&theme_get_module_info)) { return %rv; } +=head2 get_module_overrides($mod, \data) + +Checks for module specific overrides if exist in +module.overrides file and executes defined subs + +=cut +sub get_module_overrides +{ +my ($mod, $data) = @_; +return if (!$mod); + +my $mdir = &module_root_directory($mod); + +# Call module specific overrides +my $call = 'module_overrides'; +if (-r "$mdir/$call.pl") { + eval { + local $main::error_must_die = 1; + &foreign_require($mod, "$call.pl"); + &foreign_call($mod, $call, $data); + }; + } +} + =head2 get_all_module_infos(cachemode) Returns a list contains the information on all modules in this webmin