From 8e86e56120279a0522b2b05e627edde1b8a11d80 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 15 Jan 2014 15:34:17 +0100 Subject: [PATCH] [ticket/11201] Add database column type to type class PHPBB3-11201 --- phpBB/config/profilefields.yml | 2 ++ phpBB/phpbb/profilefields/profilefields.php | 2 +- phpBB/phpbb/profilefields/type/type_bool.php | 11 ++++++++++- phpBB/phpbb/profilefields/type/type_date.php | 8 ++++++++ phpBB/phpbb/profilefields/type/type_dropdown.php | 11 ++++++++++- phpBB/phpbb/profilefields/type/type_int.php | 8 ++++++++ phpBB/phpbb/profilefields/type/type_interface.php | 7 +++++++ phpBB/phpbb/profilefields/type/type_string.php | 9 ++++++++- phpBB/phpbb/profilefields/type/type_text.php | 8 ++++++++ 9 files changed, 62 insertions(+), 4 deletions(-) diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml index efc41707df..5aa30ac87a 100644 --- a/phpBB/config/profilefields.yml +++ b/phpBB/config/profilefields.yml @@ -26,6 +26,7 @@ services: class: \phpbb\profilefields\type\type_bool arguments: - @profilefields.lang_helper + - @profilefields - @request - @template - @user @@ -46,6 +47,7 @@ services: class: \phpbb\profilefields\type\type_dropdown arguments: - @profilefields.lang_helper + - @profilefields - @request - @template - @user diff --git a/phpBB/phpbb/profilefields/profilefields.php b/phpBB/phpbb/profilefields/profilefields.php index 38b8600b7b..a580ca2937 100644 --- a/phpBB/phpbb/profilefields/profilefields.php +++ b/phpBB/phpbb/profilefields/profilefields.php @@ -339,7 +339,7 @@ class profilefields * Return Templated value/field. Possible values for $mode are: * 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; diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php index f32f4a7513..6abac8c7bf 100644 --- a/phpBB/phpbb/profilefields/type/type_bool.php +++ b/phpBB/phpbb/profilefields/type/type_bool.php @@ -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->profilefields = $profilefields; $this->request = $request; $this->template = $template; $this->user = $user; @@ -184,4 +185,12 @@ class type_bool implements type_interface { return ($field_data['field_length'] == '1') ? '' : 'pf_' . $field_data['field_ident']; } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'TINT:2'; + } } diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php index fda09c05e2..1fcbf2ea3e 100644 --- a/phpBB/phpbb/profilefields/type/type_date.php +++ b/phpBB/phpbb/profilefields/type/type_date.php @@ -232,4 +232,12 @@ class type_date implements type_interface { return ''; } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'VCHAR:10'; + } } diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php index a3217f004c..e2b0dc646c 100644 --- a/phpBB/phpbb/profilefields/type/type_dropdown.php +++ b/phpBB/phpbb/profilefields/type/type_dropdown.php @@ -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->profilefields = $profilefields; $this->request = $request; $this->template = $template; $this->user = $user; @@ -182,4 +183,12 @@ class type_dropdown implements type_interface { return 'pf_' . $field_data['field_ident']; } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'UINT'; + } } diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index 13e39039c3..202005008f 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -158,4 +158,12 @@ class type_int implements type_interface { return 'pf_' . $field_data['field_ident']; } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'BINT'; + } } diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 5b662205b3..917b95f653 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -90,4 +90,11 @@ interface type_interface * @return string ident of the field */ 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(); } diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php index 57edd14d62..a9d9fddfb0 100644 --- a/phpBB/phpbb/profilefields/type/type_string.php +++ b/phpBB/phpbb/profilefields/type/type_string.php @@ -78,7 +78,14 @@ class type_string extends type_string_common implements type_interface $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]); - $this->template->assign_block_vars('string', array_change_key_case($profile_row, CASE_UPPER)); } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'VCHAR'; + } } diff --git a/phpBB/phpbb/profilefields/type/type_text.php b/phpBB/phpbb/profilefields/type/type_text.php index da1bb32859..58cc2d2741 100644 --- a/phpBB/phpbb/profilefields/type/type_text.php +++ b/phpBB/phpbb/profilefields/type/type_text.php @@ -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)); } + + /** + * {@inheritDoc} + */ + public function get_database_column_type() + { + return 'MTEXT'; + } }