From af99251e79c0d83b472f1ae66575b328e223a742 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 18 Apr 2014 15:54:28 -0700 Subject: [PATCH] web: let projects disable forums Do this by putting define("DISABLE_FORUMS", true); in your html/project/project.inc. If this is set, admin users can still see enough forum functionality to post and edit news items (this is linked to from the Admin web interface). Other users, or non-logged-in access, sees news but no forums or forum-related info. --- html/inc/news.inc | 2 +- html/inc/user.inc | 14 +++++++++----- html/ops/index.php | 4 ++-- html/user/edit_forum_preferences_action.php | 11 +++++++++-- html/user/edit_forum_preferences_form.php | 2 ++ html/user/forum_banishment_vote.php | 4 +++- html/user/forum_banishment_vote_action.php | 4 +++- html/user/forum_forum.php | 7 +++++-- html/user/forum_get_data.php | 6 +++++- html/user/forum_help_desk.php | 2 ++ html/user/forum_index.php | 7 ++++++- html/user/forum_moderate_post.php | 7 +++++-- html/user/forum_moderate_post_action.php | 5 ++++- html/user/forum_moderate_thread.php | 5 +++++ html/user/forum_moderate_thread_action.php | 7 ++++++- html/user/forum_post.php | 4 ++++ html/user/forum_rate.php | 4 +++- html/user/forum_reply.php | 5 ++++- html/user/forum_report_post.php | 5 ++++- html/user/forum_rss.php | 6 ++++-- html/user/forum_search.php | 4 +++- html/user/forum_search_action.php | 2 ++ html/user/forum_subscribe.php | 4 +++- html/user/forum_thread.php | 5 +++++ html/user/forum_thread_status.php | 7 ++++++- html/user/forum_thread_vote.php | 4 +++- html/user/forum_user_posts.php | 4 +++- html/user/sample_index.php | 6 +----- 28 files changed, 112 insertions(+), 35 deletions(-) diff --git a/html/inc/news.inc b/html/inc/news.inc index 7dfc46b7a8..4aea5d8dbb 100644 --- a/html/inc/news.inc +++ b/html/inc/news.inc @@ -37,7 +37,7 @@ function news_item($date, $title, $post) { $text $d "; - if ($forum_link) { + if ($forum_link && !DISABLE_FORUMS) { echo " · thread> ".tra("Comment")." "; diff --git a/html/inc/user.inc b/html/inc/user.inc index b141d00dd1..1d619013a3 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -247,9 +247,11 @@ function show_community_private($user) { } row2(tra("Profile"), $x); } - $tot = total_posts($user); - if ($tot) { - row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); + if (!DISABLE_FORUMS) { + $tot = total_posts($user); + if ($tot) { + row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); + } } row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); @@ -373,8 +375,10 @@ function community_links($clo, $logged_in_user){ row2(tra("Team"), tra("None")); } } - if ($tot) { - row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); + if (!DISABLE_FORUMS) { + if ($tot) { + row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); + } } if ($logged_in_user && $logged_in_user->id != $user->id) { row2(tra("Contact"), "id."\">".tra("Send private message").""); diff --git a/html/ops/index.php b/html/ops/index.php index 73d10653b5..2dd6aeb72b 100644 --- a/html/ops/index.php +++ b/html/ops/index.php @@ -1,7 +1,7 @@ User management diff --git a/html/user/edit_forum_preferences_action.php b/html/user/edit_forum_preferences_action.php index 9e6c394a85..c8f7bbf58f 100644 --- a/html/user/edit_forum_preferences_action.php +++ b/html/user/edit_forum_preferences_action.php @@ -59,6 +59,13 @@ if (post_str("action", true)=="reset"){ exit; } +$pmn = post_int("pm_notification"); +if ($pmn != $user->prefs->pm_notification) { + $user->prefs->update("pm_notification=$pmn"); +} + +if (!DISABLE_FORUMS) { + $avatar_type = post_int("avatar_select"); $newfile=IMAGE_PATH.$user->id."_avatar.jpg"; @@ -108,7 +115,6 @@ $highlight_special = ($_POST["forum_highlight_special"]!="")?1:0; $jump_to_unread = ($_POST["forum_jump_to_unread"]!="")?1:0; $ignore_sticky_posts = ($_POST["forum_ignore_sticky_posts"]!="")?1:0; $no_signature_by_default = ($_POST["signature_by_default"]!="")?0:1; -$pm_notification = post_int("pm_notification"); $signature = post_str("signature", true); if (strlen($signature)>250) { error_page(tra("Your signature was too long, please keep it less than 250 characters.")); @@ -120,8 +126,9 @@ if ($display_wrap_postcount<1) $display_wrap_postcount=1; $signature = BoincDb::escape_string($signature); -$user->prefs->update("images_as_links=$images_as_links, link_popup=$link_popup, hide_avatars=$hide_avatars, hide_signatures=$hide_signatures, highlight_special=$highlight_special, jump_to_unread=$jump_to_unread, ignore_sticky_posts=$ignore_sticky_posts, no_signature_by_default=$no_signature_by_default, pm_notification=$pm_notification, avatar='$avatar_url', signature='$signature', forum_sorting=$forum_sort, thread_sorting=$thread_sort, display_wrap_postcount=$display_wrap_postcount"); +$user->prefs->update("images_as_links=$images_as_links, link_popup=$link_popup, hide_avatars=$hide_avatars, hide_signatures=$hide_signatures, highlight_special=$highlight_special, jump_to_unread=$jump_to_unread, ignore_sticky_posts=$ignore_sticky_posts, no_signature_by_default=$no_signature_by_default, avatar='$avatar_url', signature='$signature', forum_sorting=$forum_sort, thread_sorting=$thread_sort, display_wrap_postcount=$display_wrap_postcount"); +} // DISABLE_FORUMS $add_user_to_filter = ($_POST["add_user_to_filter"]!=""); if ($add_user_to_filter){ diff --git a/html/user/edit_forum_preferences_form.php b/html/user/edit_forum_preferences_form.php index ce07917d07..4936eefaa8 100644 --- a/html/user/edit_forum_preferences_form.php +++ b/html/user/edit_forum_preferences_form.php @@ -60,6 +60,7 @@ row2( " ); +if (!DISABLE_FORUMS) { // ------------ Forum identity ----------- $select_0 = $select_1 = $select_2 = ""; @@ -142,6 +143,7 @@ row2(tra("How to sort"), ".tra("Don't move sticky posts to top")."
" ); +} // DISABLE_FORUMS // ------------ Message filtering ----------- diff --git a/html/user/forum_banishment_vote.php b/html/user/forum_banishment_vote.php index 2ef252faeb..d28b439f38 100644 --- a/html/user/forum_banishment_vote.php +++ b/html/user/forum_banishment_vote.php @@ -1,7 +1,7 @@ . +require_once("../inc/util.inc"); require_once("../inc/forum.inc"); require_once("../inc/forum_email.inc"); +if (DISABLE_FORUMS) error_page("Forums are disabled"); + check_get_args(array("id", "action", "tnow", "ttok")); function mod_comment() { diff --git a/html/user/forum_moderate_thread.php b/html/user/forum_moderate_thread.php index 4e59a035c5..6fac18f5b5 100644 --- a/html/user/forum_moderate_thread.php +++ b/html/user/forum_moderate_thread.php @@ -16,6 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . +require_once('../inc/util.inc'); require_once('../inc/forum.inc'); check_get_args(array("action", "thread", "ttok", "tnow")); @@ -23,6 +24,10 @@ check_get_args(array("action", "thread", "ttok", "tnow")); $logged_in_user = get_logged_in_user(); BoincForumPrefs::lookup($logged_in_user); +if (DISABLE_FORUMS && !is_admin($logged_in_user)) { + error_page("Forums are disabled"); +} + if (!get_str('action')) { error_page("unknown action"); } diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index 6d2dac5b40..c8ae526366 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -1,7 +1,7 @@ . +require_once("../inc/util.inc"); require_once("../inc/forum.inc"); require_once("../inc/forum_email.inc"); @@ -24,6 +25,10 @@ check_get_args(array("action", "thread", "tnow", "ttok")); $logged_in_user = get_logged_in_user(); check_tokens($logged_in_user->authenticator); BoincForumPrefs::lookup($logged_in_user); +if (DISABLE_FORUMS && !is_admin($logged_in_user)) { + error_page("Forums are disabled"); +} + $action = post_str('action', true); if (!$action) { $action = get_str('action'); diff --git a/html/user/forum_post.php b/html/user/forum_post.php index a00102701b..be7060aa4b 100644 --- a/html/user/forum_post.php +++ b/html/user/forum_post.php @@ -36,6 +36,10 @@ check_banished($logged_in_user); $forumid = get_int("id"); $forum = BoincForum::lookup_id($forumid); +if (DISABLE_FORUMS && !is_admin($logged_in_user)) { + error_page("Forums are disabled"); +} + if (!user_can_create_thread($logged_in_user, $forum)) { error_page(tra("Only project admins may create a thread here. However, you may reply to existing threads.")); } diff --git a/html/user/forum_rate.php b/html/user/forum_rate.php index ed9e866760..771cef2829 100644 --- a/html/user/forum_rate.php +++ b/html/user/forum_rate.php @@ -1,7 +1,7 @@ authenticator); } +if (DISABLE_FORUMS && !is_admin($logged_in_user)) { + error_page("Forums are disabled"); +} + if ($threadid < 1) { error_page("Invalid thread ID!"); } diff --git a/html/user/forum_thread_status.php b/html/user/forum_thread_status.php index 84f1824029..d0ba6dcb57 100644 --- a/html/user/forum_thread_status.php +++ b/html/user/forum_thread_status.php @@ -1,7 +1,7 @@ owner); if ($logged_in_user->id == $owner->id){ diff --git a/html/user/forum_thread_vote.php b/html/user/forum_thread_vote.php index e03611fd10..66950dfa5f 100644 --- a/html/user/forum_thread_vote.php +++ b/html/user/forum_thread_vote.php @@ -1,7 +1,7 @@