aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-01-18 12:36:18 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-01-18 12:36:18 +0100
commit431fa7b59321376fa7ceb44ac62de30c6edb29a8 (patch)
tree7b4de3dcee485b7075bc1eeb4ac268d6045c42b6
parent39ff387d36001c14dc2130feaf811d51e946c886 (diff)
downloadforums-431fa7b59321376fa7ceb44ac62de30c6edb29a8.tar
forums-431fa7b59321376fa7ceb44ac62de30c6edb29a8.tar.gz
forums-431fa7b59321376fa7ceb44ac62de30c6edb29a8.tar.bz2
forums-431fa7b59321376fa7ceb44ac62de30c6edb29a8.tar.xz
forums-431fa7b59321376fa7ceb44ac62de30c6edb29a8.zip
[ticket/11201] Inject table names rather then using constants
PHPBB3-11201
-rw-r--r--phpBB/config/profilefields.yml4
-rw-r--r--phpBB/config/tables.yml4
-rw-r--r--phpBB/phpbb/profilefields/lang_helper.php12
-rw-r--r--phpBB/phpbb/profilefields/profilefields.php20
4 files changed, 30 insertions, 10 deletions
diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml
index 5aa30ac87a..6c6ccedcea 100644
--- a/phpBB/config/profilefields.yml
+++ b/phpBB/config/profilefields.yml
@@ -7,6 +7,9 @@ services:
- @request
- @template
- @user
+ - %tables.profile_fields%
+ - %tables.profile_fields_language%
+ - %tables.profile_fields_data%
calls:
- [set_type_collection, [@profilefields.type_collection]]
@@ -14,6 +17,7 @@ services:
class: \phpbb\profilefields\lang_helper
arguments:
- @dbal.conn
+ - %tables.profile_fields_options_language%
profilefields.type_collection:
class: phpbb\di\service_collection
diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml
index 0d364eb6b0..e4f7bda89b 100644
--- a/phpBB/config/tables.yml
+++ b/phpBB/config/tables.yml
@@ -10,6 +10,10 @@ parameters:
tables.modules: %core.table_prefix%modules
tables.notification_types: %core.table_prefix%notification_types
tables.notifications: %core.table_prefix%notifications
+ tables.profile_fields: %core.table_prefix%profile_fields
+ tables.profile_fields_data: %core.table_prefix%profile_fields_data
+ tables.profile_fields_options_language: %core.table_prefix%profile_fields_lang
+ tables.profile_fields_language: %core.table_prefix%profile_lang
tables.posts: %core.table_prefix%posts
tables.topics: %core.table_prefix%topics
tables.user_notifications: %core.table_prefix%user_notifications
diff --git a/phpBB/phpbb/profilefields/lang_helper.php b/phpBB/phpbb/profilefields/lang_helper.php
index 432c0aa40b..cf4a248d1b 100644
--- a/phpBB/phpbb/profilefields/lang_helper.php
+++ b/phpBB/phpbb/profilefields/lang_helper.php
@@ -28,13 +28,21 @@ class lang_helper
protected $db;
/**
+ * Table where the language strings are stored
+ * @var string
+ */
+ protected $language_table;
+
+ /**
* Construct
*
* @param \phpbb\db\driver\driver $db Database object
+ * @param string $language_table Table where the language strings are stored
*/
- public function __construct($db)
+ public function __construct($db, $language_table)
{
$this->db = $db;
+ $this->language_table = $language_table;
}
/**
@@ -62,7 +70,7 @@ class lang_helper
else
{
$sql = 'SELECT option_id, lang_value
- FROM ' . PROFILE_FIELDS_LANG_TABLE . "
+ FROM ' . $this->language_table . "
WHERE field_id = $field_id
AND lang_id = $lang_id
AND field_type = '" . $this->db->sql_escape($field_type) . "'
diff --git a/phpBB/phpbb/profilefields/profilefields.php b/phpBB/phpbb/profilefields/profilefields.php
index bd9765d04c..af0b733f32 100644
--- a/phpBB/phpbb/profilefields/profilefields.php
+++ b/phpBB/phpbb/profilefields/profilefields.php
@@ -21,13 +21,17 @@ class profilefields
/**
*
*/
- public function __construct($auth, $db, $request, $template, $user)
+ public function __construct($auth, $db, $request, $template, $user, $fields_table, $fields_language_table, $fields_data_table)
{
$this->auth = $auth;
$this->db = $db;
$this->request = $request;
$this->template = $template;
$this->user = $user;
+
+ $this->fields_table = $fields_table;
+ $this->fields_language_table = $fields_language_table;
+ $this->fields_data_table = $fields_data_table;
}
/**
@@ -72,7 +76,7 @@ class profilefields
}
$sql = 'SELECT l.*, f.*
- FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
+ FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . " f
WHERE f.field_active = 1
$sql_where
AND l.lang_id = $lang_id
@@ -106,7 +110,7 @@ class profilefields
// Display hidden/no_view fields for admin/moderator
$sql = 'SELECT l.*, f.*
- FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
+ FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
WHERE l.lang_id = ' . $this->user->get_iso_lang_id() . '
AND f.field_active = 1 ' .
((!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) ? ' AND f.field_hide = 0 ' : '') . '
@@ -149,7 +153,7 @@ class profilefields
}
$sql = 'SELECT l.*, f.*
- FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
+ FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . " f
WHERE l.lang_id = $lang_id
AND f.field_active = 1
$sql_where
@@ -213,7 +217,7 @@ class profilefields
$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 . '
+ $sql = 'UPDATE ' . $this->fields_data_table . '
SET ' . $this->db->sql_build_array('UPDATE', $cp_data_sql) . "
WHERE user_id = $user_id";
$this->db->sql_query($sql);
@@ -224,7 +228,7 @@ class profilefields
$this->db->sql_return_on_error(true);
- $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $this->db->sql_build_array('INSERT', $cp_data_sql);
+ $sql = 'INSERT INTO ' . $this->fields_data_table . ' ' . $this->db->sql_build_array('INSERT', $cp_data_sql);
$this->db->sql_query($sql);
$this->db->sql_return_on_error(false);
@@ -255,7 +259,7 @@ class profilefields
}
$sql = 'SELECT *
- FROM ' . PROFILE_FIELDS_DATA_TABLE . '
+ FROM ' . $this->fields_data_table . '
WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_id));
$result = $this->db->sql_query($sql);
@@ -373,7 +377,7 @@ class profilefields
}
$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
+ FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
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';