Module invoker can now accept arbitrary argument hashes to pass to modules.
This commit is contained in:
parent
1303431bdd
commit
001992af81
23
Modules.pm
23
Modules.pm
@ -45,7 +45,6 @@ BEGIN {
|
||||
# to create block modules on the fly.
|
||||
# cgi - The CGI object to access parameters and cookies through.
|
||||
# dbh - The database handle to use for queries.
|
||||
# phpbb - An object through which to talk to a phpBB3 database
|
||||
# settings - The system settings object
|
||||
# template - The system template object
|
||||
# session - The session object
|
||||
@ -76,7 +75,7 @@ sub new {
|
||||
return set_error("No settings object available.") if(!$self -> {"settings"});
|
||||
|
||||
# ... finally, template
|
||||
return set_error("No settings template available.") if(!$self -> {"template"});
|
||||
return set_error("No template object available.") if(!$self -> {"template"});
|
||||
|
||||
# update @INC if needed
|
||||
unshift(@INC, $self -> {"blockdir"}) if($self -> {"blockdir"});
|
||||
@ -186,15 +185,17 @@ sub _new_module_internal {
|
||||
my $name = $modrow -> {"perl_module"};
|
||||
no strict "refs"; # must disable strict references to allow named module loading.
|
||||
require "$name.pm";
|
||||
my $modobj = $name -> new($modrow -> {"id"},
|
||||
$modarg,
|
||||
$self -> {"cgi"},
|
||||
$self -> {"dbh"},
|
||||
$self -> {"phpbb"},
|
||||
$self -> {"template"},
|
||||
$self -> {"settings"},
|
||||
$self -> {"session"},
|
||||
$self)
|
||||
|
||||
# Set up the module argument hash...
|
||||
my %args = { "modid" => $modrow -> {"id"},
|
||||
"args" => $modarg,
|
||||
"module" => $self,
|
||||
};
|
||||
foreach my $key (%{$self}) {
|
||||
$args{$key} = $self -> {$key};
|
||||
}
|
||||
|
||||
my $modobj = $name -> new(%args)
|
||||
or set_error("Unable to load module: ".$Block::errstr);
|
||||
use strict;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user