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 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) {