aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migration/tool/module.php
diff options
context:
space:
mode:
authorMateBartus <mate.bartus@gmail.com>2015-05-31 13:21:45 +0200
committerMateBartus <mate.bartus@gmail.com>2015-05-31 13:22:45 +0200
commit77ee0e62ca1685e4577947cc60163367dfa97de6 (patch)
treead9ac0d6fc644cf1aa36f891c454523130b21f74 /phpBB/phpbb/db/migration/tool/module.php
parente877a752be55dfda5a72c7995708e4e132a1079d (diff)
downloadforums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.gz
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.bz2
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.xz
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.zip
[ticket/13777] Use module manager in phpBB core files
PHPBB3-13777
Diffstat (limited to 'phpBB/phpbb/db/migration/tool/module.php')
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php55
1 files changed, 18 insertions, 37 deletions
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index b6f0372181..3b181872db 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -13,6 +13,8 @@
namespace phpbb\db\migration\tool;
+use phpbb\module\exception\module_exception;
+
/**
* Migration module management tool
*/
@@ -27,6 +29,9 @@ class module implements \phpbb\db\migration\tool\tool_interface
/** @var \phpbb\user */
protected $user;
+ /** @var \phpbb\module\module_manager */
+ protected $module_manager;
+
/** @var string */
protected $phpbb_root_path;
@@ -42,15 +47,17 @@ class module implements \phpbb\db\migration\tool\tool_interface
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\service $cache
* @param \phpbb\user $user
+ * @param \phpbb\module\module_manager $module_manager
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $modules_table
*/
- public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, $phpbb_root_path, $php_ext, $modules_table)
+ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, \phpbb\module\module_manager $module_manager, $phpbb_root_path, $php_ext, $modules_table)
{
$this->db = $db;
$this->cache = $cache;
$this->user = $user;
+ $this->module_manager = $module_manager;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->modules_table = $modules_table;
@@ -188,7 +195,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
$module = $this->get_module_info($class, $basename);
- $result = '';
foreach ($module['modes'] as $mode => $module_info)
{
if (!isset($data['modes']) || in_array($mode, $data['modes']))
@@ -239,13 +245,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
return;
}
- if (!class_exists('acp_modules'))
- {
- include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
- $this->user->add_lang('acp/modules');
- }
- $acp_modules = new \acp_modules();
-
$module_data = array(
'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,
'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1,
@@ -256,16 +255,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '',
'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '',
);
- $result = $acp_modules->update_module_data($module_data, true);
- // update_module_data can either return a string or an empty array...
- if (is_string($result))
- {
- // Error
- throw new \phpbb\db\migration\exception('MODULE_ERROR', $result);
- }
- else
+ try
{
+ $this->module_manager->update_module_data($module_data);
+
// Success
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name));
@@ -318,6 +312,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
$this->db->sql_query($sql);
}
}
+ catch (module_exception $e)
+ {
+ // Error
+ throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage());
+ }
// Clear the Modules Cache
$this->cache->destroy("_modules_$class");
@@ -417,21 +416,9 @@ class module implements \phpbb\db\migration\tool\tool_interface
$module_ids[] = (int) $module;
}
- if (!class_exists('acp_modules'))
- {
- include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
- $this->user->add_lang('acp/modules');
- }
- $acp_modules = new \acp_modules();
- $acp_modules->module_class = $class;
-
foreach ($module_ids as $module_id)
{
- $result = $acp_modules->delete_module($module_id);
- if (!empty($result))
- {
- return;
- }
+ $this->module_manager->delete_module($module_id, $class);
}
$this->cache->destroy("_modules_$class");
@@ -474,13 +461,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
*/
protected function get_module_info($class, $basename)
{
- if (!class_exists('acp_modules'))
- {
- include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
- $this->user->add_lang('acp/modules');
- }
- $acp_modules = new \acp_modules();
- $module = $acp_modules->get_module_infos($basename, $class, true);
+ $module = $this->module_manager->get_module_infos($basename, $class, true);
if (empty($module))
{