aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/migration/tool/module.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-03-04 00:22:15 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-03-04 00:22:15 +0100
commitd26ad8ed2693b03a12eec4deec729e972579e5d9 (patch)
tree5e5089616cc4b398c1c698154ff5fdac8f6d1476 /phpBB/includes/db/migration/tool/module.php
parent8a9e1ca3f176946bc7b8ddb9be30ca8607685b80 (diff)
parentbee4f8d8185d4ff5278be758db4ea4a814f09b4f (diff)
downloadforums-d26ad8ed2693b03a12eec4deec729e972579e5d9.tar
forums-d26ad8ed2693b03a12eec4deec729e972579e5d9.tar.gz
forums-d26ad8ed2693b03a12eec4deec729e972579e5d9.tar.bz2
forums-d26ad8ed2693b03a12eec4deec729e972579e5d9.tar.xz
forums-d26ad8ed2693b03a12eec4deec729e972579e5d9.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/avatars
Conflicts: phpBB/install/database_update.php
Diffstat (limited to 'phpBB/includes/db/migration/tool/module.php')
-rw-r--r--phpBB/includes/db/migration/tool/module.php71
1 files changed, 30 insertions, 41 deletions
diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php
index afe1f21ec5..ad94c5aadb 100644
--- a/phpBB/includes/db/migration/tool/module.php
+++ b/phpBB/includes/db/migration/tool/module.php
@@ -183,25 +183,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$basename = str_replace(array('/', '\\'), '', $basename);
$class = str_replace(array('/', '\\'), '', $class);
- $include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path;
- $info_file = "$class/info/$basename.{$this->php_ext}";
-
- // The manual and automatic ways both failed...
- if (!file_exists($include_path . $info_file))
- {
- throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $info_file);
- }
-
- $classname = "{$basename}_info";
-
- if (!class_exists($classname))
- {
- include($include_path . $info_file);
- }
-
- $info = new $classname;
- $module = $info->module();
- unset($info);
+ $module = $this->get_module_info($class, $basename);
$result = '';
foreach ($module['modes'] as $mode => $module_info)
@@ -242,14 +224,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
if (!$module_id)
{
- throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent);
+ throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
}
$parent = $data['parent_id'] = $module_id;
}
else if (!$this->exists($class, false, $parent))
{
- throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent);
+ throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
}
if ($this->exists($class, $parent, $data['module_langname']))
@@ -373,30 +355,13 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$basename = str_replace(array('/', '\\'), '', $module['module_basename']);
$class = str_replace(array('/', '\\'), '', $class);
- $include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path;
- $info_file = "$class/info/$basename.{$this->php_ext}";
-
- if (!file_exists($include_path . $info_file))
- {
- throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file);
- }
-
- $classname = "{$basename}_info";
-
- if (!class_exists($classname))
- {
- include($include_path . $info_file);
- }
-
- $info = new $classname;
- $module_info = $info->module();
- unset($info);
+ $module_info = $this->get_module_info($class, $basename);
foreach ($module_info['modes'] as $mode => $info)
{
if (!isset($module['modes']) || in_array($mode, $module['modes']))
{
- $this->remove($class, $parent, $info['title']) . '<br />';
+ $this->remove($class, $parent, $info['title']);
}
}
}
@@ -477,7 +442,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$result = $acp_modules->delete_module($module_id);
if (!empty($result))
{
- throw new phpbb_db_migration_exception('CANNOT_REMOVE_MODULE', $module_id);
+ throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result);
}
}
@@ -510,4 +475,28 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
return call_user_func_array(array(&$this, $call), $arguments);
}
}
+
+ /**
+ * Wrapper for acp_modules::get_module_infos()
+ *
+ * @param string $class Module Class
+ * @param string $basename Module Basename
+ * @return array Module Information
+ */
+ protected function get_module_info($class, $basename)
+ {
+ if (!class_exists('acp_modules'))
+ {
+ include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
+ }
+ $acp_modules = new acp_modules();
+ $module = $acp_modules->get_module_infos($basename, $class, true);
+
+ if (empty($module))
+ {
+ throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename);
+ }
+
+ return array_pop($module);
+ }
}