mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
Merge pull request #1470 from webmin/dev/module-info-override
Add ability to override module's info #1421
This commit is contained in:
19
mysql/module_overrides.pl
Normal file
19
mysql/module_overrides.pl
Normal file
@@ -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;
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user