diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-10-07 21:31:42 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-10-07 21:31:42 +0200 |
commit | c75c13e5554652927a8aa57bd3b9f3902f57b429 (patch) | |
tree | 5b3417e0c8246115c23ef4785a2190c6b4cadd95 /phpBB/phpbb/user.php | |
parent | 4ce8604700bdf0c74eb4f6c1e8907114f6083943 (diff) | |
parent | a84e4b5ab4cdbbb241004e5c1621b42490e6ba94 (diff) | |
download | forums-c75c13e5554652927a8aa57bd3b9f3902f57b429.tar forums-c75c13e5554652927a8aa57bd3b9f3902f57b429.tar.gz forums-c75c13e5554652927a8aa57bd3b9f3902f57b429.tar.bz2 forums-c75c13e5554652927a8aa57bd3b9f3902f57b429.tar.xz forums-c75c13e5554652927a8aa57bd3b9f3902f57b429.zip |
Merge pull request #5671 from 3D-I/ticket/16144
[ticket/16144] Fallback to board's default style
Diffstat (limited to 'phpBB/phpbb/user.php')
-rw-r--r-- | phpBB/phpbb/user.php | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 7363290e11..9817e40edb 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -281,9 +281,43 @@ class user extends \phpbb\session $db->sql_freeresult($result); } + // Fallback to board's default style 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); + + 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 happen + 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 |