aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-09-17 15:17:54 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-01-10 16:11:11 +0100
commit2471b19d73c38359ed70a7c9e3a82a297946c5b8 (patch)
tree49d1bd680e180abd467de9a3f2a35b4ee422c366 /phpBB
parent3e84fb76a3639dce2becb7ae620423a5cfdccecb (diff)
downloadforums-2471b19d73c38359ed70a7c9e3a82a297946c5b8.tar
forums-2471b19d73c38359ed70a7c9e3a82a297946c5b8.tar.gz
forums-2471b19d73c38359ed70a7c9e3a82a297946c5b8.tar.bz2
forums-2471b19d73c38359ed70a7c9e3a82a297946c5b8.tar.xz
forums-2471b19d73c38359ed70a7c9e3a82a297946c5b8.zip
[ticket/11201] Make profile field classes autoloadable
PHPBB3-11201
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/config/profilefields.yml23
-rw-r--r--phpBB/config/services.yml1
-rw-r--r--phpBB/includes/acp/acp_profile.php5
-rw-r--r--phpBB/includes/acp/acp_users.php3
-rw-r--r--phpBB/includes/functions_user.php9
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php8
-rw-r--r--phpBB/includes/ucp/ucp_profile.php7
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/memberlist.php6
-rw-r--r--phpBB/phpbb/profilefields/admin.php191
-rw-r--r--phpBB/phpbb/profilefields/profilefields.php (renamed from phpBB/includes/functions_profile_fields.php)367
-rw-r--r--phpBB/viewtopic.php6
12 files changed, 305 insertions, 325 deletions
diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml
new file mode 100644
index 0000000000..3b9b1a60a0
--- /dev/null
+++ b/phpBB/config/profilefields.yml
@@ -0,0 +1,23 @@
+services:
+ profilefields:
+ class: \phpbb\profilefields\profilefields
+ arguments:
+ - @auth
+ - @dbal.conn
+ - @request
+ - @template
+ - @user
+
+ profilefields.admin:
+ class: \phpbb\profilefields\admin
+ arguments:
+ - @auth
+ - @dbal.conn
+ - @request
+ - @template
+ - @user
+
+ #migrator.tool.permission1:
+ # class: \phpbb\profilefields\profilefields
+ # tags:
+ # - { name: ffoobar.tool }
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index c11184d6b6..9c9a0f625c 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -8,6 +8,7 @@ imports:
- { resource: auth_providers.yml }
- { resource: console.yml }
- { resource: mimetype_guessers.yml }
+ - { resource: profilefields.yml }
services:
acl.permissions:
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 6efd778b12..510239a837 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -29,11 +29,10 @@ class acp_profile
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
- global $request;
+ global $request, $phpbb_container;
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$user->add_lang(array('ucp', 'acp/profile'));
$this->tpl_name = 'acp_profile';
@@ -60,7 +59,7 @@ class acp_profile
FIELD_DROPDOWN => array('field_length' => 0, 'field_minlen' => 0, 'field_maxlen' => 5, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
);
- $cp = new custom_profile_admin();
+ $cp = $phpbb_container->get('profilefields.admin');
// Build Language array
// Based on this, we decide which elements need to be edited later and which language items are missing
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index b24adfc586..beb6fa1960 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -1343,9 +1343,8 @@ class acp_users
case 'profile':
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$cp_data = $cp_error = array();
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index dba6d3d6c2..b2cd911a0d 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -162,7 +162,7 @@ function user_update_name($old_name, $new_name)
function user_add($user_row, $cp_data = false)
{
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
- global $phpbb_dispatcher;
+ global $phpbb_dispatcher, $phpbb_container;
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type']))
{
@@ -276,12 +276,7 @@ function user_add($user_row, $cp_data = false)
{
$cp_data['user_id'] = (int) $user_id;
- if (!class_exists('custom_profile'))
- {
- include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- }
-
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' .
$db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data));
$db->sql_query($sql);
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index cebbadc7c7..78a0e010e6 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*/
function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{
- global $user, $template, $auth, $db, $cache;
+ global $user, $template, $auth, $db, $cache, $phpbb_container;
global $phpbb_root_path, $request, $phpEx, $config, $phpbb_dispatcher;
$user->add_lang(array('viewtopic', 'memberlist'));
@@ -61,11 +61,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// Load the custom profile fields
if ($config['load_cpf_pm'])
{
- if (!class_exists('custom_profile'))
- {
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- }
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$profile_fields = $cp->generate_profile_fields_template('grab', $author_id);
}
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 2252b2ea17..672588c51f 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -29,8 +29,7 @@ class ucp_profile
function main($id, $mode)
{
global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
- global $request;
- global $phpbb_container;
+ global $request, $phpbb_container;
$user->add_lang('posting');
@@ -257,9 +256,7 @@ class ucp_profile
trigger_error('NO_AUTH_PROFILEINFO');
}
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
-
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$cp_data = $cp_error = array();
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 1641c6eef1..333aa2816f 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -35,8 +35,6 @@ class ucp_register
trigger_error('UCP_REGISTER_DISABLE');
}
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
-
$coppa = $request->is_set('coppa') ? (int) $request->variable('coppa', false) : false;
$agreed = $request->variable('agreed', false);
$submit = $request->is_set_post('submit');
@@ -78,7 +76,7 @@ class ucp_register
}
}
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$error = $cp_data = $cp_error = array();
$s_hidden_fields = array();
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 14425ca6e4..84fbb8218a 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -617,8 +617,7 @@ switch ($mode)
$profile_fields = array();
if ($config['load_cpf_viewprofile'])
{
- include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
$profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
}
@@ -1555,8 +1554,7 @@ switch ($mode)
// Load custom profile fields
if ($config['load_cpf_memberlist'])
{
- include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
diff --git a/phpBB/phpbb/profilefields/admin.php b/phpBB/phpbb/profilefields/admin.php
new file mode 100644
index 0000000000..b784b91c55
--- /dev/null
+++ b/phpBB/phpbb/profilefields/admin.php
@@ -0,0 +1,191 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\profilefields;
+
+/**
+* Custom Profile Fields ACP
+* @package phpBB3
+*/
+class admin extends profilefields
+{
+ var $vars = array();
+
+ /**
+ * Return possible validation options
+ */
+ function validate_options()
+ {
+ global $user;
+
+ $validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
+
+ $validate_options = '';
+ foreach ($validate_ary as $lang => $value)
+ {
+ $selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
+ $validate_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
+ }
+
+ return $validate_options;
+ }
+
+ /**
+ * Get string options for second step in ACP
+ */
+ function get_string_options()
+ {
+ global $user;
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
+ 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
+ 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
+ );
+
+ return $options;
+ }
+
+ /**
+ * Get text options for second step in ACP
+ */
+ function get_text_options()
+ {
+ global $user;
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . $user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . $user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
+ 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
+ 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
+ );
+
+ return $options;
+ }
+
+ /**
+ * Get int options for second step in ACP
+ */
+ function get_int_options()
+ {
+ global $user;
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
+ 1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
+ 3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
+ );
+
+ return $options;
+ }
+
+ /**
+ * Get bool options for second step in ACP
+ */
+ function get_bool_options()
+ {
+ global $user, $config, $lang_defs;
+
+ $default_lang_id = $lang_defs['iso'][$config['default_lang']];
+
+ $profile_row = array(
+ 'var_name' => 'field_default_value',
+ 'field_id' => 1,
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_BOOL,
+ 'field_length' => $this->vars['field_length'],
+ 'lang_options' => $this->vars['lang_options']
+ );
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['CHECKBOX'] . '</label>'),
+ 1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
+ );
+
+ return $options;
+ }
+
+ /**
+ * Get dropdown options for second step in ACP
+ */
+ function get_dropdown_options()
+ {
+ global $user, $config, $lang_defs;
+
+ $default_lang_id = $lang_defs['iso'][$config['default_lang']];
+
+ $profile_row[0] = array(
+ 'var_name' => 'field_default_value',
+ 'field_id' => 1,
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_DROPDOWN,
+ 'lang_options' => $this->vars['lang_options']
+ );
+
+ $profile_row[1] = $profile_row[0];
+ $profile_row[1]['var_name'] = 'field_novalue';
+ $profile_row[1]['field_ident'] = 'field_novalue';
+ $profile_row[1]['field_default_value'] = $this->vars['field_novalue'];
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
+ 1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
+ );
+
+ return $options;
+ }
+
+ /**
+ * Get date options for second step in ACP
+ */
+ function get_date_options()
+ {
+ global $user, $config, $lang_defs;
+
+ $default_lang_id = $lang_defs['iso'][$config['default_lang']];
+
+ $profile_row = array(
+ 'var_name' => 'field_default_value',
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_DATE,
+ 'field_length' => $this->vars['field_length']
+ );
+
+ $always_now = request_var('always_now', -1);
+ if ($always_now == -1)
+ {
+ $s_checked = ($this->vars['field_default_value'] == 'now') ? true : false;
+ }
+ else
+ {
+ $s_checked = ($always_now) ? true : false;
+ }
+
+ $options = array(
+ 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
+ 1 => array('TITLE' => $user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['NO'] . '</label>'),
+ );
+
+ return $options;
+ }
+}
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/phpbb/profilefields/profilefields.php
index 7dd0b0e87d..3d9339d1d7 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/phpbb/profilefields/profilefields.php
@@ -7,33 +7,37 @@
*
*/
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
+namespace phpbb\profilefields;
/**
* Custom Profile Fields
* @package phpBB3
*/
-class custom_profile
+class profilefields
{
var $profile_types = array(FIELD_INT => 'int', FIELD_STRING => 'string', FIELD_TEXT => 'text', FIELD_BOOL => 'bool', FIELD_DROPDOWN => 'dropdown', FIELD_DATE => 'date');
var $profile_cache = array();
var $options_lang = array();
/**
+ *
+ */
+ public function __construct($auth, $db, $request, $template, $user)
+ {
+ $this->auth = $auth;
+ $this->db = $db;
+ $this->request = $request;
+ $this->template = $template;
+ $this->user = $user;
+ }
+
+ /**
* Assign editable fields to template, mode can be profile (for profile change) or register (for registration)
* Called by ucp_profile and ucp_register
* @access public
*/
function generate_profile_fields($mode, $lang_id)
{
- global $db, $template, $auth;
-
$sql_where = '';
switch ($mode)
{
@@ -44,7 +48,7 @@ class custom_profile
case 'profile':
// Show hidden fields to moderators/admins
- if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
+ if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_'))
{
$sql_where .= ' AND f.field_show_profile = 1';
}
@@ -62,9 +66,9 @@ class custom_profile
AND l.lang_id = $lang_id
AND l.field_id = f.field_id
ORDER BY f.field_order";
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
// Return templated field
$tpl_snippet = $this->process_field_row('change', $row);
@@ -72,7 +76,7 @@ class custom_profile
// Some types are multivalue, we can't give them a field_id as we would not know which to pick
$type = (int) $row['field_type'];
- $template->assign_block_vars('profile_fields', array(
+ $this->template->assign_block_vars('profile_fields', array(
'LANG_NAME' => $row['lang_name'],
'LANG_EXPLAIN' => $row['lang_explain'],
'FIELD' => $tpl_snippet,
@@ -80,7 +84,7 @@ class custom_profile
'S_REQUIRED' => ($row['field_required']) ? true : false)
);
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
/**
@@ -206,26 +210,24 @@ class custom_profile
*/
function build_cache()
{
- global $db, $user, $auth;
-
$this->profile_cache = array();
// Display hidden/no_view fields for admin/moderator
$sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
- WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
+ WHERE l.lang_id = ' . $this->user->get_iso_lang_id() . '
AND f.field_active = 1 ' .
- ((!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND f.field_hide = 0 ' : '') . '
+ ((!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) ? ' AND f.field_hide = 0 ' : '') . '
AND f.field_no_view = 0
AND l.field_id = f.field_id
ORDER BY f.field_order';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$this->profile_cache[$row['field_ident']] = $row;
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
/**
@@ -233,8 +235,6 @@ class custom_profile
*/
function get_option_lang($field_id, $lang_id, $field_type, $preview)
{
- global $db;
-
if ($preview)
{
$lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options'];
@@ -252,13 +252,13 @@ class custom_profile
AND lang_id = $lang_id
AND field_type = $field_type
ORDER BY option_id";
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
}
@@ -268,8 +268,6 @@ class custom_profile
*/
function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
{
- global $auth, $db, $user;
-
$sql_where = '';
switch ($mode)
{
@@ -280,7 +278,7 @@ class custom_profile
case 'profile':
// Show hidden fields to moderators/admins
- if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
+ if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_'))
{
$sql_where .= ' AND f.field_show_profile = 1';
}
@@ -298,9 +296,9 @@ class custom_profile
$sql_where
AND l.field_id = f.field_id
ORDER BY f.field_order";
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row);
$check_value = $cp_data['pf_' . $row['field_ident']];
@@ -314,32 +312,32 @@ class custom_profile
case 'FIELD_INVALID_DATE':
case 'FIELD_INVALID_VALUE':
case 'FIELD_REQUIRED':
- $error = $user->lang($cp_result, $row['lang_name']);
+ $error = $this->user->lang($cp_result, $row['lang_name']);
break;
case 'FIELD_TOO_SHORT':
case 'FIELD_TOO_SMALL':
- $error = $user->lang($cp_result, (int) $row['field_minlen'], $row['lang_name']);
+ $error = $this->user->lang($cp_result, (int) $row['field_minlen'], $row['lang_name']);
break;
case 'FIELD_TOO_LONG':
case 'FIELD_TOO_LARGE':
- $error = $user->lang($cp_result, (int) $row['field_maxlen'], $row['lang_name']);
+ $error = $this->user->lang($cp_result, (int) $row['field_maxlen'], $row['lang_name']);
break;
case 'FIELD_INVALID_CHARS':
switch ($row['field_validation'])
{
case '[0-9]+':
- $error = $user->lang($cp_result . '_NUMBERS_ONLY', $row['lang_name']);
+ $error = $this->user->lang($cp_result . '_NUMBERS_ONLY', $row['lang_name']);
break;
case '[\w]+':
- $error = $user->lang($cp_result . '_ALPHA_ONLY', $row['lang_name']);
+ $error = $this->user->lang($cp_result . '_ALPHA_ONLY', $row['lang_name']);
break;
case '[\w_\+\. \-\[\]]+':
- $error = $user->lang($cp_result . '_SPACERS_ONLY', $row['lang_name']);
+ $error = $this->user->lang($cp_result . '_SPACERS_ONLY', $row['lang_name']);
break;
}
break;
@@ -351,7 +349,7 @@ class custom_profile
}
}
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
/**
@@ -359,8 +357,6 @@ class custom_profile
*/
function update_profile_field_data($user_id, &$cp_data)
{
- global $db;
-
if (!sizeof($cp_data))
{
return;
@@ -394,24 +390,24 @@ class custom_profile
foreach ($cp_data as $key => $value)
{
// Firebird is case sensitive with delimiter
- $cp_data_sql[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value;
+ $cp_data_sql[$left_delim . (($this->db->sql_layer == 'firebird' || $this->db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value;
}
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $cp_data_sql) . "
+ SET ' . $this->db->sql_build_array('UPDATE', $cp_data_sql) . "
WHERE user_id = $user_id";
- $db->sql_query($sql);
+ $this->db->sql_query($sql);
- if (!$db->sql_affectedrows())
+ if (!$this->db->sql_affectedrows())
{
$cp_data_sql['user_id'] = (int) $user_id;
- $db->sql_return_on_error(true);
+ $this->db->sql_return_on_error(true);
- $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data_sql);
- $db->sql_query($sql);
+ $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $this->db->sql_build_array('INSERT', $cp_data_sql);
+ $this->db->sql_query($sql);
- $db->sql_return_on_error(false);
+ $this->db->sql_return_on_error(false);
}
}
@@ -422,8 +418,6 @@ class custom_profile
*/
function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
{
- global $db;
-
if ($mode == 'grab')
{
if (!is_array($user_id))
@@ -443,15 +437,15 @@ class custom_profile
$sql = 'SELECT *
FROM ' . PROFILE_FIELDS_DATA_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_map('intval', $user_id));
- $result = $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_id));
+ $result = $this->db->sql_query($sql);
$field_data = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$field_data[$row['user_id']] = $row;
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$user_fields = array();
@@ -564,10 +558,8 @@ class custom_profile
}
else if ($day && $month && $year)
{
- global $user;
// Date should display as the same date for every user regardless of timezone
-
- return $user->create_datetime()
+ return $this->user->create_datetime()
->setDate($year, $month, $day)
->setTime(0, 0, 0)
->format($user->lang['DATE_FORMAT'], true);
@@ -646,35 +638,32 @@ class custom_profile
*/
function get_var($field_validation, &$profile_row, $default_value, $preview)
{
- global $user;
- global $request;
-
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
$user_ident = $profile_row['field_ident'];
// checkbox - set the value to "true" if it has been set to 1
if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
{
- $value = (isset($_REQUEST[$profile_row['field_ident']]) && request_var($profile_row['field_ident'], $default_value) == 1) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
+ $value = (isset($_REQUEST[$profile_row['field_ident']]) && request_var($profile_row['field_ident'], $default_value) == 1) ? true : ((!isset($this->user->profile_fields[$user_ident]) || $preview) ? $default_value : $this->user->profile_fields[$user_ident]);
}
else if ($profile_row['field_type'] == FIELD_INT)
{
if (isset($_REQUEST[$profile_row['field_ident']]))
{
- $value = ($request->variable($profile_row['field_ident'], '') === '') ? NULL : $request->variable($profile_row['field_ident'], $default_value);
+ $value = ($this->request->variable($profile_row['field_ident'], '') === '') ? NULL : $this->request->variable($profile_row['field_ident'], $default_value);
}
else
{
- if (!$preview && array_key_exists($user_ident, $user->profile_fields) && is_null($user->profile_fields[$user_ident]))
+ if (!$preview && array_key_exists($user_ident, $this->user->profile_fields) && is_null($this->user->profile_fields[$user_ident]))
{
$value = NULL;
}
- else if (!isset($user->profile_fields[$user_ident]) || $preview)
+ else if (!isset($this->user->profile_fields[$user_ident]) || $preview)
{
$value = $default_value;
}
else
{
- $value = $user->profile_fields[$user_ident];
+ $value = $this->user->profile_fields[$user_ident];
}
}
@@ -682,7 +671,7 @@ class custom_profile
}
else
{
- $value = (isset($_REQUEST[$profile_row['field_ident']])) ? request_var($profile_row['field_ident'], $default_value, true) : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
+ $value = (isset($_REQUEST[$profile_row['field_ident']])) ? request_var($profile_row['field_ident'], $default_value, true) : ((!isset($this->user->profile_fields[$user_ident]) || $preview) ? $default_value : $this->user->profile_fields[$user_ident]);
if (gettype($value) == 'string')
{
@@ -706,10 +695,8 @@ class custom_profile
*/
function generate_int($profile_row, $preview = false)
{
- global $template;
-
$profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
}
/**
@@ -718,8 +705,6 @@ class custom_profile
*/
function generate_date($profile_row, $preview = false)
{
- global $user, $template;
-
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
$user_ident = $profile_row['field_ident'];
@@ -731,14 +716,14 @@ class custom_profile
{
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
}
- list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
+ list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident]));
}
else
{
if ($preview && $profile_row['field_default_value'] == 'now')
{
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
- list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
+ list($day, $month, $year) = explode('-', ((!isset($this->user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $this->user->profile_fields[$user_ident]));
}
else
{
@@ -768,7 +753,7 @@ class custom_profile
unset($now);
$profile_row['field_value'] = 0;
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
}
/**
@@ -777,12 +762,10 @@ class custom_profile
*/
function generate_bool($profile_row, $preview = false)
{
- global $template;
-
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
$profile_row['field_value'] = $value;
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
if ($profile_row['field_length'] == 1)
{
@@ -793,7 +776,7 @@ class custom_profile
foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
{
- $template->assign_block_vars('bool.options', array(
+ $this->template->assign_block_vars('bool.options', array(
'OPTION_ID' => $option_id,
'CHECKED' => ($value == $option_id) ? ' checked="checked"' : '',
'VALUE' => $option_value)
@@ -808,10 +791,8 @@ class custom_profile
*/
function generate_string($profile_row, $preview = false)
{
- global $template;
-
$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
}
/**
@@ -820,15 +801,12 @@ class custom_profile
*/
function generate_text($profile_row, $preview = false)
{
- global $template;
- global $user, $phpEx, $phpbb_root_path;
-
$field_length = explode('|', $profile_row['field_length']);
$profile_row['field_rows'] = $field_length[0];
$profile_row['field_cols'] = $field_length[1];
$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
}
/**
@@ -837,8 +815,6 @@ class custom_profile
*/
function generate_dropdown($profile_row, $preview = false)
{
- global $user, $template;
-
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
if (!isset($this->options_lang[$profile_row['field_id']]) || !isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
@@ -847,11 +823,11 @@ class custom_profile
}
$profile_row['field_value'] = $value;
- $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
+ $this->template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
{
- $template->assign_block_vars('dropdown.options', array(
+ $this->template->assign_block_vars('dropdown.options', array(
'OPTION_ID' => $option_id,
'SELECTED' => ($value == $option_id) ? ' selected="selected"' : '',
'VALUE' => $option_value)
@@ -866,19 +842,17 @@ class custom_profile
*/
function process_field_row($mode, $profile_row)
{
- global $template;
-
$preview = ($mode == 'preview') ? true : false;
// set template filename
- $template->set_filenames(array(
- 'cp_body' => 'custom_profile_fields.html')
- );
+ $this->template->set_filenames(array(
+ 'cp_body' => 'custom_profile_fields.html',
+ ));
// empty previously filled blockvars
foreach ($this->profile_types as $field_case => $field_type)
{
- $template->destroy_block_vars($field_type);
+ $this->template->destroy_block_vars($field_type);
}
// Assign template variables
@@ -886,7 +860,7 @@ class custom_profile
$this->$type_func($profile_row, $preview);
// Return templated data
- return $template->assign_display('cp_body');
+ return $this->template->assign_display('cp_body');
}
/**
@@ -894,8 +868,6 @@ class custom_profile
*/
function build_insert_sql_array($cp_data)
{
- global $db, $user, $auth;
-
$sql_not_in = array();
foreach ($cp_data as $key => $null)
{
@@ -904,12 +876,12 @@ class custom_profile
$sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
- WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
- ' . ((sizeof($sql_not_in)) ? ' AND ' . $db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
+ WHERE l.lang_id = ' . $this->user->get_iso_lang_id() . '
+ ' . ((sizeof($sql_not_in)) ? ' AND ' . $this->db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
AND l.field_id = f.field_id';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE)
{
@@ -924,7 +896,7 @@ class custom_profile
$cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
return $cp_data;
}
@@ -935,10 +907,6 @@ class custom_profile
*/
function get_profile_field($profile_row)
{
- global $phpbb_root_path, $phpEx;
- global $config;
- global $request;
-
$var_name = 'pf_' . $profile_row['field_ident'];
switch ($profile_row['field_type'])
@@ -982,7 +950,7 @@ class custom_profile
break;
case FIELD_INT:
- if (isset($_REQUEST[$var_name]) && $request->variable($var_name, '') === '')
+ if (isset($_REQUEST[$var_name]) && $this->request->variable($var_name, '') === '')
{
$var = NULL;
}
@@ -1004,184 +972,3 @@ class custom_profile
return $var;
}
}
-
-/**
-* Custom Profile Fields ACP
-* @package phpBB3
-*/
-class custom_profile_admin extends custom_profile
-{
- var $vars = array();
-
- /**
- * Return possible validation options
- */
- function validate_options()
- {
- global $user;
-
- $validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
-
- $validate_options = '';
- foreach ($validate_ary as $lang => $value)
- {
- $selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
- $validate_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
- }
-
- return $validate_options;
- }
-
- /**
- * Get string options for second step in ACP
- */
- function get_string_options()
- {
- global $user;
-
- $options = array(
- 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
- 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
- 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
- 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
- );
-
- return $options;
- }
-
- /**
- * Get text options for second step in ACP
- */
- function get_text_options()
- {
- global $user;
-
- $options = array(
- 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . $user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . $user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
- 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
- 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
- 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
- );
-
- return $options;
- }
-
- /**
- * Get int options for second step in ACP
- */
- function get_int_options()
- {
- global $user;
-
- $options = array(
- 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
- 1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
- 2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
- 3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
- );
-
- return $options;
- }
-
- /**
- * Get bool options for second step in ACP
- */
- function get_bool_options()
- {
- global $user, $config, $lang_defs;
-
- $default_lang_id = $lang_defs['iso'][$config['default_lang']];
-
- $profile_row = array(
- 'var_name' => 'field_default_value',
- 'field_id' => 1,
- 'lang_name' => $this->vars['lang_name'],
- 'lang_explain' => $this->vars['lang_explain'],
- 'lang_id' => $default_lang_id,
- 'field_default_value' => $this->vars['field_default_value'],
- 'field_ident' => 'field_default_value',
- 'field_type' => FIELD_BOOL,
- 'field_length' => $this->vars['field_length'],
- 'lang_options' => $this->vars['lang_options']
- );
-
- $options = array(
- 0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['CHECKBOX'] . '</label>'),
- 1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
- );
-
- return $options;
- }
-
- /**
- * Get dropdown options for second step in ACP
- */
- function get_dropdown_options()
- {
- global $user, $config, $lang_defs;
-
- $default_lang_id = $lang_defs['iso'][$config['default_lang']];
-
- $profile_row[0] = array(
- 'var_name' => 'field_default_value',
- 'field_id' => 1,
- 'lang_name' => $this->vars['lang_name'],
- 'lang_explain' => $this->vars['lang_explain'],
- 'lang_id' => $default_lang_id,
- 'field_default_value' => $this->vars['field_default_value'],
- 'field_ident' => 'field_default_value',
- 'field_type' => FIELD_DROPDOWN,
- 'lang_options' => $this->vars['lang_options']
- );
-
- $profile_row[1] = $profile_row[0];
- $profile_row[1]['var_name'] = 'field_novalue';
- $profile_row[1]['field_ident'] = 'field_novalue';
- $profile_row[1]['field_default_value'] = $this->vars['field_novalue'];
-
- $options = array(
- 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
- 1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
- );
-
- return $options;
- }
-
- /**
- * Get date options for second step in ACP
- */
- function get_date_options()
- {
- global $user, $config, $lang_defs;
-
- $default_lang_id = $lang_defs['iso'][$config['default_lang']];
-
- $profile_row = array(
- 'var_name' => 'field_default_value',
- 'lang_name' => $this->vars['lang_name'],
- 'lang_explain' => $this->vars['lang_explain'],
- 'lang_id' => $default_lang_id,
- 'field_default_value' => $this->vars['field_default_value'],
- 'field_ident' => 'field_default_value',
- 'field_type' => FIELD_DATE,
- 'field_length' => $this->vars['field_length']
- );
-
- $always_now = request_var('always_now', -1);
- if ($always_now == -1)
- {
- $s_checked = ($this->vars['field_default_value'] == 'now') ? true : false;
- }
- else
- {
- $s_checked = ($always_now) ? true : false;
- }
-
- $options = array(
- 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
- 1 => array('TITLE' => $user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['NO'] . '</label>'),
- );
-
- return $options;
- }
-}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 14040176cb..396de132cb 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1265,11 +1265,7 @@ $db->sql_freeresult($result);
// Load custom profile fields
if ($config['load_cpf_viewtopic'])
{
- if (!class_exists('custom_profile'))
- {
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
- }
- $cp = new custom_profile();
+ $cp = $phpbb_container->get('profilefields');
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);