diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index a05a0999dc..7d64ad8125 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1592,7 +1592,7 @@ switch ($mode) $cp_row = array(); if ($config['load_cpf_memberlist']) { - $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id]) : array(); + $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id], false) : array(); } $memberrow = array_merge(show_profile($row), array( 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 = $contact_url = ''; + if ($use_contact_fields) { - $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); + $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} */