Report#79: Change Style - activate this function - Code provided by Christian_N

This commit is contained in:
Kevin
2008-03-16 13:56:26 +00:00
parent ca743e8809
commit e22397bb64
9 changed files with 77 additions and 65 deletions

View File

@@ -20,57 +20,44 @@ if (!defined('IN_PORTAL'))
exit;
}
$lang = request_var('lang', '', false, true);
$style = request_var('style', 0);
$sql = 'SELECT style_id, style_name, style_copyright
FROM ' . STYLES_TABLE . '
WHERE style_active = 1
ORDER BY style_name ASC';
if (file_exists($phpbb_root_path . 'language/' . $lang . "/common.$phpEx"))
{
$this->lang_name = $lang;
$this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/';
$result = $db->sql_query($sql);
$style_select = '<option selected="selected" disabled="disabled">' . $user->lang['STYLE_CHOOSE'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ( $style == $row['style_id'] ) ? ' selected="selected"' : '';
$style_value = append_sid("{$phpbb_root_path}portal.$phpEx", 'style=' . $row['style_id']);
$style_select .= '<option value="' . $style_value . '"' . $selected . '>&nbsp; ' . $row['style_name'] . ' &nbsp;</option>';
}
$db->sql_freeresult($result);
// style info
$sql2 = 'SELECT style_id, style_name, style_copyright
FROM ' . STYLES_TABLE . '
WHERE style_active = 1
AND style_id = ' . $style;
$cookie_expire = $this->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000);
$this->set_cookie('lang', $lang, $cookie_expire);
unset($cookie_expire);
}
$result = $db->sql_query($sql2);
$row = $db->sql_fetchrow($result);
$requested_style = request_var('style', 0, false, true);
$template->assign_vars(array(
'S_STYLE_ACTION'=> append_sid("{$phpbb_root_path}portal.$phpEx"),
'STYLE_NAME' => $row['style_name'],
'STYLE_COPY' => $row['style_copyright'],
'STYLE_SELECT' => $style_select,
));
if ($requested_style && (!$config['override_user_style'] || $auth->acl_get('a_styles')))
{
$style = $requested_style;
$cookie_expire = $this->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000);
$this->set_cookie('style', $style, $cookie_expire);
unset($cookie_expire);
}
$all = false;
$default = '';
$sql_where = (!$all) ? 'WHERE style_active = 1 ' : '';
$sql = 'SELECT style_id, style_name, style_copyright
FROM ' . STYLES_TABLE . "
$sql_where
ORDER BY style_name";
$result = $db->sql_query($sql);
$style_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['style_id'] == $default) ? ' selected="selected"' : '';
$style_options .= '<option value="' . $row['style_id'] . '"' . $selected . '>' . $row['style_name'] . '</option>';
$template->assign_block_vars('styles', array(
'STYLE_ID' => $row['style_id'],
'STYLE_NAME' => $row['style_name'],
'STYLE_COPY' => $row['style_copyright'],
'U_STYLE' => append_sid("{$phpbb_root_path}portal.$phpEx", 'style=' . $row['style_id']),
));
}
$db->sql_freeresult($result);
$db->sql_freeresult($result);
// Assign specific vars
$template->assign_vars(array(
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['style']),
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['style']),
'S_DISPLAY_CHANGE_STYLE' => true,
));