mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-14 20:50:30 +01:00
[ticket/16859] Apply similar logic to UCP board preferences
PHPBB3-16859
This commit is contained in:
parent
c3598d0d58
commit
2c8be65dcf
@ -263,13 +263,13 @@ function phpbb_version_compare($version1, $version2, $operator = null)
|
||||
// functions used for building option fields
|
||||
|
||||
/**
|
||||
* Pick a language, any language ...
|
||||
*
|
||||
* @param string $default Language ISO code to be selected by default in the dropdown list
|
||||
* @param array $langdata Language data in format of array(array('lang_iso' => string, lang_local_name => string), ...)
|
||||
*
|
||||
* @return string HTML options for language selection dropdown list.
|
||||
*/
|
||||
* Pick a language, any language ...
|
||||
*
|
||||
* @param string $default Language ISO code to be selected by default in the dropdown list
|
||||
* @param array $langdata Language data in format of array(array('lang_iso' => string, lang_local_name => string), ...)
|
||||
*
|
||||
* @return string HTML options for language selection dropdown list.
|
||||
*/
|
||||
function language_select($default = '', array $langdata = [])
|
||||
{
|
||||
global $db;
|
||||
@ -295,26 +295,36 @@ function language_select($default = '', array $langdata = [])
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick a template/theme combo,
|
||||
*/
|
||||
function style_select($default = '', $all = false)
|
||||
* Pick a template/theme combo
|
||||
*
|
||||
* @param string $default Style ID to be selected by default in the dropdown list
|
||||
* @param bool $all Flag indicating if all styles data including inactive ones should be fetched
|
||||
* @param array $styledata Style data in format of array(array('style_id' => int, style_name => string), ...)
|
||||
*
|
||||
* @return string HTML options for style selection dropdown list.
|
||||
*/
|
||||
function style_select($default = '', $all = false, array $styledata = [])
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (empty($styledata))
|
||||
{
|
||||
$sql_where = (!$all) ? 'WHERE style_active = 1 ' : '';
|
||||
$sql = 'SELECT style_id, style_name
|
||||
FROM ' . STYLES_TABLE . "
|
||||
$sql_where
|
||||
ORDER BY style_name";
|
||||
$result = $db->sql_query($sql);
|
||||
$styledata = (array) $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$style_options = '';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
foreach ($styledata as $row)
|
||||
{
|
||||
$selected = ($row['style_id'] == $default) ? ' selected="selected"' : '';
|
||||
$style_options .= '<option value="' . $row['style_id'] . '"' . $selected . '>' . $row['style_name'] . '</option>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $style_options;
|
||||
}
|
||||
|
@ -159,33 +159,23 @@ class ucp_prefs
|
||||
phpbb_timezone_select($template, $user, $data['tz'], true);
|
||||
|
||||
// check if there are any user-selectable languages
|
||||
$sql = 'SELECT COUNT(lang_id) as languages_count
|
||||
FROM ' . LANG_TABLE;
|
||||
$sql = 'SELECT lang_iso, lang_local_name
|
||||
FROM ' . LANG_TABLE . '
|
||||
ORDER BY lang_english_name';
|
||||
$result = $db->sql_query($sql);
|
||||
if ($db->sql_fetchfield('languages_count') > 1)
|
||||
{
|
||||
$s_more_languages = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_more_languages = false;
|
||||
}
|
||||
$lang_row = (array) $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$s_more_languages = count($lang_row) > 1;
|
||||
|
||||
// check if there are any user-selectable styles
|
||||
$sql = 'SELECT COUNT(style_id) as styles_count
|
||||
$sql = 'SELECT style_id, style_name
|
||||
FROM ' . STYLES_TABLE . '
|
||||
WHERE style_active = 1';
|
||||
WHERE style_active = 1
|
||||
ORDER BY style_name';
|
||||
$result = $db->sql_query($sql);
|
||||
if ($db->sql_fetchfield('styles_count') > 1)
|
||||
{
|
||||
$s_more_styles = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_more_styles = false;
|
||||
}
|
||||
$styles_row = (array) $db->sql_fetchrowset($result);
|
||||
$db->sql_freeresult($result);
|
||||
$s_more_styles = count($styles_row) > 1;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
@ -208,8 +198,8 @@ class ucp_prefs
|
||||
'S_MORE_LANGUAGES' => $s_more_languages,
|
||||
'S_MORE_STYLES' => $s_more_styles,
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($data['lang']),
|
||||
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['user_style']),
|
||||
'S_LANG_OPTIONS' => language_select($data['lang'], $lang_row),
|
||||
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['user_style'], false, $styles_row),
|
||||
'S_CAN_HIDE_ONLINE' => ($auth->acl_get('u_hideonline')) ? true : false,
|
||||
'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user