aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-03-09 05:24:03 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-03-09 05:24:03 -0500
commitbd1fb91dd2245c0b84d5857b3633ea4ad65545db (patch)
tree1109e56aef5c1db6d6d4b9d30c55eaf539e55bb7 /phpBB/includes/acp
parent0ec8e9dbff7d71e9a60ec8de8a15ba8f28ccdc04 (diff)
parentf832f5a4ee88459dae6fda7e1b303b15f84768dc (diff)
downloadforums-bd1fb91dd2245c0b84d5857b3633ea4ad65545db.tar
forums-bd1fb91dd2245c0b84d5857b3633ea4ad65545db.tar.gz
forums-bd1fb91dd2245c0b84d5857b3633ea4ad65545db.tar.bz2
forums-bd1fb91dd2245c0b84d5857b3633ea4ad65545db.tar.xz
forums-bd1fb91dd2245c0b84d5857b3633ea4ad65545db.zip
Merge remote-tracking branch 'rxu/ticket/9831' into develop-olympus
* rxu/ticket/9831: [ticket/9831] Fix saving unchecked checkbox field value [ticket/9831] Correctly store checkbox default value for boolean CPF.
Diffstat (limited to 'phpBB/includes/acp')
-rw-r--r--phpBB/includes/acp/acp_profile.php35
1 files changed, 31 insertions, 4 deletions
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 2e43b0545a..a591474fce 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -504,11 +504,34 @@ class acp_profile
}
}
}
- /* else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
+ else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
{
- // Get the number of options if this key is 'field_maxlen'
- $var = request_var('field_default_value', 0);
- }*/
+ // 'field_length' == 1 defines radio buttons. Possible values are 1 or 2 only.
+ // 'field_length' == 2 defines checkbox. Possible values are 0 or 1 only.
+ // If we switch the type on step 2, we have to adjust field value.
+ // 1 is a common value for the checkbox and radio buttons.
+
+ // Adjust unchecked checkbox value.
+ // If we return or save settings from 2nd/3rd page
+ // and the checkbox is unchecked, set the value to 0.
+ if (isset($_REQUEST['step']) && !isset($_REQUEST[$key]))
+ {
+ $var = 0;
+ }
+
+ // If we switch to the checkbox type but former radio buttons value was 2,
+ // which is not the case for the checkbox, set it to 0 (unchecked).
+ if ($cp->vars['field_length'] == 2 && $var == 2)
+ {
+ $var = 0;
+ }
+ // If we switch to the radio buttons but the former checkbox value was 0,
+ // which is not the case for the radio buttons, set it to 0.
+ else if ($cp->vars['field_length'] == 1 && $var == 0)
+ {
+ $var = 2;
+ }
+ }
else if ($field_type == FIELD_INT && $key == 'field_default_value')
{
// Permit an empty string
@@ -676,6 +699,10 @@ class acp_profile
{
$_new_key_ary[$key] = utf8_normalize_nfc(request_var($key, array(array('')), true));
}
+ else if ($field_type == FIELD_BOOL && $key == 'field_default_value')
+ {
+ $_new_key_ary[$key] = request_var($key, $cp->vars[$key]);
+ }
else
{
if (!isset($_REQUEST[$key]))