From 8c39e65a528a384fd67f1888652ab4b147256aba Mon Sep 17 00:00:00 2001 From: Ihlas Sovbetov <31760097+ihlassovbetov@users.noreply.github.com> Date: Fri, 10 Dec 2021 22:01:14 +0300 Subject: [PATCH 1/2] Update admin.php new function qa_db_has_user_visible_postids($userid) check if user has any visible posts --- qa-include/db/admin.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qa-include/db/admin.php b/qa-include/db/admin.php index 74ed2fe6c..17fbabec1 100644 --- a/qa-include/db/admin.php +++ b/qa-include/db/admin.php @@ -160,6 +160,21 @@ function qa_db_get_user_visible_postids($userid) )); } +/** + * Checks if $userid has any visible posts + * @param $userid + * @return boolen + */ +function qa_db_has_user_visible_postids($userid) +{ + return qa_db_read_one_value(qa_db_query_sub( + 'SELECT 1 + FROM ^posts + WHERE userid = $ AND type IN ('Q', 'A', 'C', 'Q_QUEUED', 'A_QUEUED', 'C_QUEUED') + LIMIT 1', + $userid + ), true); +} /** * Return list of postids of visible or queued posts from $ip address From 5ff524d0f4f16ea112eb609822e8a7b67a22aba5 Mon Sep 17 00:00:00 2001 From: Ihlas Sovbetov <31760097+ihlassovbetov@users.noreply.github.com> Date: Fri, 10 Dec 2021 22:04:22 +0300 Subject: [PATCH 2/2] Update user-profile.php first check if the user has any visible posts to hide. otherwise no need to display dohideall button. --- qa-include/pages/user-profile.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qa-include/pages/user-profile.php b/qa-include/pages/user-profile.php index e90f8990d..d311fb6e7 100644 --- a/qa-include/pages/user-profile.php +++ b/qa-include/pages/user-profile.php @@ -699,10 +699,13 @@ ); if (!qa_user_permit_error('permit_hide_show')) { - $qa_content['form_profile']['buttons']['hideall'] = array( - 'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"', - 'label' => qa_lang_html('users/hide_all_user_button'), - ); + $has_vpost = qa_db_has_user_visible_postids($useraccount['userid']); + if( $has_vpost ){ + $qa_content['form_profile']['buttons']['hideall'] = array( + 'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"', + 'label' => qa_lang_html('users/hide_all_user_button'), + ); + } } if ($loginlevel >= QA_USER_LEVEL_ADMIN) {