[feature/module_services] Fix check_file_src() function for extensions
This commit is contained in:
@@ -813,18 +813,17 @@ function check_file_src($value, $key, $module_id, $force_error = true)
|
|||||||
$error = '';
|
$error = '';
|
||||||
|
|
||||||
// We check if the chosen file is present in all active styles
|
// We check if the chosen file is present in all active styles
|
||||||
$sql = 'SELECT st.theme_path
|
$sql = 'SELECT style_path
|
||||||
FROM ' . STYLES_THEME_TABLE . ' st
|
FROM ' . STYLES_TABLE . '
|
||||||
LEFT JOIN ' . STYLES_TABLE . ' s
|
WHERE style_active = 1';
|
||||||
ON (st.theme_id = s.style_id)
|
|
||||||
WHERE s.style_active = 1';
|
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
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 . '<br />';
|
$error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['style_path'] . '/theme/images/portal/' . $value . '<br />';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
@@ -833,7 +832,7 @@ function check_file_src($value, $key, $module_id, $force_error = true)
|
|||||||
{
|
{
|
||||||
if ($force_error)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
41
tests/functions/check_file_src_test.php
Normal file
41
tests/functions/check_file_src_test.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) Board3 Group ( www.board3.de )
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__) . '/../../portal/includes/functions.php');
|
||||||
|
require_once(dirname(__FILE__) . '/../../../../../includes/functions_acp.php');
|
||||||
|
|
||||||
|
class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframework\database_test_case
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
global $db, $phpbb_root_path, $phpEx, $user;
|
||||||
|
$user = new phpbb_mock_user();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDataSet()
|
||||||
|
{
|
||||||
|
return $this->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<br />', 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<br />', check_file_src('portal_foobar.png', '', 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
21
tests/functions/fixtures/styles.xml
Normal file
21
tests/functions/fixtures/styles.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<dataset>
|
||||||
|
<table name="phpbb_styles">
|
||||||
|
<column>style_path</column>
|
||||||
|
<column>style_name</column>
|
||||||
|
<column>style_active</column>
|
||||||
|
<column>style_parent_tree</column>
|
||||||
|
<row>
|
||||||
|
<value>subsilver2</value>
|
||||||
|
<value>subsilver2</value>
|
||||||
|
<value>0</value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>prosilver</value>
|
||||||
|
<value>prosilver</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value></value>
|
||||||
|
</row>
|
||||||
|
</table>
|
||||||
|
</dataset>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace board3\portal\tests\testframework;
|
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
|
* Copied from phpbb_test_case_helpers::get_test_config() to fix some paths
|
||||||
|
|||||||
Reference in New Issue
Block a user