diff options
author | Nils Adermann <naderman@naderman.de> | 2012-07-17 18:48:10 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2012-07-23 15:45:57 +0200 |
commit | 10172887fd47e86eefbabd6f5e755cd93279960d (patch) | |
tree | 307f50b083a62a9b097202c50085d63da7ec6959 /phpBB/includes/functions_profile_fields.php | |
parent | 55aaa596d72c8eef54f394da22f43bdf731d9333 (diff) | |
download | forums-10172887fd47e86eefbabd6f5e755cd93279960d.tar forums-10172887fd47e86eefbabd6f5e755cd93279960d.tar.gz forums-10172887fd47e86eefbabd6f5e755cd93279960d.tar.bz2 forums-10172887fd47e86eefbabd6f5e755cd93279960d.tar.xz forums-10172887fd47e86eefbabd6f5e755cd93279960d.zip |
[ticket/10965] Introduce a new profile field option to display no value
By default the 3.0.10 behaviour is kept, profile fields will not show up
if they have either not yet been selected or in case of an optional
dropdown field if the novalue option was selected.
PHPBB3-10965
Diffstat (limited to 'phpBB/includes/functions_profile_fields.php')
-rw-r--r-- | phpBB/includes/functions_profile_fields.php | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 16c193c15a..5391b781fa 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -122,7 +122,7 @@ class custom_profile case FIELD_BOOL: $field_value = (bool) $field_value; - + if (!$field_value && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -134,7 +134,7 @@ class custom_profile { return false; } - + $field_value = (int) $field_value; if ($field_value < $field_data['field_minlen']) @@ -521,7 +521,7 @@ class custom_profile switch ($this->profile_types[$field_type]) { case 'int': - if ($value === '') + if ($value === '' && !$ident_ary['data']['field_show_novalue']) { return NULL; } @@ -530,7 +530,7 @@ class custom_profile case 'string': case 'text': - if (!$value) + if (!$value && !$ident_ary['data']['field_show_novalue']) { return NULL; } @@ -548,7 +548,7 @@ class custom_profile $month = (isset($date[1])) ? (int) $date[1] : 0; $year = (isset($date[2])) ? (int) $date[2] : 0; - if (!$day && !$month && !$year) + if (!$day && !$month && !$year && !$ident_ary['data']['field_show_novalue']) { return NULL; } @@ -571,12 +571,7 @@ class custom_profile $this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false); } - // If a dropdown field is required, users - // cannot choose the "no value" option. - // They must choose one of the other options. - // Therefore, here we treat a value equal to - // the "no value" as a lack of value, i.e. NULL. - if ($value == $ident_ary['data']['field_novalue'] && $ident_ary['data']['field_required']) + if ($value == $ident_ary['data']['field_novalue'] && !$ident_ary['data']['field_show_novalue']) { return NULL; } @@ -586,7 +581,14 @@ class custom_profile // User not having a value assigned if (!isset($this->options_lang[$field_id][$lang_id][$value])) { - return NULL; + if ($ident_ary['data']['field_show_novalue']) + { + $value = $ident_ary['data']['field_novalue']; + } + else + { + return NULL; + } } return $this->options_lang[$field_id][$lang_id][$value]; @@ -600,6 +602,11 @@ class custom_profile $this->get_option_lang($field_id, $lang_id, FIELD_BOOL, false); } + if (!$value && $ident_ary['data']['field_show_novalue']) + { + $value = $ident_ary['data']['field_default_value']; + } + if ($ident_ary['data']['field_length'] == 1) { return (isset($this->options_lang[$field_id][$lang_id][(int) $value])) ? $this->options_lang[$field_id][$lang_id][(int) $value] : NULL; |