From a823205403f2dbbd907c03e59fd232552351d566 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Feb 2014 11:05:48 +0100 Subject: [PATCH] [ticket/12233] Allow profile fields to be contact fields Contact fields are displayed with in the contact section of the user profile and are displayed differently in the mini profile next to posts and private messages PHPBB3-12233 --- phpBB/adm/style/acp_profile.html | 6 +++ phpBB/includes/acp/acp_profile.php | 26 +++++++--- phpBB/includes/db/schema_data.php | 3 ++ phpBB/install/schemas/firebird_schema.sql | 5 +- phpBB/install/schemas/mssql_schema.sql | 5 +- phpBB/install/schemas/mysql_40_schema.sql | 3 ++ phpBB/install/schemas/mysql_41_schema.sql | 3 ++ phpBB/install/schemas/oracle_schema.sql | 3 ++ phpBB/install/schemas/postgres_schema.sql | 3 ++ phpBB/install/schemas/sqlite_schema.sql | 5 +- phpBB/language/en/acp/profile.php | 4 ++ .../data/v310/profilefield_contact_field.php | 51 +++++++++++++++++++ phpBB/phpbb/profilefields/manager.php | 19 +++++++ .../prosilver/template/memberlist_view.html | 11 +++- .../template/ucp_pm_viewmessage.html | 11 +++- .../prosilver/template/viewtopic_body.html | 9 +++- .../subsilver2/template/memberlist_view.html | 10 ++++ .../subsilver2/template/viewtopic_body.html | 2 + 18 files changed, 166 insertions(+), 13 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_contact_field.php diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 04e6d9f12b..64bc3df09b 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -79,6 +79,12 @@

{L_HIDE_PROFILE_FIELD_EXPLAIN}
checked="checked" />
+
+

{L_FIELD_IS_CONTACT_EXPLAIN}
+
checked="checked" />
+
+
+
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 3a5298fb58..4d316d84e4 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -386,6 +386,9 @@ class acp_profile 'field_show_on_pm' => 0, 'field_show_on_vt' => 0, 'field_show_on_ml' => 0, + 'field_is_contact' => 0, + 'field_contact_desc'=> '', + 'field_contact_url' => '', 'lang_name' => utf8_normalize_nfc(request_var('field_ident', '', true)), 'lang_explain' => '', 'lang_default_value'=> '') @@ -396,7 +399,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_pm', 'field_show_on_vt', 'field_show_on_ml', 'field_required', 'field_show_novalue', '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_pm', 'field_show_on_vt', 'field_show_on_ml', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view', 'field_is_contact', 'field_contact_desc', 'field_contact_url'), 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') ); @@ -411,21 +414,24 @@ class acp_profile 'field_show_on_ml', 'field_show_profile', 'field_hide', + 'field_is_contact', ); $options = $profile_field->prepare_options_form($exclude, $visibility_ary); $cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']); - $cp->vars['lang_name'] = utf8_normalize_nfc(request_var('lang_name', $field_row['lang_name'], true)); - $cp->vars['lang_explain'] = utf8_normalize_nfc(request_var('lang_explain', $field_row['lang_explain'], true)); - $cp->vars['lang_default_value'] = utf8_normalize_nfc(request_var('lang_default_value', $field_row['lang_default_value'], true)); + $cp->vars['lang_name'] = $request->variable('lang_name', $field_row['lang_name'], true); + $cp->vars['lang_explain'] = $request->variable('lang_explain', $field_row['lang_explain'], true); + $cp->vars['lang_default_value'] = $request->variable('lang_default_value', $field_row['lang_default_value'], true); + $cp->vars['field_contact_desc'] = $request->variable('field_contact_desc', $field_row['field_contact_desc'], true); + $cp->vars['field_contact_url'] = $request->variable('field_contact_url', $field_row['field_contact_url'], true); foreach ($visibility_ary as $val) { - $cp->vars[$val] = ($submit || $save) ? request_var($val, 0) : $field_row[$val]; + $cp->vars[$val] = ($submit || $save) ? $request->variable($val, 0) : $field_row[$val]; } - $cp->vars['field_no_view'] = request_var('field_no_view', (int) $field_row['field_no_view']); + $cp->vars['field_no_view'] = $request->variable('field_no_view', (int) $field_row['field_no_view']); // If the user has submitted a form with options (i.e. dropdown field) if ($options) @@ -626,6 +632,9 @@ class acp_profile 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, 'S_SHOW_PROFILE' => ($cp->vars['field_show_profile']) ? true : false, 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, + 'S_FIELD_CONTACT' => $cp->vars['field_is_contact'], + 'FIELD_CONTACT_DESC'=> $cp->vars['field_contact_desc'], + 'FIELD_CONTACT_URL' => $cp->vars['field_contact_url'], 'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']), 'FIELD_TYPE' => $profile_field->get_name(), @@ -886,7 +895,10 @@ class acp_profile 'field_show_on_ml' => $cp->vars['field_show_on_ml'], 'field_hide' => $cp->vars['field_hide'], 'field_show_profile' => $cp->vars['field_show_profile'], - 'field_no_view' => $cp->vars['field_no_view'] + 'field_no_view' => $cp->vars['field_no_view'], + 'field_is_contact' => $cp->vars['field_is_contact'], + 'field_contact_desc' => $cp->vars['field_contact_desc'], + 'field_contact_url' => $cp->vars['field_contact_url'], ); if ($action == 'create') diff --git a/phpBB/includes/db/schema_data.php b/phpBB/includes/db/schema_data.php index 0447895433..2c45e8d194 100644 --- a/phpBB/includes/db/schema_data.php +++ b/phpBB/includes/db/schema_data.php @@ -777,6 +777,9 @@ $schema_data['phpbb_profile_fields'] = array( 'field_no_view' => array('BOOL', 0), 'field_active' => array('BOOL', 0), 'field_order' => array('UINT', 0), + 'field_is_contact' => array('BOOL', 0), + 'field_contact_desc' => array('VCHAR', ''), + 'field_contact_url' => array('VCHAR', ''), ), 'PRIMARY_KEY' => 'field_id', 'KEYS' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 263ebb4490..ea7153b643 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -926,7 +926,10 @@ CREATE TABLE phpbb_profile_fields ( field_hide INTEGER DEFAULT 0 NOT NULL, field_no_view INTEGER DEFAULT 0 NOT NULL, field_active INTEGER DEFAULT 0 NOT NULL, - field_order INTEGER DEFAULT 0 NOT NULL + field_order INTEGER DEFAULT 0 NOT NULL, + field_is_contact INTEGER DEFAULT 0 NOT NULL, + field_contact_desc VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + field_contact_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL );; ALTER TABLE phpbb_profile_fields ADD PRIMARY KEY (field_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 11309d67a5..1aa33508cc 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1132,7 +1132,10 @@ CREATE TABLE [phpbb_profile_fields] ( [field_hide] [int] DEFAULT (0) NOT NULL , [field_no_view] [int] DEFAULT (0) NOT NULL , [field_active] [int] DEFAULT (0) NOT NULL , - [field_order] [int] DEFAULT (0) NOT NULL + [field_order] [int] DEFAULT (0) NOT NULL , + [field_is_contact] [int] DEFAULT (0) NOT NULL , + [field_contact_desc] [varchar] (255) DEFAULT ('') NOT NULL , + [field_contact_url] [varchar] (255) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 16c26fac4a..37c5d14fab 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -664,6 +664,9 @@ CREATE TABLE phpbb_profile_fields ( field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + field_is_contact tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_contact_desc varbinary(255) DEFAULT '' NOT NULL, + field_contact_url varbinary(255) DEFAULT '' NOT NULL, PRIMARY KEY (field_id), KEY fld_type (field_type), KEY fld_ordr (field_order) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index b345e1f474..aa0cfd7c50 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -664,6 +664,9 @@ CREATE TABLE phpbb_profile_fields ( field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + field_is_contact tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_contact_desc varchar(255) DEFAULT '' NOT NULL, + field_contact_url varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (field_id), KEY fld_type (field_type), KEY fld_ordr (field_order) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index b819ba2c59..19439ba788 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1236,6 +1236,9 @@ CREATE TABLE phpbb_profile_fields ( field_no_view number(1) DEFAULT '0' NOT NULL, field_active number(1) DEFAULT '0' NOT NULL, field_order number(8) DEFAULT '0' NOT NULL, + field_is_contact number(1) DEFAULT '0' NOT NULL, + field_contact_desc varchar2(255) DEFAULT '' , + field_contact_url varchar2(255) DEFAULT '' , CONSTRAINT pk_phpbb_profile_fields PRIMARY KEY (field_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index be8af3c873..390bc0211d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -872,6 +872,9 @@ CREATE TABLE phpbb_profile_fields ( field_no_view INT2 DEFAULT '0' NOT NULL CHECK (field_no_view >= 0), field_active INT2 DEFAULT '0' NOT NULL CHECK (field_active >= 0), field_order INT4 DEFAULT '0' NOT NULL CHECK (field_order >= 0), + field_is_contact INT2 DEFAULT '0' NOT NULL CHECK (field_is_contact >= 0), + field_contact_desc varchar(255) DEFAULT '' NOT NULL, + field_contact_url varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (field_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 717b242a57..df8396f04c 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -644,7 +644,10 @@ CREATE TABLE phpbb_profile_fields ( field_hide INTEGER UNSIGNED NOT NULL DEFAULT '0', field_no_view INTEGER UNSIGNED NOT NULL DEFAULT '0', field_active INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_order INTEGER UNSIGNED NOT NULL DEFAULT '0' + field_order INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_is_contact INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_contact_desc varchar(255) NOT NULL DEFAULT '', + field_contact_url varchar(255) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type); diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php index 726a9bac82..0ea95c35ba 100644 --- a/phpBB/language/en/acp/profile.php +++ b/phpBB/language/en/acp/profile.php @@ -82,6 +82,8 @@ $lang = array_merge($lang, array( 'EVERYTHING_OK' => 'Everything OK', 'FIELD_BOOL' => 'Boolean (Yes/No)', + 'FIELD_CONTACT_DESC' => 'Contact description', + 'FIELD_CONTACT_URL' => 'Contact link', 'FIELD_DATE' => 'Date', 'FIELD_DESCRIPTION' => 'Field description', 'FIELD_DESCRIPTION_EXPLAIN' => 'The explanation for this field presented to the user.', @@ -90,6 +92,8 @@ $lang = array_merge($lang, array( 'FIELD_IDENT_ALREADY_EXIST' => 'The chosen field identification already exist. Please choose another name.', 'FIELD_IDENT_EXPLAIN' => 'The field identification is a name to identify the profile field within the database and the templates.', 'FIELD_INT' => 'Numbers', + 'FIELD_IS_CONTACT' => 'Display field as a contact field', + 'FIELD_IS_CONTACT_EXPLAIN' => 'Contact fields are displayed with in the contact section of the user profile and are displayed differently in the mini profile next to posts and private messages.', 'FIELD_LENGTH' => 'Length of input box', 'FIELD_NOT_FOUND' => 'Profile field not found.', 'FIELD_STRING' => 'Single text field', diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_contact_field.php b/phpBB/phpbb/db/migration/data/v310/profilefield_contact_field.php new file mode 100644 index 0000000000..c7617813eb --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_contact_field.php @@ -0,0 +1,51 @@ +db_tools->sql_column_exists($this->table_prefix . 'profile_fields', 'field_is_contact'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_on_memberlist', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_is_contact' => array('BOOL', 0), + 'field_contact_desc' => array('VCHAR', ''), + 'field_contact_url' => array('VCHAR', ''), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_is_contact', + 'field_contact_desc', + 'field_contact_url', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index ac2542a6d4..874d0a21e0 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -353,21 +353,40 @@ class manager continue; } + $field_desc = $this->user->lang($ident_ary['data']['field_contact_desc']); + if (strpos($field_desc, '%s') !== false) + { + $field_desc = sprintf($field_desc, $value); + } + $contact_url = ''; + if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false) + { + $contact_url = sprintf($ident_ary['data']['field_contact_url'], $value); + } + $tpl_fields['row'] += array( + 'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident, 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value, + 'PROFILE_' . strtoupper($ident) . '_CONTACT'=> $contact_url, + 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc, 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'], 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']), 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $this->user->lang($ident_ary['data']['lang_explain']), + 'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'], 'S_PROFILE_' . strtoupper($ident) => true, ); $tpl_fields['blockrow'][] = array( + 'PROFILE_FIELD_IDENT' => $ident, 'PROFILE_FIELD_VALUE' => $value, + 'PROFILE_FIELD_CONTACT' => $contact_url, + 'PROFILE_FIELD_DESC' => $field_desc, 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'], 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']), 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']), + 'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'], 'S_PROFILE_' . strtoupper($ident) => true, ); } diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 1c4b6be2d1..78aca39bdf 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -29,7 +29,11 @@
{L_USER_IS_INACTIVE}{L_COLON}
{USER_INACTIVE_REASON}
{L_AGE}{L_COLON}
{AGE}
{L_USERGROUPS}{L_COLON}
-
{custom_fields.PROFILE_FIELD_NAME}{L_COLON}
{custom_fields.PROFILE_FIELD_VALUE}
+ + +
{custom_fields.PROFILE_FIELD_NAME}{L_COLON}
{custom_fields.PROFILE_FIELD_VALUE}
+ +
 
{L_REMOVE_FRIEND}
@@ -64,6 +68,11 @@
{L_AIM}{L_COLON}
{L_SEND_AIM_MESSAGE}{USER_AIM}
{L_ICQ}{L_COLON}
{L_SEND_ICQ_MESSAGE}{USER_ICQ}
{L_JABBER}{L_COLON}
{L_SEND_JABBER_MESSAGE}
{L_JABBER}{L_COLON}
{USER_JABBER}
+ + +
{custom_fields.PROFILE_FIELD_NAME}{L_COLON}
{custom_fields.PROFILE_FIELD_DESC}
+ +
{PROFILE_FIELD1_NAME}{L_COLON}
{PROFILE_FIELD1_VALUE}
diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 3623489ccf..1aebec7887 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -27,7 +27,9 @@ -
{custom_fields.PROFILE_FIELD_NAME}{L_COLON} {custom_fields.PROFILE_FIELD_VALUE}
+ +
{custom_fields.PROFILE_FIELD_NAME}{L_COLON} {custom_fields.PROFILE_FIELD_VALUE}
+ @@ -35,6 +37,7 @@
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index d5c45e1dfe..15150ce023 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -137,7 +137,9 @@ -
{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
+ +
{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
+ @@ -153,6 +155,11 @@
  • {L_YIM}
  • {L_AIM}
  • {L_JABBER}
  • + + +
  • {postrow.custom_fields.PROFILE_FIELD_NAME}
  • + + diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 40d61dddd9..31b274d96f 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -138,6 +138,14 @@ {L_JABBER}{L_COLON} {JABBER_IMG}{USER_JABBER_IMG} + + + + {custom_fields.PROFILE_FIELD_NAME}{L_COLON} + {custom_fields.PROFILE_FIELD_VALUE} + + + @@ -164,10 +172,12 @@ + {custom_fields.PROFILE_FIELD_NAME}{L_COLON} {custom_fields.PROFILE_FIELD_VALUE} + diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 9ba71d78bc..251983761c 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -210,7 +210,9 @@ +
    {postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE} +