diff --git a/portal/includes/functions.php b/portal/includes/functions.php index 8c623e44..8895c5d7 100644 --- a/portal/includes/functions.php +++ b/portal/includes/functions.php @@ -813,18 +813,17 @@ function check_file_src($value, $key, $module_id, $force_error = true) $error = ''; // We check if the chosen file is present in all active styles - $sql = 'SELECT st.theme_path - FROM ' . STYLES_THEME_TABLE . ' st - LEFT JOIN ' . STYLES_TABLE . ' s - ON (st.theme_id = s.style_id) - WHERE s.style_active = 1'; + $sql = 'SELECT style_path + FROM ' . STYLES_TABLE . ' + WHERE style_active = 1'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - if (!file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/images/portal/' . $value)) + if (!file_exists($phpbb_root_path . 'styles/' . $row['style_path'] . '/theme/images/portal/' . $value) && + !file_exists($phpbb_root_path . 'ext/board3/portal/styles/' . $row['style_path'] . '/theme/images/portal/' . $value)) { - $error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['theme_path'] . '/theme/images/portal/' . $value . '
'; + $error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['style_path'] . '/theme/images/portal/' . $value . '
'; } } $db->sql_freeresult($result); @@ -833,7 +832,7 @@ function check_file_src($value, $key, $module_id, $force_error = true) { if ($force_error) { - trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&mode=config&module_id=' . $module_id)), E_USER_WARNING ); + trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id)), E_USER_WARNING); } else { diff --git a/tests/functions/check_file_src_test.php b/tests/functions/check_file_src_test.php new file mode 100644 index 00000000..b122ca78 --- /dev/null +++ b/tests/functions/check_file_src_test.php @@ -0,0 +1,41 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/styles.xml'); + } + + public function test_check_file_src() + { + $this->assertFalse(check_file_src('portal_attach.png', '', 15, false)); + $this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png
', check_file_src('portal_foobar.png', '', 15, false)); + } + + public function test_check_file_src_error() + { + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->setExpectedTriggerError(E_USER_WARNING); + $this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png
', check_file_src('portal_foobar.png', '', 15)); + } +} diff --git a/tests/functions/fixtures/styles.xml b/tests/functions/fixtures/styles.xml new file mode 100644 index 00000000..6cb30627 --- /dev/null +++ b/tests/functions/fixtures/styles.xml @@ -0,0 +1,21 @@ + + + + style_path + style_name + style_active + style_parent_tree + + subsilver2 + subsilver2 + 0 + + + + prosilver + prosilver + 1 + + +
+
diff --git a/tests/testframework/test_case_helpers.php b/tests/testframework/test_case_helpers.php index 27c379c5..74ab9a82 100644 --- a/tests/testframework/test_case_helpers.php +++ b/tests/testframework/test_case_helpers.php @@ -9,7 +9,7 @@ namespace board3\portal\tests\testframework; -abstract class test_case_helpers extends \phpbb_test_case_helpers +class test_case_helpers extends \phpbb_test_case_helpers { /** * Copied from phpbb_test_case_helpers::get_test_config() to fix some paths