mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 22:38:52 +00:00
[ticket/11201] Remove type related code from build_insert_sql_array()
PHPBB3-11201
This commit is contained in:
parent
daf21fcb30
commit
d601aaad26
10 changed files with 71 additions and 21 deletions
|
@ -372,7 +372,7 @@ class acp_profile
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile_field = $phpbb_container->get('profilefields.type.' . $cp->profile_types[$field_type]);
|
$profile_field = $phpbb_container->get('profilefields.type.' . $cp->profile_types[$field_type]);
|
||||||
$field_row = array_merge($profile_field->get_default_values(), array(
|
$field_row = array_merge($profile_field->get_default_option_values(), array(
|
||||||
'field_ident' => str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),
|
'field_ident' => str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),
|
||||||
'field_required' => 0,
|
'field_required' => 0,
|
||||||
'field_show_novalue'=> 0,
|
'field_show_novalue'=> 0,
|
||||||
|
|
|
@ -408,18 +408,8 @@ class profilefields
|
||||||
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE)
|
$profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]);
|
||||||
{
|
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_default_field_value($row);
|
||||||
$now = getdate();
|
|
||||||
$row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
|
||||||
}
|
|
||||||
else if ($row['field_default_value'] === '' && $row['field_type'] == FIELD_INT)
|
|
||||||
{
|
|
||||||
// We cannot insert an empty string into an integer column.
|
|
||||||
$row['field_default_value'] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
|
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class type_bool implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => 1,
|
'field_length' => 1,
|
||||||
|
@ -63,6 +63,14 @@ class type_bool implements type_interface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data)
|
||||||
|
{
|
||||||
|
return $field_data['field_default_value'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,7 +59,7 @@ class type_date implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => 10,
|
'field_length' => 10,
|
||||||
|
@ -71,6 +71,20 @@ class type_date implements type_interface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data)
|
||||||
|
{
|
||||||
|
if ($field_data['field_default_value'] == 'now')
|
||||||
|
{
|
||||||
|
$now = getdate();
|
||||||
|
$field_data['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field_data['field_default_value'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,7 +55,7 @@ class type_dropdown implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => 0,
|
'field_length' => 0,
|
||||||
|
@ -67,6 +67,14 @@ class type_dropdown implements type_interface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data)
|
||||||
|
{
|
||||||
|
return $field_data['field_default_value'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,7 +39,7 @@ class type_int implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => 5,
|
'field_length' => 5,
|
||||||
|
@ -51,6 +51,20 @@ class type_int implements type_interface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data)
|
||||||
|
{
|
||||||
|
if ($field_data['field_default_value'] === '')
|
||||||
|
{
|
||||||
|
// We cannot insert an empty string into an integer column.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field_data['field_default_value'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,11 +31,19 @@ interface type_interface
|
||||||
public function get_options($default_lang_id, $field_data);
|
public function get_options($default_lang_id, $field_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default values for this type
|
* Get default values for the options of this type
|
||||||
*
|
*
|
||||||
* @return array with values like default field size and more
|
* @return array with values like default field size and more
|
||||||
*/
|
*/
|
||||||
public function get_default_values();
|
public function get_default_option_values();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default value for this type
|
||||||
|
*
|
||||||
|
* @param array $field_data Array with data for this field
|
||||||
|
* @return mixed default value for new users when no value is given
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get profile field value on submit
|
* Get profile field value on submit
|
||||||
|
|
|
@ -39,7 +39,7 @@ class type_string extends type_string_common implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => 10,
|
'field_length' => 10,
|
||||||
|
|
|
@ -28,6 +28,14 @@ abstract class type_string_common
|
||||||
return $validate_options;
|
return $validate_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_default_field_value($field_data)
|
||||||
|
{
|
||||||
|
return $field_data['lang_default_value'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate entered profile field data
|
* Validate entered profile field data
|
||||||
*
|
*
|
||||||
|
|
|
@ -39,7 +39,7 @@ class type_text extends type_string_common implements type_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function get_default_values()
|
public function get_default_option_values()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'field_length' => '5|80',
|
'field_length' => '5|80',
|
||||||
|
|
Loading…
Add table
Reference in a new issue