aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_module.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-08-22 03:19:17 -0400
committerNils Adermann <naderman@naderman.de>2011-09-29 15:42:47 +0200
commit4844b007771f71973db2fa440d3c8ef9057d1b02 (patch)
treeb7cc57543c8a684342f551207b02eebfed9ef2f3 /phpBB/includes/functions_module.php
parentf6632fcfd08650f13560529a6a04c152aefd4e3c (diff)
downloadforums-4844b007771f71973db2fa440d3c8ef9057d1b02.tar
forums-4844b007771f71973db2fa440d3c8ef9057d1b02.tar.gz
forums-4844b007771f71973db2fa440d3c8ef9057d1b02.tar.bz2
forums-4844b007771f71973db2fa440d3c8ef9057d1b02.tar.xz
forums-4844b007771f71973db2fa440d3c8ef9057d1b02.zip
[feature/extension-manager] Load (A/U/M)CP modules from extensions
To avoid large bc breaking changes, modules in the old includes directory structure still follow the same naming conventions. Modules in extensions have to be placed in an xcp/ folder and need a _module suffix. The corresponding info file is in the same directory but with an _info suffix. PHPBB3-10323
Diffstat (limited to 'phpBB/includes/functions_module.php')
-rw-r--r--phpBB/includes/functions_module.php84
1 files changed, 41 insertions, 43 deletions
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index 09c54422b0..1a6b57794a 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -440,7 +440,8 @@ class p_master
trigger_error('Module not accessible', E_USER_ERROR);
}
- if (!class_exists("{$this->p_class}_$this->p_name"))
+ // new modules use the full class names, old ones are always called <type>_<name>, e.g. acp_board
+ if (!class_exists($this->p_name) && !class_exists("{$this->p_class}_$this->p_name"))
{
if (!file_exists("$module_path/{$this->p_class}_$this->p_name.$phpEx"))
{
@@ -453,62 +454,59 @@ class p_master
{
trigger_error("Module file $module_path/{$this->p_class}_$this->p_name.$phpEx does not contain correct class [{$this->p_class}_$this->p_name]", E_USER_ERROR);
}
+ }
- if (!empty($mode))
- {
- $this->p_mode = $mode;
- }
+ if (!empty($mode))
+ {
+ $this->p_mode = $mode;
+ }
- // Create a new instance of the desired module ... if it has a
- // constructor it will of course be executed
- $instance = "{$this->p_class}_$this->p_name";
+ // Create a new instance of the desired module ...
+ $class_name = (class_exists($this->p_name)) ? $this->p_name : "{$this->p_class}_$this->p_name";
- $this->module = new $instance($this);
+ $this->module = new $class_name($this);
- // We pre-define the action parameter we are using all over the place
- if (defined('IN_ADMIN'))
+ // We pre-define the action parameter we are using all over the place
+ if (defined('IN_ADMIN'))
+ {
+ // Is first module automatically enabled a duplicate and the category not passed yet?
+ if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate'])
{
- // Is first module automatically enabled a duplicate and the category not passed yet?
- if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate'])
- {
- $icat = $this->module_ary[$this->active_module_row_id]['parent'];
- }
+ $icat = $this->module_ary[$this->active_module_row_id]['parent'];
+ }
- // Not being able to overwrite ;)
- $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ // Not being able to overwrite ;)
+ $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ }
+ else
+ {
+ // If user specified the module url we will use it...
+ if ($module_url !== false)
+ {
+ $this->module->u_action = $module_url;
}
else
{
- // If user specified the module url we will use it...
- if ($module_url !== false)
- {
- $this->module->u_action = $module_url;
- }
- else
- {
- $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
- }
-
- $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
}
- // Add url_extra parameter to u_action url
- if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra'])
- {
- $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra'];
- }
+ $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ }
- // Assign the module path for re-usage
- $this->module->module_path = $module_path . '/';
+ // Add url_extra parameter to u_action url
+ if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra'])
+ {
+ $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra'];
+ }
- // Execute the main method for the new instance, we send the module id and mode as parameters
- // Users are able to call the main method after this function to be able to assign additional parameters manually
- if ($execute_module)
- {
- $this->module->main($this->p_name, $this->p_mode);
- }
+ // Assign the module path for re-usage
+ $this->module->module_path = $module_path . '/';
- return;
+ // Execute the main method for the new instance, we send the module id and mode as parameters
+ // Users are able to call the main method after this function to be able to assign additional parameters manually
+ if ($execute_module)
+ {
+ $this->module->main($this->p_name, $this->p_mode);
}
}