[ticket/12187] Do not make clickable when using as contact field

PHPBB3-12187
This commit is contained in:
Joas Schilling 2014-03-04 09:10:57 +01:00
parent c650078904
commit 03ef39c1f1
6 changed files with 54 additions and 28 deletions

View file

@ -1592,7 +1592,7 @@ switch ($mode)
$cp_row = array(); $cp_row = array();
if ($config['load_cpf_memberlist']) 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( $memberrow = array_merge(show_profile($row), array(

View file

@ -337,12 +337,14 @@ class manager
} }
/** /**
* Assign the user's profile fields data to the template * Assign the user's profile fields data to the template
* *
* @param array $profile_row Array with users profile field data * @param array $profile_row Array with users profile field data
* @return array * @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)
public function generate_profile_fields_template_data($profile_row) * @return array
*/
public function generate_profile_fields_template_data($profile_row, $use_contact_fields = true)
{ {
// $profile_row == $user_fields[$row['user_id']]; // $profile_row == $user_fields[$row['user_id']];
$tpl_fields = array(); $tpl_fields = array();
@ -358,15 +360,20 @@ class manager
continue; continue;
} }
$field_desc = $this->user->lang($ident_ary['data']['field_contact_desc']); $field_desc = $contact_url = '';
if (strpos($field_desc, '%s') !== false) if ($use_contact_fields)
{ {
$field_desc = sprintf($field_desc, $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']);
$contact_url = ''; if (strpos($field_desc, '%s') !== false)
if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false) {
{ $field_desc = sprintf($field_desc, $value);
$contact_url = sprintf($ident_ary['data']['field_contact_url'], $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( $tpl_fields['row'] += array(

View file

@ -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; 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} * {@inheritDoc}
*/ */

View file

@ -89,6 +89,17 @@ interface type_interface
*/ */
public function get_profile_value($field_value, $field_data); 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 * Generate the input field for display
* *

View file

@ -102,6 +102,19 @@ abstract class type_string_common extends type_base
return $field_value; 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} * {@inheritDoc}
*/ */

View file

@ -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} * {@inheritDoc}
*/ */