aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-05-19 17:45:45 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-05-19 17:45:45 +0200
commitcd1da92d8540d6b4aa0fa1ccf2bcafe68007288a (patch)
treefb0eaa2dc6fc2ca3540fa8a9717cab7daa467714 /phpBB
parente49b4543de7c18df7e9b5c70ef5064cc4de9934a (diff)
downloadforums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.gz
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.bz2
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.xz
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.zip
[ticket/11538] Add optional switch as argument to hex colour validation
The value of $optional will decide whether an empty string will be treated as incorrect input or if it is allowed. The optional argument will default to false and therefore treat an empty string as incorrect unless explicitly told to not do so. PHPBB3-11538
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/acp/acp_groups.php2
-rw-r--r--phpBB/includes/functions_user.php8
-rw-r--r--phpBB/includes/ucp/ucp_groups.php2
3 files changed, 7 insertions, 5 deletions
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 089fe4baa1..83c355540e 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -421,7 +421,7 @@ class acp_groups
*/
$validation_checks = array(
'max_recipients' => array('num', false, 0, 16777215),
- 'colour' => array('hex_colour'),
+ 'colour' => array('hex_colour', true),
);
if ($validation_error = validate_data($submit_ary, $validation_checks))
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f8e1fcaa45..61972c3876 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1903,14 +1903,16 @@ function validate_jabber($jid)
* Validate hex colour value
*
* @param string $colour The hex colour value
-* @return bool|string Error message if colour value is incorrect, false if it
+* @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)
+function phpbb_validate_hex_colour($colour, $optional = false)
{
if (empty($colour))
{
- return false;
+ return (($optional) ? false : 'WRONG_DATA');
}
if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour))
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index 20a55d8c32..9365913541 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -596,7 +596,7 @@ class ucp_groups
}
// Validate submitted colour value
- if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour'))))
+ if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour', true))))
{
// Replace "error" string with its real, localised form
$error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error));