diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:34 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:34 +0100 |
| commit | 517f25353246f06eec7d1fdef90a04119a45bbbf (patch) | |
| tree | 7837b0e54fcd05f2f49a22a078b0f12cad864b30 /phpBB/includes/functions_module.php | |
| parent | 89b37954f994a7cd517553d2d16686f91dcaae72 (diff) | |
| parent | 7068d8b462e388ea87883c5203a28fa6a8e4b6dc (diff) | |
| download | forums-517f25353246f06eec7d1fdef90a04119a45bbbf.tar forums-517f25353246f06eec7d1fdef90a04119a45bbbf.tar.gz forums-517f25353246f06eec7d1fdef90a04119a45bbbf.tar.bz2 forums-517f25353246f06eec7d1fdef90a04119a45bbbf.tar.xz forums-517f25353246f06eec7d1fdef90a04119a45bbbf.zip | |
Merge commit 'release-3.0-B5'
Diffstat (limited to 'phpBB/includes/functions_module.php')
| -rw-r--r-- | phpBB/includes/functions_module.php | 77 |
1 files changed, 71 insertions, 6 deletions
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 753e043c16..d45358327f 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(); @@ -69,6 +70,11 @@ class p_master $cache->put('_modules_' . $this->p_class, $this->module_cache); } + if (empty($this->module_cache)) + { + $this->module_cache = array('modules' => array(), 'parents' => array()); + } + // We "could" build a true tree with this function - maybe mod authors want to use this... // Functions for traversing and manipulating the tree are not available though // We might re-structure the module system to use true trees in 3.2.x... @@ -166,7 +172,7 @@ class p_master $depth = sizeof($this->module_cache['parents'][$row['module_id']]); // We need to prefix the functions to not create a naming conflict - + // Function for building 'url_extra' $url_func = '_module_' . $row['module_basename'] . '_url'; @@ -191,7 +197,7 @@ class p_master 'mode' => (string) $row['module_mode'], 'display' => (int) $row['module_display'], - 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode']) : '', + 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '', 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), 'langname' => $row['module_langname'], @@ -212,6 +218,50 @@ class p_master } /** + * 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 */ function module_auth($module_auth, $forum_id = false) @@ -314,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; } @@ -369,8 +420,14 @@ 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_id}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } else { @@ -384,7 +441,13 @@ class p_master $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_id}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $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 (!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']; } // Assign the module path for re-usage @@ -394,7 +457,7 @@ class p_master // 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_name : $this->p_id, $this->p_mode); + $this->module->main($this->p_name, $this->p_mode); } return; @@ -578,7 +641,9 @@ class p_master } $u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&mode=' . $item_ary['mode']); - $u_title .= (!$item_ary['cat'] && isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; + + // Was not allowed in categories before - /*!$item_ary['cat'] && */ + $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; // Only output a categories items if it's currently selected if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent))) |
