diff options
author | Andreas Fischer <bantu@phpbb.com> | 2013-05-26 18:24:29 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2013-05-26 18:24:29 +0200 |
commit | 2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497 (patch) | |
tree | b8b1bb07ef8cd5e070099445ef497ab92d321747 /phpBB/includes/functions_user.php | |
parent | 4a935608708c28f2996c732517d877bb0cd80738 (diff) | |
parent | cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a (diff) | |
download | forums-2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497.tar forums-2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497.tar.gz forums-2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497.tar.bz2 forums-2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497.tar.xz forums-2b356e766f8d0f3e9dfc2d1fdd6bc857fdb63497.zip |
Merge remote-tracking branch 'marc1706/ticket/11538' into develop-olympus
* marc1706/ticket/11538:
[ticket/11538] Add optional switch as argument to hex colour validation
[ticket/11538] Modify test colour values
[ticket/11538] Limit comment in acp_groups to 80 characters per line
[ticket/11538] Move group ID into abstract test class and add more test cases
[ticket/11538] Merge calls to validate_data() in acp_groups
[ticket/11538] Rename phpbb_validate_colour to phpbb_validate_hex_colour
[ticket/11538] Use abstract class for functional test cases for group colour
[ticket/11538] Add function phpbb_validate_colour for validating colours
[ticket/11538] Make sure regex doesn't allow multiple color values
[ticket/11538] Add tests for acp group manage page
[ticket/11538] Simplify colour value check and remove support for '#'
[ticket/11538] Fix incorrect regex and test for duplicate # in color string
[ticket/11538] Use regex for testing color value and improve tests
[ticket/11538] Make sure group color can't exceed maximum of 6 characters
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 5a6a0b4a05..61972c3876 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1247,8 +1247,9 @@ function validate_data($data, $val_ary) { $function = array_shift($validate); array_unshift($validate, $data[$var]); + $function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate'; - if ($result = call_user_func_array('validate_' . $function, $validate)) + if ($result = call_user_func_array($function_prefix . $function, $validate)) { // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); @@ -1899,6 +1900,30 @@ function validate_jabber($jid) } /** +* Validate hex colour value +* +* @param string $colour The hex colour value +* @param bool $optional Whether the colour value is optional. True if an empty +* string will be accepted as correct input, false if not. +* @return bool|string Error message if colour value is incorrect, false if it +* fits the hex colour code +*/ +function phpbb_validate_hex_colour($colour, $optional = false) +{ + if (empty($colour)) + { + return (($optional) ? false : 'WRONG_DATA'); + } + + if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour)) + { + return 'WRONG_DATA'; + } + + return false; +} + +/** * Verifies whether a style ID corresponds to an active style. * * @param int $style_id The style_id of a style which should be checked if activated or not. |