diff options
author | Maat <maat-pub@mageia.biz> | 2012-06-03 21:23:14 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2012-06-03 21:23:14 +0200 |
commit | a06a38ae692551dc1c0416b835ce9924b3d9f7f5 (patch) | |
tree | 1bb2c2b3d8d56668585513890afc1d641cead0b1 /phpBB/includes/functions_profile_fields.php | |
parent | 2db884ac2e5122be1db0582b76bf7204783a0c0d (diff) | |
parent | 19a47dfbbc4265e33c14d6679b5693d80120db4b (diff) | |
download | forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.gz forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.bz2 forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.xz forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.zip |
Merging with upstream 3.0.11
Diffstat (limited to 'phpBB/includes/functions_profile_fields.php')
-rw-r--r-- | phpBB/includes/functions_profile_fields.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 78fe049f40..16c193c15a 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -149,7 +149,18 @@ class custom_profile case FIELD_DROPDOWN: $field_value = (int) $field_value; - + + // retrieve option lang data if necessary + if (!isset($this->options_lang[$field_data['field_id']]) || !isset($this->options_lang[$field_data['field_id']][$field_data['lang_id']]) || !sizeof($this->options_lang[$file_data['field_id']][$field_data['lang_id']])) + { + $this->get_option_lang($field_data['field_id'], $field_data['lang_id'], FIELD_DROPDOWN, false); + } + + if (!isset($this->options_lang[$field_data['field_id']][$field_data['lang_id']][$field_value])) + { + return 'FIELD_INVALID_VALUE'; + } + if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -302,6 +313,7 @@ class custom_profile switch ($cp_result) { case 'FIELD_INVALID_DATE': + case 'FIELD_INVALID_VALUE': case 'FIELD_REQUIRED': $error = sprintf($user->lang[$cp_result], $row['lang_name']); break; @@ -559,7 +571,12 @@ class custom_profile $this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false); } - if ($value == $ident_ary['data']['field_novalue']) + // 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']) { return NULL; } @@ -613,10 +630,10 @@ class custom_profile $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; $user_ident = $profile_row['field_ident']; - // checkbox - only testing for isset + // checkbox - set the value to "true" if it has been set to 1 if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2) { - $value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]); + $value = (isset($_REQUEST[$profile_row['field_ident']]) && request_var($profile_row['field_ident'], $default_value) == 1) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]); } else if ($profile_row['field_type'] == FIELD_INT) { |