diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2014-01-13 21:05:19 +0100 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2014-01-13 21:09:17 +0100 |
| commit | b3803d563a857e12f540a315c51cf97a6c0be438 (patch) | |
| tree | 20f56d595f91e66091c00ed35b4b7090764c1267 /phpBB/phpbb/profilefields/profilefields.php | |
| parent | a7e3538e5b0cb12610b5c051a5d30292970249d1 (diff) | |
| download | forums-b3803d563a857e12f540a315c51cf97a6c0be438.tar forums-b3803d563a857e12f540a315c51cf97a6c0be438.tar.gz forums-b3803d563a857e12f540a315c51cf97a6c0be438.tar.bz2 forums-b3803d563a857e12f540a315c51cf97a6c0be438.tar.xz forums-b3803d563a857e12f540a315c51cf97a6c0be438.zip | |
[ticket/11201] Move get_profile_field() to type classes
PHPBB3-11201
Diffstat (limited to 'phpBB/phpbb/profilefields/profilefields.php')
| -rw-r--r-- | phpBB/phpbb/profilefields/profilefields.php | 79 |
1 files changed, 5 insertions, 74 deletions
diff --git a/phpBB/phpbb/profilefields/profilefields.php b/phpBB/phpbb/profilefields/profilefields.php index 3d9339d1d7..b34a85f9fa 100644 --- a/phpBB/phpbb/profilefields/profilefields.php +++ b/phpBB/phpbb/profilefields/profilefields.php @@ -22,10 +22,11 @@ class profilefields /** * */ - public function __construct($auth, $db, $request, $template, $user) + public function __construct($auth, $db, /** @todo: */ $phpbb_container, $request, $template, $user) { $this->auth = $auth; $this->db = $db; + $this->container = $phpbb_container; $this->request = $request; $this->template = $template; $this->user = $user; @@ -300,7 +301,8 @@ class profilefields while ($row = $this->db->sql_fetchrow($result)) { - $cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row); + $profile_field = $this->container->get('profilefields.type.' . $this->profile_types[$row['field_type']]); + $cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row); $check_value = $cp_data['pf_' . $row['field_ident']]; if (($cp_result = $this->validate_profile_field($row['field_type'], $check_value, $row)) !== false) @@ -362,7 +364,7 @@ class profilefields return; } - switch ($db->sql_layer) + switch ($this->db->sql_layer) { case 'oracle': case 'firebird': @@ -900,75 +902,4 @@ class profilefields return $cp_data; } - - /** - * Get profile field value on submit - * @access private - */ - function get_profile_field($profile_row) - { - $var_name = 'pf_' . $profile_row['field_ident']; - - switch ($profile_row['field_type']) - { - case FIELD_DATE: - - if (!isset($_REQUEST[$var_name . '_day'])) - { - if ($profile_row['field_default_value'] == 'now') - { - $now = getdate(); - $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']); - } - list($day, $month, $year) = explode('-', $profile_row['field_default_value']); - } - else - { - $day = request_var($var_name . '_day', 0); - $month = request_var($var_name . '_month', 0); - $year = request_var($var_name . '_year', 0); - } - - $var = sprintf('%2d-%2d-%4d', $day, $month, $year); - break; - - case FIELD_BOOL: - // Checkbox - if ($profile_row['field_length'] == 2) - { - $var = (isset($_REQUEST[$var_name])) ? 1 : 0; - } - else - { - $var = request_var($var_name, (int) $profile_row['field_default_value']); - } - break; - - case FIELD_STRING: - case FIELD_TEXT: - $var = utf8_normalize_nfc(request_var($var_name, (string) $profile_row['field_default_value'], true)); - break; - - case FIELD_INT: - if (isset($_REQUEST[$var_name]) && $this->request->variable($var_name, '') === '') - { - $var = NULL; - } - else - { - $var = request_var($var_name, (int) $profile_row['field_default_value']); - } - break; - - case FIELD_DROPDOWN: - $var = request_var($var_name, (int) $profile_row['field_default_value']); - break; - - default: - $var = request_var($var_name, $profile_row['field_default_value']); - break; - } - - return $var; - } } |
