From a823205403f2dbbd907c03e59fd232552351d566 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Feb 2014 11:05:48 +0100 Subject: [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 --- .../data/v310/profilefield_contact_field.php | 51 ++++++++++++++++++++++ phpBB/phpbb/profilefields/manager.php | 19 ++++++++ 2 files changed, 70 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_contact_field.php (limited to 'phpBB/phpbb') 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, ); } -- cgit v1.2.1 From 76409388afcd6389b5a29bc54b49faaf6bc4b4a5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Feb 2014 15:11:17 +0100 Subject: [ticket/12234] Replace ICQ with custom profile field PHPBB3-12234 --- .../db/migration/data/v310/profilefield_icq.php | 50 ++++++++++++++++++++++ .../data/v310/profilefield_icq_cleanup.php | 47 ++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_icq.php create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_icq_cleanup.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_icq.php b/phpBB/phpbb/db/migration/data/v310/profilefield_icq.php new file mode 100644 index 0000000000..0b8344333a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_icq.php @@ -0,0 +1,50 @@ + 'phpbb_icq', + 'field_type' => 'profilefields.type.string', + 'field_ident' => 'phpbb_icq', + 'field_length' => '20', + 'field_minlen' => '3', + 'field_maxlen' => '15', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '[0-9]+', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 1, + 'field_show_on_vt' => 1, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + 'field_is_contact' => 1, + 'field_contact_desc' => 'SEND_ICQ_MESSAGE', + 'field_contact_url' => 'https://www.icq.com/people/%s/', + ); + + protected $user_column_name = 'user_icq'; +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_icq_cleanup.php b/phpBB/phpbb/db/migration/data/v310/profilefield_icq_cleanup.php new file mode 100644 index 0000000000..c073b191a1 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_icq_cleanup.php @@ -0,0 +1,47 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_icq'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_icq', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_icq', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_icq' => array('VCHAR:20', ''), + ), + ), + ); + } +} -- cgit v1.2.1 From a2f2629e2a5038aca372cc3e55c408a99b6ca6fc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Feb 2014 23:02:54 +0100 Subject: [ticket/12187] Add URL type for profile fields PHPBB3-12187 --- phpBB/phpbb/profilefields/type/type_int.php | 2 +- phpBB/phpbb/profilefields/type/type_string.php | 2 +- phpBB/phpbb/profilefields/type/type_url.php | 83 ++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 phpBB/phpbb/profilefields/type/type_url.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index 267f522d5d..c98c863e13 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -61,7 +61,7 @@ class type_int extends type_base 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => ''), 1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => ''), 2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => ''), - 3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => ''), + 3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => ''), ); return $options; diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php index 9d241c49ef..9dada592eb 100644 --- a/phpBB/phpbb/profilefields/type/type_string.php +++ b/phpBB/phpbb/profilefields/type/type_string.php @@ -109,7 +109,7 @@ class type_string extends type_string_common $default_value = $profile_row['lang_default_value']; $profile_row['field_value'] = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value, true) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]); - $this->template->assign_block_vars('string', array_change_key_case($profile_row, CASE_UPPER)); + $this->template->assign_block_vars($this->get_name_short(), array_change_key_case($profile_row, CASE_UPPER)); } /** diff --git a/phpBB/phpbb/profilefields/type/type_url.php b/phpBB/phpbb/profilefields/type/type_url.php new file mode 100644 index 0000000000..08f976cf4b --- /dev/null +++ b/phpBB/phpbb/profilefields/type/type_url.php @@ -0,0 +1,83 @@ + array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => ''), + 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), + 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), + ); + + return $options; + } + + /** + * {@inheritDoc} + */ + public function get_default_option_values() + { + return array( + 'field_length' => 40, + 'field_minlen' => 0, + 'field_maxlen' => 200, + 'field_validation' => '', + 'field_novalue' => '', + 'field_default_value' => '', + ); + } + + /** + * {@inheritDoc} + */ + public function get_profile_value($field_value, $field_data) + { + if (!$field_value && !$field_data['field_show_novalue']) + { + return null; + } + + return $field_value; + } + + /** + * {@inheritDoc} + */ + public function validate_profile_field(&$field_value, $field_data) + { + $field_value = trim($field_value); + + if ($field_value === '' && !$field_data['field_required']) + { + return false; + } + + if (!preg_match('#^' . get_preg_expression('url') . '$#i', $field_value)) + { + return $this->user->lang('FIELD_INVALID_URL', $this->get_field_name($field_data['lang_name'])); + } + + return false; + } +} -- cgit v1.2.1 From e750d71f840e0c2e8fe802c5cc593c0630746291 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 3 Mar 2014 12:38:55 +0100 Subject: [ticket/12187] Convert website field data to custom profile field PHPBB3-12187 --- .../migration/data/v310/profilefield_website.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_website.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_website.php b/phpBB/phpbb/db/migration/data/v310/profilefield_website.php new file mode 100644 index 0000000000..818b66d2e4 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_website.php @@ -0,0 +1,52 @@ + 'phpbb_website', + 'field_type' => 'profilefields.type.url', + 'field_ident' => 'phpbb_website', + 'field_length' => '40', + 'field_minlen' => '12', + 'field_maxlen' => '255', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 1, + 'field_show_on_vt' => 1, + 'field_show_on_ml' => 1, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + 'field_is_contact' => 1, + 'field_contact_desc' => 'VISIT_WEBSITE', + 'field_contact_url' => '%s', + ); + + protected $user_column_name = 'user_website'; +} -- cgit v1.2.1 From a3627a9ff767631121c70a00ca17d99a3533ad31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Mar 2014 08:25:36 +0100 Subject: [ticket/12187] Remove user_website field PHPBB3-12187 --- .../data/v310/profilefield_website_cleanup.php | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_website_cleanup.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_website_cleanup.php b/phpBB/phpbb/db/migration/data/v310/profilefield_website_cleanup.php new file mode 100644 index 0000000000..9a4d724347 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_website_cleanup.php @@ -0,0 +1,47 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_website'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_website', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_website', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_website' => array('VCHAR_UNI:200', ''), + ), + ), + ); + } +} -- cgit v1.2.1 From c650078904e41c9dd468b329131ace2fcbd8d1f9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Mar 2014 08:47:47 +0100 Subject: [ticket/12187] Split generate_profile_fields_template() into 2 methods Removing the mode switch that wraps the content of the method PHPBB3-12187 --- phpBB/phpbb/profilefields/manager.php | 192 +++++++++++++++++----------------- 1 file changed, 96 insertions(+), 96 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 874d0a21e0..8b4a3917f2 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -278,125 +278,125 @@ class manager } /** - * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) - * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template + * Grab the user specific profile fields data + * + * @param int|array $user_ids Single user id or an array of ids + * @return array Users profile fields data */ - public function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false) + public function grab_profile_fields_data($user_ids = 0) { - if ($mode == 'grab') + if (!is_array($user_ids)) { - if (!is_array($user_id)) - { - $user_id = array($user_id); - } + $user_ids = array($user_ids); + } - if (!sizeof($this->profile_cache)) - { - $this->build_cache(); - } + if (!sizeof($this->profile_cache)) + { + $this->build_cache(); + } - if (!sizeof($user_id)) - { - return array(); - } + if (!sizeof($user_ids)) + { + return array(); + } - $sql = 'SELECT * - FROM ' . $this->fields_data_table . ' - WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_id)); - $result = $this->db->sql_query($sql); + $sql = 'SELECT * + FROM ' . $this->fields_data_table . ' + WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_ids)); + $result = $this->db->sql_query($sql); - $field_data = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $field_data[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); + $field_data = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $field_data[$row['user_id']] = $row; + } + $this->db->sql_freeresult($result); - $user_fields = array(); + $user_fields = array(); - $user_ids = $user_id; + // Go through the fields in correct order + foreach (array_keys($this->profile_cache) as $used_ident) + { + foreach ($field_data as $user_id => $row) + { + $user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident]; + $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident]; + } - // Go through the fields in correct order - foreach (array_keys($this->profile_cache) as $used_ident) + foreach ($user_ids as $user_id) { - foreach ($field_data as $user_id => $row) + if (!isset($user_fields[$user_id][$used_ident]) && $this->profile_cache[$used_ident]['field_show_novalue']) { - $user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident]; + $user_fields[$user_id][$used_ident]['value'] = ''; $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident]; } - - foreach ($user_ids as $user_id) - { - if (!isset($user_fields[$user_id][$used_ident]) && $this->profile_cache[$used_ident]['field_show_novalue']) - { - $user_fields[$user_id][$used_ident]['value'] = ''; - $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident]; - } - } } - - return $user_fields; } - else if ($mode == 'show') - { - // $profile_row == $user_fields[$row['user_id']]; - $tpl_fields = array(); - $tpl_fields['row'] = $tpl_fields['blockrow'] = array(); - foreach ($profile_row as $ident => $ident_ary) - { - $profile_field = $this->type_collection[$ident_ary['data']['field_type']]; - $value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']); + return $user_fields; + } - if ($value === null) - { - continue; - } + /** + * Assign the user's profile fields data to the template + * + * @param array $profile_row Array with users profile field data + * @return array + */ + public function generate_profile_fields_template_data($profile_row) + { + // $profile_row == $user_fields[$row['user_id']]; + $tpl_fields = array(); + $tpl_fields['row'] = $tpl_fields['blockrow'] = array(); - $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); - } + foreach ($profile_row as $ident => $ident_ary) + { + $profile_field = $this->type_collection[$ident_ary['data']['field_type']]; + $value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']); - $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, - ); + if ($value === null) + { + continue; } - return $tpl_fields; - } - else - { - trigger_error('Wrong mode for custom profile', E_USER_ERROR); + $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, + ); } + + return $tpl_fields; } /** -- cgit v1.2.1 From 03ef39c1f18584b331b5ddbd59e94848b8d3cd17 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Mar 2014 09:10:57 +0100 Subject: [ticket/12187] Do not make clickable when using as contact field PHPBB3-12187 --- phpBB/phpbb/profilefields/manager.php | 35 +++++++++++++--------- phpBB/phpbb/profilefields/type/type_base.php | 8 +++++ phpBB/phpbb/profilefields/type/type_interface.php | 11 +++++++ .../profilefields/type/type_string_common.php | 13 ++++++++ phpBB/phpbb/profilefields/type/type_url.php | 13 -------- 5 files changed, 53 insertions(+), 27 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 8b4a3917f2..a4626bc5de 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -337,12 +337,14 @@ class manager } /** - * Assign the user's profile fields data to the template - * - * @param array $profile_row Array with users profile field data - * @return array - */ - public function generate_profile_fields_template_data($profile_row) + * Assign the user's profile fields data to the template + * + * @param array $profile_row Array with users profile field data + * @param bool $use_contact_fields Should we display contact fields as such? + * This requires special treatments (links should not be parsed in the values, and more) + * @return array + */ + public function generate_profile_fields_template_data($profile_row, $use_contact_fields = true) { // $profile_row == $user_fields[$row['user_id']]; $tpl_fields = array(); @@ -358,15 +360,20 @@ 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) + $field_desc = $contact_url = ''; + if ($use_contact_fields) { - $contact_url = sprintf($ident_ary['data']['field_contact_url'], $value); + $value = $profile_field->get_profile_contact_value($ident_ary['value'], $ident_ary['data']); + $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( diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php index 9c363a7b4e..a96196674d 100644 --- a/phpBB/phpbb/profilefields/type/type_base.php +++ b/phpBB/phpbb/profilefields/type/type_base.php @@ -84,6 +84,14 @@ abstract class type_base implements type_interface return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name; } + /** + * {@inheritDoc} + */ + public function get_profile_contact_value($field_value, $field_data) + { + return $this->get_profile_value($field_value, $field_data); + } + /** * {@inheritDoc} */ diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 94f6882524..a1c3d879c8 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -89,6 +89,17 @@ interface type_interface */ public function get_profile_value($field_value, $field_data); + /** + * Get Profile Value for display + * + * When displaying a contact field, we don't want to have links already parsed and more + * + * @param mixed $field_value Field value as stored in the database + * @param array $field_data Array with requirements of the field + * @return mixed Field value to display + */ + public function get_profile_contact_value($field_value, $field_data); + /** * Generate the input field for display * diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index f00a7e6a08..d5fb8f4b97 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -102,6 +102,19 @@ abstract class type_string_common extends type_base return $field_value; } + /** + * {@inheritDoc} + */ + public function get_profile_contact_value($field_value, $field_data) + { + if (!$field_value && !$field_data['field_show_novalue']) + { + return null; + } + + return $field_value; + } + /** * {@inheritDoc} */ diff --git a/phpBB/phpbb/profilefields/type/type_url.php b/phpBB/phpbb/profilefields/type/type_url.php index 08f976cf4b..b1523b9355 100644 --- a/phpBB/phpbb/profilefields/type/type_url.php +++ b/phpBB/phpbb/profilefields/type/type_url.php @@ -48,19 +48,6 @@ class type_url extends type_string ); } - /** - * {@inheritDoc} - */ - public function get_profile_value($field_value, $field_data) - { - if (!$field_value && !$field_data['field_show_novalue']) - { - return null; - } - - return $field_value; - } - /** * {@inheritDoc} */ -- cgit v1.2.1 From 83a7e632b9b21fed88a3dbea679580d0740664f7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Mar 2014 10:19:08 +0100 Subject: [ticket/12235] Convert WLM to custom profile field PHPBB3-12235 --- .../db/migration/data/v310/profilefield_wlm.php | 51 ++++++++++++++++++++++ .../data/v310/profilefield_wlm_cleanup.php | 47 ++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_wlm.php create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_wlm_cleanup.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_wlm.php b/phpBB/phpbb/db/migration/data/v310/profilefield_wlm.php new file mode 100644 index 0000000000..8a42f1fea1 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_wlm.php @@ -0,0 +1,51 @@ + 'phpbb_wlm', + 'field_type' => 'profilefields.type.string', + 'field_ident' => 'phpbb_wlm', + 'field_length' => '40', + 'field_minlen' => '5', + 'field_maxlen' => '255', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '.*', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 1, + 'field_show_on_vt' => 1, + 'field_show_on_ml' => 0, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + 'field_is_contact' => 1, + 'field_contact_desc' => '', + 'field_contact_url' => '', + ); + + protected $user_column_name = 'user_msnm'; +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_wlm_cleanup.php b/phpBB/phpbb/db/migration/data/v310/profilefield_wlm_cleanup.php new file mode 100644 index 0000000000..ac03287121 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_wlm_cleanup.php @@ -0,0 +1,47 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_msnm'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_wlm', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm' => array('VCHAR_UNI', ''), + ), + ), + ); + } +} -- cgit v1.2.1