From 265c621c9ede226cf50140057c5184245d4bf779 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 15:20:46 +0200 Subject: [ticket/12408] Add quick setting for "default guest style" to ACP PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 56 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_board.php') 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 */ -- cgit v1.2.1 From ae63843647d309d2deb2863189699212e9a3aa27 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 15:48:17 +0200 Subject: [ticket/12408] Simplified queries PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/acp/acp_board.php') 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); } -- cgit v1.2.1 From 60c9955f514fcd5e5cde650bb7be0cf051b89b95 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 17:04:18 +0200 Subject: [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(-) (limited to 'phpBB/includes/acp/acp_board.php') 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); } -- cgit v1.2.1 From 0b4944f1254ce07b9cd81fb0d7d6158672a9eac0 Mon Sep 17 00:00:00 2001 From: PayBas Date: Thu, 8 May 2014 15:33:16 +0200 Subject: [ticket/12408] Public functions and updated doc block PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_board.php') 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; -- cgit v1.2.1 From aaddf41e5b105c6e1b57a5e75267db69576afdf6 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sat, 24 May 2014 16:01:08 +0200 Subject: [ticket/12408] Changed lang vars, added fieldset and removed "default" PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/acp/acp_board.php') 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 */ -- cgit v1.2.1 From 0061a305d8b440995d11ec48c5ae81fc6023ad7e Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 15 Sep 2014 15:25:43 +0200 Subject: [ticket/12408] Fix white-space sniffer PHPBB3-12408 --- phpBB/includes/acp/acp_board.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_board.php') 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); -- cgit v1.2.1