aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShitiz Garg <mail@dragooon.net>2014-06-22 17:55:30 +0530
committerShitiz Garg <mail@dragooon.net>2014-06-27 17:48:36 +0530
commit6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4 (patch)
treed870b148766afced126f26b2c373a4ddd625dd06
parent18763d7286b1e6119f67ec510fc18a9789d172b2 (diff)
downloadforums-6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4.tar
forums-6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4.tar.gz
forums-6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4.tar.bz2
forums-6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4.tar.xz
forums-6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4.zip
[ticket/12759] Allow multiple fields to be loaded via get_option_lang
PHPBB3-12759
-rw-r--r--phpBB/phpbb/profilefields/lang_helper.php21
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php4
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php6
3 files changed, 21 insertions, 10 deletions
diff --git a/phpBB/phpbb/profilefields/lang_helper.php b/phpBB/phpbb/profilefields/lang_helper.php
index c055931181..9e4991e94a 100644
--- a/phpBB/phpbb/profilefields/lang_helper.php
+++ b/phpBB/phpbb/profilefields/lang_helper.php
@@ -51,7 +51,7 @@ class lang_helper
/**
* Get language entries for options and store them here for later use
*/
- public function get_option_lang($field_id, $lang_id, $field_type, $preview_options)
+ public function get_option_lang($field_id, $lang_id, $preview_options)
{
if ($preview_options !== false)
{
@@ -72,17 +72,28 @@ class lang_helper
}
else
{
- $sql = 'SELECT option_id, lang_value
+ if (is_array($field_id))
+ {
+ foreach ($field_id as $k => $id)
+ {
+ $field_id[$k] = (int) $id;
+ }
+ }
+ else
+ {
+ $field_id = array((int) $field_id);
+ }
+
+ $sql = 'SELECT field_id, option_id, lang_value
FROM ' . $this->language_table . '
- WHERE field_id = ' . (int) $field_id . '
+ WHERE ' . $this->db->sql_in_set('field_id', $field_id) . '
AND lang_id = ' . (int) $lang_id . "
- AND field_type = '" . $this->db->sql_escape($field_type) . "'
ORDER BY option_id";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- $this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
+ $this->options_lang[$row['field_id']][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
}
$this->db->sql_freeresult($result);
}
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index eb8d3e47d6..86e480f6b3 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -155,7 +155,7 @@ class type_bool extends type_base
if (!$this->lang_helper->is_set($field_id, $lang_id))
{
- $this->lang_helper->get_option_lang($field_id, $lang_id, FIELD_BOOL, false);
+ $this->lang_helper->get_option_lang($field_id, $lang_id, false);
}
if (!$field_value && $field_data['field_show_novalue'])
@@ -203,7 +203,7 @@ class type_bool extends type_base
{
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
{
- $this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $this->get_service_name(), $preview_options);
+ $this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
}
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 52c9fcf86a..5ecbf4e167 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -135,7 +135,7 @@ class type_dropdown extends type_base
// retrieve option lang data if necessary
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], 1))
{
- $this->lang_helper->get_option_lang($field_data['field_id'], $field_data['lang_id'], $this->get_service_name(), false);
+ $this->lang_helper->get_option_lang($field_data['field_id'], $field_data['lang_id'], false);
}
if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], $field_value))
@@ -160,7 +160,7 @@ class type_dropdown extends type_base
$lang_id = $field_data['lang_id'];
if (!$this->lang_helper->is_set($field_id, $lang_id))
{
- $this->lang_helper->get_option_lang($field_id, $lang_id, $this->get_service_name(), false);
+ $this->lang_helper->get_option_lang($field_id, $lang_id, false);
}
if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
@@ -199,7 +199,7 @@ class type_dropdown extends type_base
if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1))
{
- $this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $this->get_service_name(), $preview_options);
+ $this->lang_helper->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
}
$profile_row['field_value'] = (int) $value;