From 265c621c9ede226cf50140057c5184245d4bf779 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 15:20:46 +0200 Subject: [PATCH 1/7] [ticket/12408] Add quick setting for "default guest style" to ACP PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 56 +++++++++++++++++++++++++++++++- phpBB/language/en/acp/board.php | 3 ++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index f2707f15ca..cd3d2aa8ff 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -65,7 +65,8 @@ class acp_board 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true), - 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false), + 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true), + 'default_guest_style' => array('lang' => 'DEFAULT_GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), 'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'WARNINGS', @@ -509,6 +510,14 @@ class acp_board continue; } + if ($config_name == 'default_guest_style') + { + if (isset($cfg_array[$config_name])) { + $this->guest_style_set($cfg_array[$config_name]); + } + continue; + } + $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($config_name == 'email_function_name') @@ -912,6 +921,51 @@ class acp_board return ''; } + /** + * Get default guest style + */ + function guest_style_get() + { + global $db; + + $style = false; + + $sql_array = array( + 'SELECT' => 'u.user_style', + 'FROM' => array( + USERS_TABLE => 'u', + ), + 'WHERE' => 'u.user_id = ' . ANONYMOUS, + ); + + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query_limit($sql, 1); + + while ($row = $db->sql_fetchrow($result)) + { + $style = (isset($row['user_style'])) ? $row['user_style'] : false; + } + + return $style; + } + + /** + * Set default guest style + */ + function guest_style_set($style_id) + { + global $db; + + $sql_ary = array( + 'user_style' => $style_id, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . ANONYMOUS; + $db->sql_query($sql); + } + /** * Select default dateformat */ diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index d451bdd515..3008797a84 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -46,6 +46,9 @@ $lang = array_merge($lang, array( 'DEFAULT_DATE_FORMAT_EXPLAIN' => 'The date format is the same as the PHP date function.', 'DEFAULT_LANGUAGE' => 'Default language', 'DEFAULT_STYLE' => 'Default style', + 'DEFAULT_STYLE_EXPLAIN' => 'The default board style for logged in users.', + 'DEFAULT_GUEST_STYLE' => 'Default guest style', + 'DEFAULT_GUEST_STYLE_EXPLAIN' => 'The default board style for guests.', 'DISABLE_BOARD' => 'Disable board', 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.', 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', From ae63843647d309d2deb2863189699212e9a3aa27 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 15:48:17 +0200 Subject: [PATCH 2/7] [ticket/12408] Simplified queries PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index cd3d2aa8ff..fd09cab94c 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -930,21 +930,13 @@ class acp_board $style = false; - $sql_array = array( - 'SELECT' => 'u.user_style', - 'FROM' => array( - USERS_TABLE => 'u', - ), - 'WHERE' => 'u.user_id = ' . ANONYMOUS, - ); - - $sql = $db->sql_build_query('SELECT', $sql_array); + $sql = 'SELECT u.user_style + FROM ' . USERS_TABLE . ' u + WHERE u.user_id = ' . ANONYMOUS; $result = $db->sql_query_limit($sql, 1); - while ($row = $db->sql_fetchrow($result)) - { - $style = (isset($row['user_style'])) ? $row['user_style'] : false; - } + $style = (int) $db->sql_fetchfield('user_style'); + $db->sql_freeresult($result); return $style; } @@ -961,8 +953,8 @@ class acp_board ); $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . ANONYMOUS; + SET user_style = ' . $style_id . ' + WHERE user_id = ' . ANONYMOUS; $db->sql_query($sql); } From 60c9955f514fcd5e5cde650bb7be0cf051b89b95 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 17:04:18 +0200 Subject: [PATCH 3/7] [ticket/12408] Code cleanup Rebased to see if travis will finally play along PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index fd09cab94c..3a07978ac4 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -927,13 +927,11 @@ class acp_board function guest_style_get() { global $db; - - $style = false; - $sql = 'SELECT u.user_style - FROM ' . USERS_TABLE . ' u - WHERE u.user_id = ' . ANONYMOUS; - $result = $db->sql_query_limit($sql, 1); + $sql = 'SELECT user_style + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . ANONYMOUS; + $result = $db->sql_query($sql); $style = (int) $db->sql_fetchfield('user_style'); $db->sql_freeresult($result); @@ -948,12 +946,8 @@ class acp_board { global $db; - $sql_ary = array( - 'user_style' => $style_id, - ); - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . $style_id . ' + SET user_style = ' . (int) $style_id . ' WHERE user_id = ' . ANONYMOUS; $db->sql_query($sql); } From 0b4944f1254ce07b9cd81fb0d7d6158672a9eac0 Mon Sep 17 00:00:00 2001 From: PayBas Date: Thu, 8 May 2014 15:33:16 +0200 Subject: [PATCH 4/7] [ticket/12408] Public functions and updated doc block PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 3a07978ac4..77a0f56e5a 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -924,7 +924,7 @@ class acp_board /** * Get default guest style */ - function guest_style_get() + public function guest_style_get() { global $db; @@ -941,8 +941,10 @@ class acp_board /** * Set default guest style + * + * @param int $style_id The style ID */ - function guest_style_set($style_id) + public function guest_style_set($style_id) { global $db; From aaddf41e5b105c6e1b57a5e75267db69576afdf6 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sat, 24 May 2014 16:01:08 +0200 Subject: [PATCH 5/7] [ticket/12408] Changed lang vars, added fieldset and removed "default" PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 14 ++++++++------ phpBB/language/en/acp/board.php | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 77a0f56e5a..4cc579c256 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -65,14 +65,16 @@ class acp_board 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true), + + 'legend2' => 'BOARD_STYLE', 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true), - 'default_guest_style' => array('lang' => 'DEFAULT_GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), + 'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), 'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'legend2' => 'WARNINGS', + 'legend3' => 'WARNINGS', 'warnings_expire_days' => array('lang' => 'WARNINGS_EXPIRE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - 'legend3' => 'ACP_SUBMIT_CHANGES', + 'legend4' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -510,7 +512,7 @@ class acp_board continue; } - if ($config_name == 'default_guest_style') + if ($config_name == 'guest_style') { if (isset($cfg_array[$config_name])) { $this->guest_style_set($cfg_array[$config_name]); @@ -922,7 +924,7 @@ class acp_board } /** - * Get default guest style + * Get guest style */ public function guest_style_get() { @@ -940,7 +942,7 @@ class acp_board } /** - * Set default guest style + * Set guest style * * @param int $style_id The style ID */ diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 3008797a84..07bf927936 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -41,18 +41,19 @@ $lang = array_merge($lang, array( 'ACP_BOARD_SETTINGS_EXPLAIN' => 'Here you can determine the basic operation of your board, give it a fitting name and description, and among other settings adjust the default values for timezone and language.', 'BOARD_INDEX_TEXT' => 'Board index text', 'BOARD_INDEX_TEXT_EXPLAIN' => 'This text is displayed as the board index in the board’s breadcrumbs. If not specified, it will default to “Board index”.', + 'BOARD_STYLE' => 'Board style', 'CUSTOM_DATEFORMAT' => 'Custom…', 'DEFAULT_DATE_FORMAT' => 'Date format', 'DEFAULT_DATE_FORMAT_EXPLAIN' => 'The date format is the same as the PHP date function.', 'DEFAULT_LANGUAGE' => 'Default language', 'DEFAULT_STYLE' => 'Default style', - 'DEFAULT_STYLE_EXPLAIN' => 'The default board style for logged in users.', - 'DEFAULT_GUEST_STYLE' => 'Default guest style', - 'DEFAULT_GUEST_STYLE_EXPLAIN' => 'The default board style for guests.', + 'DEFAULT_STYLE_EXPLAIN' => 'The default style for new users.', 'DISABLE_BOARD' => 'Disable board', 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.', 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', + 'GUEST_STYLE' => 'Guest style', + 'GUEST_STYLE_EXPLAIN' => 'The board style for guests.', 'OVERRIDE_STYLE' => 'Override user style', 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s style with the default.', 'SITE_DESC' => 'Site description', From 5a780dfab1ba972bc116b4fdd4e8dfa186f9c74a Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 15 Sep 2014 14:49:56 +0200 Subject: [PATCH 6/7] [ticket/12408] Clarify the behavior of "override style" PHPBB3-12408 --- phpBB/language/en/acp/board.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 07bf927936..2e4f89a6ae 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -55,7 +55,7 @@ $lang = array_merge($lang, array( 'GUEST_STYLE' => 'Guest style', 'GUEST_STYLE_EXPLAIN' => 'The board style for guests.', 'OVERRIDE_STYLE' => 'Override user style', - 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s style with the default.', + 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s (and guest’s) style with the style as defined under "Default style".', 'SITE_DESC' => 'Site description', 'SITE_HOME_TEXT' => 'Main website text', 'SITE_HOME_TEXT_EXPLAIN' => 'This text will be displayed as a link to your website homepage in the board’s breadcrumbs. If not specified, it will default to “Home”.', From 0061a305d8b440995d11ec48c5ae81fc6023ad7e Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 15 Sep 2014 15:25:43 +0200 Subject: [PATCH 7/7] [ticket/12408] Fix white-space sniffer PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 4cc579c256..a8b72f6c0b 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -65,7 +65,7 @@ class acp_board 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true), - + 'legend2' => 'BOARD_STYLE', 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true), 'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), @@ -930,7 +930,7 @@ class acp_board { global $db; - $sql = 'SELECT user_style + $sql = 'SELECT user_style FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS; $result = $db->sql_query($sql);