From 3fbdb2f345cc5fb132755033ba3b9d2fa061218e Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 04:30:48 +0200 Subject: [ticket/16019] Deny prosilver's uninstallation PHPBB3-16019 --- phpBB/includes/acp/acp_styles.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 1bf5a3c6a8..1983dff1cc 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -289,6 +289,14 @@ class acp_styles { global $user, $phpbb_log; + // Don't remove prosilver, you can still deactivate it. + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . " + WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'"; + $result = $this->db->sql_query($sql); + $prosilver_id = (int) $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + $default = $this->default_style; $uninstalled = array(); $messages = array(); @@ -296,6 +304,10 @@ class acp_styles // Check styles list foreach ($ids as $id) { + if ($id == $prosilver_id) + { + trigger_error($this->user->lang['UNINSTALL_PROSILVER'] . adm_back_link($this->u_action), E_USER_WARNING); + } if (!$id) { trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -- cgit v1.2.1 From af84fb71e065c99f94dd4781f42fc55e923821cf Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 04:59:29 +0200 Subject: [ticket/16019] Move code to before of confirm box is submitted PHPBB3-16019 --- phpBB/includes/acp/acp_styles.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 1983dff1cc..16ad8c5320 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -259,6 +259,19 @@ class acp_styles // Get list of styles to uninstall $ids = $this->request_vars('id', 0, true); + // Don't remove prosilver, you can still deactivate it. + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . " + WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'"; + $result = $this->db->sql_query($sql); + $prosilver_id = (int) $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (in_array($prosilver_id, $ids)) + { + trigger_error($this->user->lang['UNINSTALL_PROSILVER'] . adm_back_link($this->u_action), E_USER_WARNING); + } + // Check if confirmation box was submitted if (confirm_box(true)) { @@ -289,14 +302,6 @@ class acp_styles { global $user, $phpbb_log; - // Don't remove prosilver, you can still deactivate it. - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . " - WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'"; - $result = $this->db->sql_query($sql); - $prosilver_id = (int) $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - $default = $this->default_style; $uninstalled = array(); $messages = array(); @@ -304,10 +309,6 @@ class acp_styles // Check styles list foreach ($ids as $id) { - if ($id == $prosilver_id) - { - trigger_error($this->user->lang['UNINSTALL_PROSILVER'] . adm_back_link($this->u_action), E_USER_WARNING); - } if (!$id) { trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -- cgit v1.2.1 From 6cc16af75f007745454ab658ba29c366aab86150 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 05:32:02 +0200 Subject: [ticket/16019] Amend code for the better PHPBB3-16019 --- phpBB/includes/acp/acp_styles.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 16ad8c5320..88878a9ce7 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -264,12 +264,15 @@ class acp_styles FROM ' . STYLES_TABLE . " WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'"; $result = $this->db->sql_query($sql); - $prosilver_id = (int) $this->db->sql_fetchrow($result); + $prosilver_id = (int) $this->db->sql_fetchfield('style_id'); $this->db->sql_freeresult($result); - if (in_array($prosilver_id, $ids)) + if ($prosilver_id) { - trigger_error($this->user->lang['UNINSTALL_PROSILVER'] . adm_back_link($this->u_action), E_USER_WARNING); + if (in_array($prosilver_id, $ids)) + { + trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING); + } } // Check if confirmation box was submitted -- cgit v1.2.1 From aec25f24ae3cffadd91f7b1542ce632c27030e29 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 06:07:54 +0200 Subject: [ticket/16019] Get rid of the uninstall link PHPBB3-16019 --- phpBB/includes/acp/acp_styles.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 88878a9ce7..19d3add43e 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1014,11 +1014,14 @@ class acp_styles 'L_ACTION' => $this->user->lang['EXPORT'] ); */ - // Uninstall - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] - ); + if ($style['style_name'] !== 'prosilver') + { + // Uninstall + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'], + 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] + ); + } // Preview $actions[] = array( -- cgit v1.2.1 From 463807fcf01ef96b020322faf70c6fd866d29edd Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 06:38:54 +0200 Subject: [ticket/16019] Code's enhancement PHPBB3-16019 --- phpBB/includes/acp/acp_styles.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 19d3add43e..cf8c700aad 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -267,12 +267,9 @@ class acp_styles $prosilver_id = (int) $this->db->sql_fetchfield('style_id'); $this->db->sql_freeresult($result); - if ($prosilver_id) + if ($prosilver_id && in_array($prosilver_id, $ids)) { - if (in_array($prosilver_id, $ids)) - { - trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING); - } + trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING); } // Check if confirmation box was submitted -- cgit v1.2.1