From 2ab3ee7d67f99f1e6b7702b22e79c3a5af85adf8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 2 Oct 2013 22:37:16 +0200 Subject: [ticket/11871] Fallback to int ID of the module, when creating links Firefox is currently unable to correctly copy a urlencoded \ so users will be unable to post links to modules. However we can still fallback to the id instead of the name, so we do that in this case. PHPBB3-11871 --- phpBB/includes/functions_module.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index b33f3d6866..dca720c36e 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -519,7 +519,7 @@ class p_master } // 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}"; + $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } else { @@ -551,7 +551,7 @@ 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_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; + $this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; } // Add url_extra parameter to u_action url @@ -799,12 +799,12 @@ class p_master // if the item has a name use it, else use its id if (empty($item_ary['name'])) { - $u_title .= $item_ary['id']; + $u_title .= $item_ary['id']; } else { // if the category has a name, then use it. - $u_title .= $item_ary['name']; + $u_title .= $this->get_module_identifier($item_ary['name'], $item_ary['id']); } // If the item is not a category append the mode if (!$item_ary['cat']) @@ -982,6 +982,29 @@ class p_master return substr($basename, strlen($this->p_class) + 1); } + /** + * If the basename contains a \ we dont use that for the URL. + * + * Firefox is currently unable to correctly copy a urlencoded \ + * so users will be unable to post links to modules. + * However we can still fallback to the id instead of the name, + * so we do that in this case. + * + * @param string $basename Basename of the module + * @param int $id Id of the module + * @return mixed Identifier that should be used for + * module link creation + */ + protected function get_module_identifier($basename, $id) + { + if (strpos($basename, '\\') === false) + { + return $basename; + } + + return $id; + } + /** * Checks whether the given module basename is a correct class name * -- cgit v1.2.1 From fa31096cb98a8c26377121f26ea79520dcab00f9 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Wed, 20 Nov 2013 22:57:41 +0100 Subject: [ticket/12026] Correct path for template files Correct path for template files in MCP and UCP modules, which are added via extenstions PHPBB3-12026 --- phpBB/includes/functions_module.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index dca720c36e..ac13a99aa2 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -528,12 +528,12 @@ class p_master * the style paths for the extension (the ext author can change them * if necessary). */ - $module_dir = explode('_', get_class($this->module)); + $module_dir = explode('\\', get_class($this->module)); - // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (isset($module_dir[3]) && $module_dir[1] === 'ext') + // 0 vendor, 1 extension name, ... + if (isset($module_dir[1])) { - $module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles'; + $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; if (is_dir($phpbb_root_path . $module_style_dir)) { -- cgit v1.2.1 From fc778fe63706d21ce2fd78f10e5c8f4dec29ed3b Mon Sep 17 00:00:00 2001 From: Lukasz Date: Wed, 20 Nov 2013 23:04:56 +0100 Subject: [ticket/12026] Remove phpbb root path PHPBB3-12026 --- phpBB/includes/functions_module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index ac13a99aa2..0d0f79a16d 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -535,7 +535,7 @@ class p_master { $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; - if (is_dir($phpbb_root_path . $module_style_dir)) + if (is_dir($module_style_dir)) { $template->set_style(array($module_style_dir, 'styles')); } -- cgit v1.2.1 From a5f1dc67b9a29b80f584ca753260fb8dbe459a43 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Dec 2013 10:02:53 +0100 Subject: [ticket/12026] Remove root path, its prepended later PHPBB3-12026 --- phpBB/includes/functions_module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 0d0f79a16d..e1259eba12 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -533,9 +533,9 @@ class p_master // 0 vendor, 1 extension name, ... if (isset($module_dir[1])) { - $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; + $module_style_dir = 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; - if (is_dir($module_style_dir)) + if (is_dir($phpbb_root_path . $module_style_dir)) { $template->set_style(array($module_style_dir, 'styles')); } -- cgit v1.2.1