aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2012-07-17 18:48:10 +0200
committerNils Adermann <naderman@naderman.de>2012-07-23 15:45:57 +0200
commit10172887fd47e86eefbabd6f5e755cd93279960d (patch)
tree307f50b083a62a9b097202c50085d63da7ec6959
parent55aaa596d72c8eef54f394da22f43bdf731d9333 (diff)
downloadforums-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
-rw-r--r--phpBB/adm/style/acp_profile.html4
-rw-r--r--phpBB/develop/create_schema_files.php1
-rw-r--r--phpBB/includes/acp/acp_profile.php6
-rw-r--r--phpBB/includes/functions_profile_fields.php31
-rw-r--r--phpBB/install/database_update.php8
-rw-r--r--phpBB/install/schemas/firebird_schema.sql1
-rw-r--r--phpBB/install/schemas/mssql_schema.sql1
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql1
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql1
-rw-r--r--phpBB/install/schemas/oracle_schema.sql1
-rw-r--r--phpBB/install/schemas/postgres_schema.sql1
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql1
-rw-r--r--phpBB/language/en/acp/profile.php2
13 files changed, 46 insertions, 13 deletions
diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html
index 85d37568c2..1c9c038f8f 100644
--- a/phpBB/adm/style/acp_profile.html
+++ b/phpBB/adm/style/acp_profile.html
@@ -64,6 +64,10 @@
<dd><input type="checkbox" class="radio" id="field_required" name="field_required" value="1"<!-- IF S_FIELD_REQUIRED --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
+ <dt><label for="field_show_novalue">{L_SHOW_NOVALUE_FIELD}:</label><br /><span>{L_SHOW_NOVALUE_FIELD_EXPLAIN}</span></dt>
+ <dd><input type="checkbox" class="radio" id="field_show_novalue" name="field_show_novalue" value="1"<!-- IF S_FIELD_SHOW_NOVALUE --> checked="checked"<!-- ENDIF --> /></dd>
+ </dl>
+ <dl>
<dt><label for="field_hide">{L_HIDE_PROFILE_FIELD}:</label><br /><span>{L_HIDE_PROFILE_FIELD_EXPLAIN}</span></dt>
<dd><input type="checkbox" class="radio" id="field_hide" name="field_hide" value="1"<!-- IF S_FIELD_HIDE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index d44efb8870..496ac22e90 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1448,6 +1448,7 @@ function get_schema_struct()
'field_default_value' => array('VCHAR_UNI', ''),
'field_validation' => array('VCHAR_UNI:20', ''),
'field_required' => array('BOOL', 0),
+ 'field_show_novalue' => array('BOOL', 0),
'field_show_on_reg' => array('BOOL', 0),
'field_show_on_vt' => array('BOOL', 0),
'field_show_profile' => array('BOOL', 0),
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index a591474fce..19223847f0 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -365,6 +365,7 @@ class acp_profile
$field_row = array_merge($default_values[$field_type], array(
'field_ident' => str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),
'field_required' => 0,
+ 'field_show_novalue'=> 0,
'field_hide' => 0,
'field_show_profile'=> 0,
'field_no_view' => 0,
@@ -380,7 +381,7 @@ class acp_profile
// $exclude contains the data we gather in each step
$exclude = array(
- 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'),
+ 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_vt', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view'),
2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'),
3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
);
@@ -405,6 +406,7 @@ class acp_profile
// Visibility Options...
$visibility_ary = array(
'field_required',
+ 'field_show_novalue',
'field_show_on_reg',
'field_show_on_vt',
'field_show_profile',
@@ -757,6 +759,7 @@ class acp_profile
$template->assign_vars(array(
'S_STEP_ONE' => true,
'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false,
+ 'S_FIELD_SHOW_NOVALUE'=> ($cp->vars['field_show_novalue']) ? true : false,
'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false,
'S_SHOW_ON_VT' => ($cp->vars['field_show_on_vt']) ? true : false,
'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false,
@@ -1073,6 +1076,7 @@ class acp_profile
'field_default_value' => $cp->vars['field_default_value'],
'field_validation' => $cp->vars['field_validation'],
'field_required' => $cp->vars['field_required'],
+ 'field_show_novalue' => $cp->vars['field_show_novalue'],
'field_show_on_reg' => $cp->vars['field_show_on_reg'],
'field_show_on_vt' => $cp->vars['field_show_on_vt'],
'field_hide' => $cp->vars['field_hide'],
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;
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index c1fe144c62..2901bc76ee 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -995,6 +995,14 @@ function database_update_info()
'3.0.10-RC3' => array(),
// No changes from 3.0.10 to 3.0.11-RC1
'3.0.10' => array(),
+ // Changes from 3.0.11-RC1 to 3.0.11-RC2
+ '3.0.5' => array(
+ 'add_columns' => array(
+ PROFILE_FIELDS_TABLE => array(
+ 'field_show_novalue' => array('BOOL', 0),
+ ),
+ ),
+ ),
/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */
);
diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql
index 73052f0a22..eae692f529 100644
--- a/phpBB/install/schemas/firebird_schema.sql
+++ b/phpBB/install/schemas/firebird_schema.sql
@@ -807,6 +807,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
field_required INTEGER DEFAULT 0 NOT NULL,
+ field_show_novalue INTEGER DEFAULT 0 NOT NULL,
field_show_on_reg INTEGER DEFAULT 0 NOT NULL,
field_show_on_vt INTEGER DEFAULT 0 NOT NULL,
field_show_profile INTEGER DEFAULT 0 NOT NULL,
diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql
index 8ed3ba7e12..0b2f8368de 100644
--- a/phpBB/install/schemas/mssql_schema.sql
+++ b/phpBB/install/schemas/mssql_schema.sql
@@ -974,6 +974,7 @@ CREATE TABLE [phpbb_profile_fields] (
[field_default_value] [varchar] (255) DEFAULT ('') NOT NULL ,
[field_validation] [varchar] (20) DEFAULT ('') NOT NULL ,
[field_required] [int] DEFAULT (0) NOT NULL ,
+ [field_show_novalue] [int] DEFAULT (0) NOT NULL ,
[field_show_on_reg] [int] DEFAULT (0) NOT NULL ,
[field_show_on_vt] [int] DEFAULT (0) NOT NULL ,
[field_show_profile] [int] DEFAULT (0) NOT NULL ,
diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index 42b7291d9d..969cbe0472 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -571,6 +571,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value blob NOT NULL,
field_validation varbinary(60) DEFAULT '' NOT NULL,
field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 7a6d0ae188..15d34894d8 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -571,6 +571,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) DEFAULT '' NOT NULL,
field_validation varchar(20) DEFAULT '' NOT NULL,
field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index 6e7ec31efc..af7b2b60ec 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -1085,6 +1085,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar2(765) DEFAULT '' ,
field_validation varchar2(60) DEFAULT '' ,
field_required number(1) DEFAULT '0' NOT NULL,
+ field_show_novalue number(1) DEFAULT '0' NOT NULL,
field_show_on_reg number(1) DEFAULT '0' NOT NULL,
field_show_on_vt number(1) DEFAULT '0' NOT NULL,
field_show_profile number(1) DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index 38f167bc7b..0a05a7cd75 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -761,6 +761,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) DEFAULT '' NOT NULL,
field_validation varchar(20) DEFAULT '' NOT NULL,
field_required INT2 DEFAULT '0' NOT NULL CHECK (field_required >= 0),
+ field_show_novalue INT2 DEFAULT '0' NOT NULL CHECK (field_show_novalue >= 0),
field_show_on_reg INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_reg >= 0),
field_show_on_vt INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_vt >= 0),
field_show_profile INT2 DEFAULT '0' NOT NULL CHECK (field_show_profile >= 0),
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index c0574244ca..be7faa4688 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -554,6 +554,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) NOT NULL DEFAULT '',
field_validation varchar(20) NOT NULL DEFAULT '',
field_required INTEGER UNSIGNED NOT NULL DEFAULT '0',
+ field_show_novalue INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_on_reg INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_on_vt INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_profile INTEGER UNSIGNED NOT NULL DEFAULT '0',
diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php
index a25dcd174b..e193d9303c 100644
--- a/phpBB/language/en/acp/profile.php
+++ b/phpBB/language/en/acp/profile.php
@@ -131,6 +131,8 @@ $lang = array_merge($lang, array(
'SAVE' => 'Save',
'SECOND_OPTION' => 'Second option',
+ 'SHOW_NOVALUE_FIELD' => 'Show field if no value was selected',
+ 'SHOW_NOVALUE_FIELD_EXPLAIN' => 'Determines if the profile field should be displayed if no value was selected for optional fields or if no value has been selected yet for required fields.',
'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. This information is needed for the second step where you’ll be able to set remaining options and tweak your profile field further.',
'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step.',
'STEP_1_TITLE_CREATE' => 'Add profile field',