[ticket/506] Only check styles/all folder for module images and fix tests
B3P-506
This commit is contained in:
@@ -427,36 +427,24 @@ function get_portal_tracking_info($fetch_news)
|
||||
*/
|
||||
function check_file_src($value, $key, $module_id, $force_error = true)
|
||||
{
|
||||
global $db, $phpbb_root_path, $phpEx, $user;
|
||||
global $phpbb_admin_path, $portal_root_path, $phpEx, $user;
|
||||
|
||||
$error = '';
|
||||
|
||||
// We check if the chosen file is present in all active styles
|
||||
$sql = 'SELECT style_path
|
||||
FROM ' . STYLES_TABLE . '
|
||||
WHERE style_active = 1';
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
// We check if the chosen file is present in the styles/all/ folder
|
||||
if (!file_exists($portal_root_path . 'styles/all/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['style_path'] . '/theme/images/portal/' . $value . '<br />';
|
||||
}
|
||||
$error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/all/theme/images/portal/' . $value . '<br />';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!empty($error))
|
||||
{
|
||||
if ($force_error)
|
||||
{
|
||||
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
|
||||
{
|
||||
return $error;
|
||||
trigger_error($error . adm_back_link(append_sid("{$phpbb_admin_path}index.$phpEx", 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id)), E_USER_WARNING);
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -15,10 +15,14 @@ class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframe
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
global $phpbb_root_path, $portal_root_path;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
global $user;
|
||||
$user = new phpbb_mock_user();
|
||||
|
||||
$portal_root_path = $phpbb_root_path . 'ext/board3/portal/';
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
@@ -29,7 +33,7 @@ class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframe
|
||||
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<br />', check_file_src('portal_foobar.png', '', 15, false));
|
||||
$this->assertEquals(': styles/all/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15, false));
|
||||
}
|
||||
|
||||
public function test_check_file_src_error()
|
||||
@@ -38,6 +42,6 @@ class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframe
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->setExpectedTriggerError(E_USER_WARNING);
|
||||
$this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15));
|
||||
$this->assertEquals(': styles/all/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user