diff options
-rw-r--r-- | phpBB/includes/functions_acp.php | 5 | ||||
-rw-r--r-- | tests/functions/insert_config_array_test.php | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 2edb44d408..c46cc3421d 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -665,14 +665,15 @@ function validate_range($value_ary, &$error) * @param array $add_config_vars An array of new config display vars * @param array $where Where to place the new config vars, * before or after an exisiting config, as an array -* of the form: array('after' => 'config_name') +* of the form: array('after' => 'config_name') or +* array('before' => 'config_name'). * @return array The array of config display vars */ function phpbb_insert_config_array($display_vars, $add_config_vars, $where) { if (is_array($where) && array_key_exists(current($where), $display_vars)) { - $position = array_search(current($where), array_keys($display_vars)) + ((key($where) == 'after') ? 1 : 0); + $position = array_search(current($where), array_keys($display_vars)) + ((key($where) == 'before') ? 0 : 1); $display_vars = array_merge( array_slice($display_vars, 0, $position), $add_config_vars, diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php index e0ea3428b8..bfcb05862e 100644 --- a/tests/functions/insert_config_array_test.php +++ b/tests/functions/insert_config_array_test.php @@ -92,13 +92,13 @@ class phpbb_functions_insert_config_array_test extends phpbb_test_case 'acp_config_5' => array(), ), ), - array( // When after|before is not used correctly (defaults to before) + array( // When after|before is not used correctly (defaults to after) array('new_config_1' => array()), array('foobar' => 'acp_config_1'), array( 'legend1' => '', - 'new_config_1' => array(), 'acp_config_1' => array(), + 'new_config_1' => array(), 'acp_config_2' => array(), 'acp_config_3' => array(), 'acp_config_4' => array(), |