[ticket/12334] Implemented get_profile_valueid method

PHPBB3-12334
This commit is contained in:
PayBas 2014-04-29 16:16:19 +02:00 committed by Shitiz Garg
parent 4169fd65f0
commit 507eca319d
7 changed files with 84 additions and 1 deletions

View file

@ -389,7 +389,7 @@ class manager
{
$profile_field = $this->type_collection[$ident_ary['data']['field_type']];
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
$valueid = (!$ident_ary['value'] && !$ident_ary['data']['field_show_novalue']) ? $ident_ary['data']['field_novalue'] : $ident_ary['value'];
$valueid = $profile_field->get_profile_valueid($ident_ary['value'], $ident_ary['data']);
if ($value === null)
{

View file

@ -177,6 +177,24 @@ class type_bool extends type_base
}
}
/**
* {@inheritDoc}
*/
public function get_profile_valueid($field_value, $field_data)
{
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
{
return null;
}
if (!$field_value && $field_data['field_show_novalue'])
{
$field_value = $field_data['field_novalue'];
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View file

@ -205,6 +205,19 @@ class type_date extends type_base
return $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_valueid($field_value, $field_data)
{
if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
{
return null;
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View file

@ -186,6 +186,24 @@ class type_dropdown extends type_base
return $this->lang_helper->get($field_id, $lang_id, $field_value);
}
/**
* {@inheritDoc}
*/
public function get_profile_valueid($field_value, $field_data)
{
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
{
return null;
}
if (!$field_value && $field_data['field_show_novalue'])
{
$field_value = $field_data['field_novalue'];
}
return $field_value;
}
/**
* {@inheritDoc}
*/

View file

@ -151,6 +151,18 @@ class type_int extends type_base
return (int) $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_valueid($field_value, $field_data)
{
if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
{
return null;
}
return (int) $field_value;
}
/**
* {@inheritDoc}
*/

View file

@ -93,6 +93,15 @@ interface type_interface
*/
public function get_profile_value($field_value, $field_data);
/**
* Get Profile Value ID for display (the raw, unprocessed user data)
*
* @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 ID to display
*/
public function get_profile_valueid($field_value, $field_data);
/**
* Get Profile Value for display
*

View file

@ -109,6 +109,19 @@ abstract class type_string_common extends type_base
return $field_value;
}
/**
* {@inheritDoc}
*/
public function get_profile_valueid($field_value, $field_data)
{
if (!$field_value && !$field_data['field_show_novalue'])
{
return null;
}
return $field_value;
}
/**
* {@inheritDoc}
*/