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.
This commit is contained in:
David Anderson 2014-04-18 15:54:28 -07:00
parent b18fffc249
commit af99251e79
28 changed files with 112 additions and 35 deletions

View File

@ -37,7 +37,7 @@ function news_item($date, $title, $post) {
<span class=news_content>$text</span>
<span class=news_date>$d
";
if ($forum_link) {
if ($forum_link && !DISABLE_FORUMS) {
echo "
&middot; <a href=".URL_BASE."forum_thread.php?id=$post->thread> ".tra("Comment")."</a>
";

View File

@ -247,9 +247,11 @@ function show_community_private($user) {
}
row2(tra("Profile"), $x);
}
$tot = total_posts($user);
if ($tot) {
row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
if (!DISABLE_FORUMS) {
$tot = total_posts($user);
if ($tot) {
row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
}
}
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"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
if (!DISABLE_FORUMS) {
if ($tot) {
row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
}
}
if ($logged_in_user && $logged_in_user->id != $user->id) {
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>");

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -124,6 +124,7 @@ echo "
</td>
<td><b>User management</b>
<ul>
<li><a href=".URL_BASE."/forum_index.php>Post news item</a></li>
<li><a href=\"profile_screen_form.php\">Screen user profiles </a></li>
<li><a href=\"badge_admin.php\">Badges</a></li>
<li><a href=\"manage_special_users.php\">User privileges</a></li>
@ -134,7 +135,6 @@ echo "
ID: <input name=\"userid\">
</form>
</li>
</li>
</ul>
</td>
</tr>

View File

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

View File

@ -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"),
<input type=\"checkbox\" name=\"forum_ignore_sticky_posts\" ".$forum_ignore_sticky_posts.">".tra("Don't move sticky posts to top")."<br>
"
);
} // DISABLE_FORUMS
// ------------ Message filtering -----------

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -20,6 +20,8 @@ require_once('../inc/util.inc');
require_once('../inc/forum_db.inc');
require_once('../inc/forum_banishment_vote.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("action", "userid"));
$config = get_config();

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -21,6 +21,8 @@ require_once("../inc/util.inc");
require_once("../inc/forum_db.inc");
require_once("../inc/forum_banishment_vote.inc");
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("action", "userid", "tnow", "ttok"));
$config = get_config();

View File

@ -33,6 +33,11 @@ if (!$start) $start = 0;
$forum = BoincForum::lookup_id($id);
if (!$forum) error_page("forum ID not found");
$user = get_logged_in_user(false);
BoincForumPrefs::lookup($user);
if (DISABLE_FORUMS && !is_admin($user)) {
error_page("Forums are disabled");
}
if (!is_forum_visible_to_user($forum, $user)) {
if ($user) {
@ -41,8 +46,6 @@ if (!is_forum_visible_to_user($forum, $user)) {
error_page(tra("Not visible to you"));
}
BoincForumPrefs::lookup($user);
if (!$sort_style) {
// get the sort style either from the logged in user or a cookie
if ($user){

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -22,6 +22,10 @@ require_once("../inc/xml.inc");
xml_header();
if (DISABLE_FORUMS) {
xml_error(-1, "Forums are disabled");
}
$retval = db_init_xml();
if ($retval) xml_error($retval);

View File

@ -20,6 +20,8 @@ require_once('../inc/forum.inc');
require_once('../inc/util.inc');
require_once('../inc/time.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array());
$user = get_logged_in_user(false);

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -26,6 +26,11 @@ require_once('../inc/time.inc');
check_get_args(array("read", "return", "tnow", "ttok"));
$user = get_logged_in_user(false);
BoincForumPrefs::lookup($user);
if (DISABLE_FORUMS && !is_admin($user)) {
error_page("Forums are disabled");
}
// Process request to mark all posts as read
//

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -18,11 +18,14 @@
// The form where a moderator decides what he is going to do to a post.
// Submits informaiton to forum_moderate_post_action.php for actual action
// Submits information to forum_moderate_post_action.php for actual action
// to be done.
require_once('../inc/util.inc');
require_once('../inc/forum.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("id", "action", "userid", "tnow", "ttok"));
$logged_in_user = get_logged_in_user();

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -16,9 +16,12 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
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() {

View File

@ -16,6 +16,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
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");
}

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -16,6 +16,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
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');

View File

@ -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."));
}

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -21,6 +21,8 @@
require_once('../inc/forum.inc');
require_once('../inc/util.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
$config = get_config();
if (parse_bool($config, "no_forum_rating")) {
page_head(tra("Rating offline"));

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -19,11 +19,14 @@
// Post a reply to a thread.
// Both input (form) and action take place here.
require_once('../inc/util.inc');
require_once('../inc/forum_email.inc');
require_once('../inc/forum.inc');
require_once('../inc/bbcode_html.inc');
require_once('../inc/akismet.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
$logged_in_user = get_logged_in_user(true);
BoincForumPrefs::lookup($logged_in_user);
check_banished($logged_in_user);

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -21,9 +21,12 @@
// For this file to work the project must have defined who
// should receive such reports (in the configuration file)
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("post", "submit", "reason", "tnow", "ttok"));
$postId = get_int('post');

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -24,10 +24,12 @@
// Else enumerate threads by decreasing timestamp,
// and show the post with latest timestamp for each
require_once("../project/project.inc");
require_once("../inc/util.inc");
require_once("../inc/boinc_db.inc");
require_once("../inc/forum_rss.inc");
if (DISABLE_FORUMS) error_page("Forums are disabled");
$forumid = get_int('forumid');
$forum = BoincForum::lookup_id($forumid);
if (!$forum) error_page("no such forum");

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -22,6 +22,8 @@
require_once('../inc/forum.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("forumid"));
page_head(tra("Forum search"));

View File

@ -23,6 +23,8 @@ require_once('../inc/time.inc');
require_once('../inc/text_transform.inc');
require_once('../inc/forum.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array());
// Searches for the keywords in the $keyword_list array in thread titles.

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -22,6 +22,8 @@
require_once('../inc/forum.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("action", "thread", "tnow", "ttok"));
$action = get_str('action');

View File

@ -37,12 +37,17 @@ if ($filter != "false"){
}
$logged_in_user = get_logged_in_user(false);
$tokens = "";
if ($logged_in_user) {
BoincForumPrefs::lookup($logged_in_user);
$tokens = url_tokens($logged_in_user->authenticator);
}
if (DISABLE_FORUMS && !is_admin($logged_in_user)) {
error_page("Forums are disabled");
}
if ($threadid < 1) {
error_page("Invalid thread ID!");
}

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -28,6 +28,11 @@ $thread = BoincThread::lookup_id($threadid);
if (!$thread) error_page("no such thread");
$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");
}
$owner = BoincUser::lookup_id($thread->owner);
if ($logged_in_user->id == $owner->id){

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -21,6 +21,8 @@
require_once('../inc/forum.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("id"));
$threadid = get_int('id');

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -21,6 +21,8 @@ require_once('../inc/time.inc');
require_once('../inc/forum.inc');
require_once('../inc/user.inc');
if (DISABLE_FORUMS) error_page("Forums are disabled");
check_get_args(array("userid", "offset"));
$userid = get_int("userid");

View File

@ -1,7 +1,7 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2014 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -22,10 +22,6 @@
// my developing your own stylesheet
// and customizing the header/footer functions in html/project/project.inc
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/news.inc");