From 60d817416bd2367e3a234837f559f6e0ffb150c0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 22 Jan 2007 17:05:23 +0000 Subject: fixing mcp bugs by introducing a new feature to check for loaded/accessible modules/modes. If the MCP module "logs" get disabled the quick mod tools on viewtopic still show a link to the logs, this will then lead to an error message. This is not fixable. The logs should be accessible to all moderators by default. git-svn-id: file:///svn/phpbb/trunk@6920 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_module.php | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index ca47ef2f89..1ad543c298 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -21,6 +21,7 @@ class p_master var $p_parent; var $active_module = false; + var $active_module_row_id = false; var $acl_forum_id = false; var $module_ary = array(); @@ -216,6 +217,50 @@ class p_master unset($this->module_cache['modules'], $names); } + /** + * Check if a certain main module is accessible/loaded + * By giving the module mode you are able to additionally check for only one mode within the main module + * + * @param string $module_basename The module base name, for example logs, reports, main (for the mcp). + * @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence. + * + * @return bool Returns true if module is loaded and accessible, else returns false + */ + function loaded($module_basename, $module_mode = false) + { + if (empty($this->loaded_cache)) + { + $this->loaded_cache = array(); + + foreach ($this->module_ary as $row) + { + if (!$row['name']) + { + continue; + } + + if (!isset($this->loaded_cache[$row['name']])) + { + $this->loaded_cache[$row['name']] = array(); + } + + if (!$row['mode']) + { + continue; + } + + $this->loaded_cache[$row['name']][$row['mode']] = true; + } + } + + if ($module_mode === false) + { + return (isset($this->loaded_cache[$module_basename])) ? true : false; + } + + return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false; + } + /** * Check module authorisation */ @@ -319,6 +364,7 @@ class p_master $this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id]; $this->active_module = $item_ary['id']; + $this->active_module_row_id = $row_id; break; } @@ -374,6 +420,12 @@ class p_master // 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']) + { + $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) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } @@ -392,6 +444,12 @@ class p_master $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } + // Add url_extra parameter to u_action url + if ($this->module_ary[$this->active_module_row_id]['url_extra']) + { + $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra']; + } + // Assign the module path for re-usage $this->module->module_path = $module_path . '/'; -- cgit v1.2.1