mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-30 04:58:37 +01:00
[ticket/16144] Provide extra fallback to board's default style for $user
PHPBB3-16144
This commit is contained in:
parent
9c15594fe4
commit
3e23adf030
@ -519,7 +519,7 @@ $lang = array_merge($lang, array(
|
||||
'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.',
|
||||
'NO_FEED_ENABLED' => 'Feeds are not available on this board.',
|
||||
'NO_FEED' => 'The requested feed is not available.',
|
||||
'NO_STYLE_DATA' => 'Could not get style data',
|
||||
'NO_STYLE_DATA' => 'Could not get style data for user_style %s and set for user_id %s',
|
||||
'NO_STYLE_CFG' => 'Could not get the style configuration file for: %s',
|
||||
'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages.
|
||||
'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.',
|
||||
|
@ -281,9 +281,48 @@ class user extends \phpbb\session
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Something went very bad this time.
|
||||
* Fallback to board's default style upon its strict verification.
|
||||
*/
|
||||
if (!$this->style)
|
||||
{
|
||||
trigger_error('NO_STYLE_DATA', E_USER_ERROR);
|
||||
/** Verify default style exists in the database */
|
||||
$sql = 'SELECT style_id
|
||||
FROM ' . STYLES_TABLE . '
|
||||
WHERE style_id = ' . (int) $config['default_style'];
|
||||
$result = $db->sql_query($sql);
|
||||
$style_id = (int) $db->sql_fetchfield('style_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$style_id = $style_id ?: false;
|
||||
|
||||
if ($style_id > 0)
|
||||
{
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
/** Update $user row */
|
||||
$sql = 'SELECT *
|
||||
FROM ' . STYLES_TABLE . '
|
||||
WHERE style_id = ' . (int) $config['default_style'];
|
||||
$result = $db->sql_query($sql);
|
||||
$this->style = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
/** Update user style preference */
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_style = ' . (int) $style_id . '
|
||||
WHERE user_id = ' . (int) $this->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
}
|
||||
}
|
||||
|
||||
/** This should never happens */
|
||||
if (!$this->style)
|
||||
{
|
||||
trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Now parse the cfg file and cache it
|
||||
|
Loading…
x
Reference in New Issue
Block a user