mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11201] Add database column type to type class
PHPBB3-11201
This commit is contained in:
parent
1dbc2d6218
commit
8e86e56120
9 changed files with 62 additions and 4 deletions
|
@ -26,6 +26,7 @@ services:
|
||||||
class: \phpbb\profilefields\type\type_bool
|
class: \phpbb\profilefields\type\type_bool
|
||||||
arguments:
|
arguments:
|
||||||
- @profilefields.lang_helper
|
- @profilefields.lang_helper
|
||||||
|
- @profilefields
|
||||||
- @request
|
- @request
|
||||||
- @template
|
- @template
|
||||||
- @user
|
- @user
|
||||||
|
@ -46,6 +47,7 @@ services:
|
||||||
class: \phpbb\profilefields\type\type_dropdown
|
class: \phpbb\profilefields\type\type_dropdown
|
||||||
arguments:
|
arguments:
|
||||||
- @profilefields.lang_helper
|
- @profilefields.lang_helper
|
||||||
|
- @profilefields
|
||||||
- @request
|
- @request
|
||||||
- @template
|
- @template
|
||||||
- @user
|
- @user
|
||||||
|
|
|
@ -339,7 +339,7 @@ class profilefields
|
||||||
* Return Templated value/field. Possible values for $mode are:
|
* Return Templated value/field. Possible values for $mode are:
|
||||||
* change == user is able to set/enter profile values; preview == just show the value
|
* change == user is able to set/enter profile values; preview == just show the value
|
||||||
*/
|
*/
|
||||||
protected function process_field_row($mode, $profile_row)
|
public function process_field_row($mode, $profile_row)
|
||||||
{
|
{
|
||||||
$preview_options = ($mode == 'preview') ? $this->vars['lang_options'] : false;
|
$preview_options = ($mode == 'preview') ? $this->vars['lang_options'] : false;
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,10 @@ class type_bool implements type_interface
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
|
public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\profilefields\profilefields $profilefields, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
|
||||||
{
|
{
|
||||||
$this->lang_helper = $lang_helper;
|
$this->lang_helper = $lang_helper;
|
||||||
|
$this->profilefields = $profilefields;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
@ -184,4 +185,12 @@ class type_bool implements type_interface
|
||||||
{
|
{
|
||||||
return ($field_data['field_length'] == '1') ? '' : 'pf_' . $field_data['field_ident'];
|
return ($field_data['field_length'] == '1') ? '' : 'pf_' . $field_data['field_ident'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'TINT:2';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,4 +232,12 @@ class type_date implements type_interface
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'VCHAR:10';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,10 @@ class type_dropdown implements type_interface
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
|
public function __construct(\phpbb\profilefields\lang_helper $lang_helper, \phpbb\profilefields\profilefields $profilefields, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
|
||||||
{
|
{
|
||||||
$this->lang_helper = $lang_helper;
|
$this->lang_helper = $lang_helper;
|
||||||
|
$this->profilefields = $profilefields;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
@ -182,4 +183,12 @@ class type_dropdown implements type_interface
|
||||||
{
|
{
|
||||||
return 'pf_' . $field_data['field_ident'];
|
return 'pf_' . $field_data['field_ident'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'UINT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,4 +158,12 @@ class type_int implements type_interface
|
||||||
{
|
{
|
||||||
return 'pf_' . $field_data['field_ident'];
|
return 'pf_' . $field_data['field_ident'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'BINT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,4 +90,11 @@ interface type_interface
|
||||||
* @return string ident of the field
|
* @return string ident of the field
|
||||||
*/
|
*/
|
||||||
public function get_field_ident($field_data);
|
public function get_field_ident($field_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the column type for the database
|
||||||
|
*
|
||||||
|
* @return string Returns the database column type
|
||||||
|
*/
|
||||||
|
public function get_database_column_type();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,14 @@ class type_string extends type_string_common implements type_interface
|
||||||
$default_value = $profile_row['lang_default_value'];
|
$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]);
|
$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('string', array_change_key_case($profile_row, CASE_UPPER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'VCHAR';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,4 +84,12 @@ class type_text extends type_string_common implements type_interface
|
||||||
|
|
||||||
$this->template->assign_block_vars('text', array_change_key_case($profile_row, CASE_UPPER));
|
$this->template->assign_block_vars('text', array_change_key_case($profile_row, CASE_UPPER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_database_column_type()
|
||||||
|
{
|
||||||
|
return 'MTEXT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue