From a869084f87358cb397d6a32ed0cc60edb020dba0 Mon Sep 17 00:00:00 2001 From: "Janus B. Kristensen" Date: Thu, 6 Jan 2005 11:47:44 +0000 Subject: [PATCH] Users can ignore other users in the forums svn path=/trunk/boinc/; revision=4999 --- html/inc/forum.inc | 20 +++++++++++++---- html/user/edit_forum_preferences_action.php | 24 ++++++++++++++++++++- html/user/edit_forum_preferences_form.php | 21 ++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/html/inc/forum.inc b/html/inc/forum.inc index ea124cbc91..2eccbff54e 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -228,6 +228,7 @@ function getForumPreferences($user){ $user->rated_posts=$prefs->rated_posts; $user->low_rating_threshold=$prefs->low_rating_threshold; $user->high_rating_threshold=$prefs->high_rating_threshold; + $user->ignorelist=$prefs->ignorelist; $user->forum_preferences=1; //Set defaults in certain cases: @@ -459,8 +460,18 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS $data = mysql_query("SELECT userid FROM profile WHERE userid = " . $user->id); //Lookup existance of profile for user $user->has_profile = (mysql_numrows($data) > 0); //and store this info in the user object $user->has_avatar = ($user->avatar != ""); //for later access - $rated_below_threshold = ($logged_in_user->low_rating_threshold>($post->score*$post->votes)); - $rated_above_threshold = ($logged_in_user->high_rating_threshold<($post->score*$post->votes)); + + //If the user that made this post is on the list of people to ignore, change thresholds to be more strict + + if (in_array($user->id,explode("|",$logged_in_user->ignorelist))){ + $user_is_on_ignorelist=true; + $rated_below_threshold = ($logged_in_user->high_rating_threshold>($post->score*$post->votes)); + $rated_above_threshold = ($logged_in_user->high_rating_threshold+abs($logged_in_user->low_rating_threshold)<($post->score*$post->votes)); + } else { //Use normal threshold values + $rated_below_threshold = ($logged_in_user->low_rating_threshold>($post->score*$post->votes)); + $rated_above_threshold = ($logged_in_user->high_rating_threshold<($post->score*$post->votes)); + } + $can_edit = $logged_in_user && $user->id == $logged_in_user->id; @@ -527,7 +538,8 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS if ($can_edit && $controls != NO_CONTROLS) echo " id\">[Edit this post]"; if ($post->modified) echo "
Last modified: ", pretty_time_Str($post->modified); if ($rated_below_threshold && $filter){ - echo "
This post has been filtered (rating: ".($post->score * $post->votes)."), press id."&filter=false#".$post->id."\">here to view this thread without filtering"; + if ($user_is_on_ignorelist) $andtext=" and the user is on your ignore list"; + echo "
This post has been filtered (rating: ".($post->score * $post->votes).")$andtext, press id."&filter=false#".$post->id."\">here to view this thread without filtering"; } echo "\n\n"; @@ -555,7 +567,7 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS echo ""; } - if (!$filter || !$rated_below_threshold){ + if (!$filter || !$rated_below_threshold){ //If either filtering is turned off of this post is not below the threshold $posttext=nl2br(stripslashes($post->content)); if ($post->signature && !$logged_in_user->hide_signatures){ //If the creator of this post has a signature and $posttext.=nl2br("\n".stripslashes($user->signature)); //wants it to be shown for this post AND the logged in diff --git a/html/user/edit_forum_preferences_action.php b/html/user/edit_forum_preferences_action.php index 532b73a946..bd08d75a59 100644 --- a/html/user/edit_forum_preferences_action.php +++ b/html/user/edit_forum_preferences_action.php @@ -5,9 +5,12 @@ require_once("../inc/user.inc"); require_once("../inc/profile.inc"); require_once("../inc/util.inc"); require_once("../inc/image.inc"); +require_once("../inc/forum.inc"); + db_init(); $user = get_logged_in_user(); +$user = getForumPreferences($user); $avatar_url = mysql_escape_string($HTTP_POST_VARS["avatar_url"]); if (substr($avatar_url,0,4)!="http") $avatar_url="http://".$avatar_url; @@ -51,7 +54,7 @@ $hide_signatures = ($HTTP_POST_VARS["forum_hide_signatures"]!=""); $jump_to_unread = ($HTTP_POST_VARS["forum_jump_to_unread"]!=""); $low_rating_threshold = intval($HTTP_POST_VARS["forum_low_rating_threshold"]); $high_rating_threshold = intval($HTTP_POST_VARS["forum_high_rating_threshold"]); - +$add_user_to_filter = ($HTTP_POST_VARS["add_user_to_filter"]!=""); $no_signature_by_default=($HTTP_POST_VARS["signature_enable"]==""); $signature = sanitize_html(stripslashes($HTTP_POST_VARS["signature"])); @@ -68,6 +71,24 @@ $answer_sort = $HTTP_POST_VARS["answer_sort"]; $forum_sorting=mysql_escape_string(implode("|",array($forum_sort,$thread_sort,$faq_sort,$answer_sort))); $has_prefs=mysql_query("select * from forum_preferences where userid='".$user->id."'"); +if ($add_user_to_filter){ //see if we should add any users to the ignorelist + $user_to_add = $HTTP_POST_VARS["forum_filter_user"]; + if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ + $ignorelist = $user->ignorelist."|".$user_to_add; + } else { + $ignorelist = $user->ignorelist; + } +} +$ignored_users = explode("|",$ignorelist); +for ($i=1;$iid" ); diff --git a/html/user/edit_forum_preferences_form.php b/html/user/edit_forum_preferences_form.php index c523c36e3b..8fceb4aedb 100644 --- a/html/user/edit_forum_preferences_form.php +++ b/html/user/edit_forum_preferences_form.php @@ -94,6 +94,27 @@ row2("Filtering". " ); +$filtered_userlist=explode("|",$user->ignorelist); +for ($i=1;$i ".$filtered_userlist[$i]." - ".user_links($filtered_user,URL_BASE)."
"; +} +row2("Filtered users". + "
Ignore specific users
You can define a list of users to ignore.
These users will have to write posts with very high
rating in order to not be filtered.
", + "
+ $forum_filtered_userlist +
+ + + + +
Userid (For instance: 123456789)
+ Please note that you can only filter a limited number of users. +
+ " +); + + if ($user->no_signature_by_default==0){$enable_signature="checked=\"checked\"";} else {$enable_signature="";} $signature=stripslashes($user->signature);