What does this product do?
It:
- Displays a marker on posts which have gained or lost their poster reputation points. For example, a post which got a +1 and a +2 (for +3 total) would display "+3 ", whereas a post that got a -2 total would display "-2" . These icons are displayed at the top of the post, next to the
post title icon, but you can alter this to display them in a different way, different location, or not at all.
- Allows vBulletin to identify and act upon posts and threads with a low reputation score. For some ideas about how you can auto-moderate or filter posts/threads based on their reputation score, see the addons section of this mod.
Why use this mod?
- It lets your members see which posts are valued by the community, and which are not.
- It thus helps encourage members to post better content.
- It lets members identify low rep (spam, etc) posts/threads and save time by ignoring them.
- It is required for several other mods of mine, which do cool things like enable members to ignore posts with low reputation, or auto-close threads where the first post has a very negative rep score.
- Overall, it is designed to ease the load on your moderators and encourage members to take responsibility for making sure your forum discussions are high quality and stick to the forum rules.
Requirements:
- Your forum runs vBulletin 3.6.8. This mod is not supported, and may not work, on other versions of vBulletin.
- Your forum uses the legacy postbit. Or, you know enough about template edits that you can adapt some simple template edits for postbit_legacy into suitable versions for the new vertical postbit. If you do adapt the template edits, please send me your adapted versions so I can add compatibility for those people whose forums don't use the legacy postbit.
- You are not averse to product imports, file/template edits, and using "Mark as Installed". No, really, marking as installed is very important - you won't get bug fixes, updates or support unless you do this.
With regard to the install...
Note that each step of the install enables a different part of this mod. Importing the product file changes the database to support per-post reputation counters. Doing the sql queries for big boards ensures all posts in your database are updated to include this information. Doing the edits to postbit_legacy causes each post to show the reputation given to it. Editing adminreputation.php ensures that these counters are correctly updated if/when you, as an admin, manually edit or delete rep scores from the admincp. Editing the searchresults template and the search.php file enable the display of post reputation scores on search.php results pages. You can skip some of the latter steps if you want to minimize install time at the cost of some features.
To install :
Step 1 : Import the attached XML file as a product.
Step 2 : ONLY if your board has more than 10,000 posts, or 1,000 threads, run the following SQL queries via the MySQL command line :
Code:
UPDATE vb_post AS post SET post.rsum = ( SELECT SUM(reputation) FROM vb_reputation WHERE post.postid = postid);
UPDATE vb_post AS post SET post.rpos = ( SELECT SUM(reputation) FROM vb_reputation WHERE post.postid = postid AND reputation > 0);
UPDATE vb_post AS post SET post.rneg = ( SELECT SUM(reputation) FROM vb_reputation WHERE post.postid = postid AND reputation < 0);
You will of course need to replace "vb_" with whatever your database prefix is for these queries to work. These queries may take a long time to run, depending on the size of your board. Note however that you need only run them
once. After they are run, this product will function normally.
If your board has less than 100,000 posts and 10,000 threads, you can completely skip this step.
Step 3 : In forum template "postbit_legacy" find :
Code:
<if condition="$show['moderated']">
<td class="alt2" id="td_post_$post[postid]" style="border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<td class="alt1" id="td_post_$post[postid]" style="border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>
Replace this with :
Code:
<if condition="$show['moderated']">
<td class="alt2" id="td_post_$post[postid]" style="border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<if condition="$post['rsum'] == 0">
<td class="alt1" id="td_post_$post[postid]" style="border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<if condition="$post['rsum'] > 0">
<td class="alt1" id="td_post_$post[postid]" style="background-color:lightgreen; border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<td class="alt1" id="td_post_$post[postid]" style="background-color:#FAAFBE; border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>
</if>
</if>
This change will make the backgrounds of posts with overall positive rep display in "lightgreen", and the backgrounds of posts with overall negative rep display in "#FAAFBE" (pink - like red, but lighter and more readable).
This will allow users to much more easily identify high/low rep posts in threads.
Step 4 : Then find, a few lines below in postbit_legacy, find :
Code:
<if condition="$post['title']"><strong>$post[title]</strong></if>
And add underneath that :
Code:
</div>
<div align="left">
<if condition="$post['rpos'] > 0">
<img src="images/reputation/reputation_pos.gif" /><font color='green' size='+1'><B>+$post[rpos]</B></font>
</if>
<if condition="$post['rneg'] < 0">
<img src="images/reputation/reputation_neg.gif" /><font color='red' size='+1'><B>$post[rneg]</B></font>
</if>
This edit ensures that posts which have got reputation will display little markers to indicate exactly what reputation they have got. Feel free to display it differently if you want.
The variables you can use are :
$post['rsum'] : the positive rep the post has got, minus the negative rep it has got
$post['rpos'] : the positive rep the post has got
$post['rneg'] : the negative rep the post has got
Step 5 : In forum file admincp/adminreputation.php :
After :
Code:
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "reputation
WHERE reputationid = " . $vbulletin->GPC['reputationid']
);
Add :
Code:
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rsum =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
)
WHERE postid = $repinfo[postid];
");
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rpos =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
AND reputation > 0
)
WHERE postid = $repinfo[postid];
");
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rneg =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
AND reputation < 0
)
WHERE postid = $repinfo[postid];
");
Step 6 : In forum file admincp/adminreputation.php :
Before :
Code:
define('CP_REDIRECT', "adminreputation.php?do=list&u=" . $vbulletin->GPC['userid']);
print_stop_message('saved_reputation_successfully');
Add :
Code:
$rid = $vbulletin->GPC['reputationid'];
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rsum =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
)
WHERE postid =
(
SELECT postid
FROM " . TABLE_PREFIX . "reputation
where postid =
(
SELECT postid
from " . TABLE_PREFIX . "reputation
where reputationid = $rid
)
)
");
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rpos =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
AND reputation > 0
)
WHERE postid =
(
SELECT postid
FROM " . TABLE_PREFIX . "reputation
where postid =
(
SELECT postid
from " . TABLE_PREFIX . "reputation
where reputationid = $rid
)
)
");
$db->query_write("
UPDATE " . TABLE_PREFIX . "post AS post
SET post.rneg =
(
SELECT SUM(reputation)
FROM " . TABLE_PREFIX . "reputation
WHERE post.postid = postid
AND reputation < 0
)
WHERE postid =
(
SELECT postid
FROM " . TABLE_PREFIX . "reputation
where postid =
(
SELECT postid
from " . TABLE_PREFIX . "reputation
where reputationid = $rid
)
)
");
These edits to admincp/adminreputation.php ensure that, when an admin deletes or edits a reputation scoring, the rep score of the post it was given to is correctly updated.
Step 7 : In forum template "search_results_postbit", Find :
Code:
<if condition="$post[posticon]"><img class="inlineimg" src="$post[posticonpath]" alt="$post[posticontitle]" border="0" /></if>
Insert afterwards :
Code:
<if condition="$post['rpos'] > 0">
<img src="images/reputation/reputation_pos.gif" /><font color='green' size='+1'><B>+$post[rpos]</B></font>
</if>
<if condition="$post['rneg'] < 0">
<img src="images/reputation/reputation_neg.gif" /><font color='red' size='+1'><B>$post[rneg]</B></font>
</if>
Step 8 : In forum file "search.php" (forum root directory)
Find :
Code:
$dataQuery = "
SELECT post.postid, post.title AS posttitle, post.dateline AS postdateline,
post.iconid AS posticonid, post.pagetext, post.visible, post.attach,
Replace with :
Code:
$dataQuery = "
SELECT post.postid, post.title AS posttitle, post.dateline AS postdateline,
post.iconid AS posticonid, post.pagetext, post.visible, post.attach, post.rsum, post.rpos, post.rneg,
Then find :
Code:
($hook = vBulletinHook::fetch_hook('search_results_query_threads')) ? eval($hook) : false;
// query thread data
$dataQuery = "
SELECT $previewfield
thread.threadid, thread.threadid AS postid, thread.title AS threadtitle, thread.iconid AS threadiconid, thread.dateline, thread.forumid,
thread.replycount, IF(thread.views=0, thread.replycount+1, thread.views) as views, thread.sticky,
thread.pollid, thread.open, thread.lastpost AS postdateline, thread.visible, thread.hiddencount, thread.deletedcount,
$lastpost_info, thread.attach, thread.postusername, thread.forumid,
And insert below :
Code:
(SELECT rsum FROM vb_post where thread.firstpostid = postid) AS rsum,
(SELECT rpos FROM vb_post where thread.firstpostid = postid) AS rpos,
(SELECT rneg FROM vb_post where thread.firstpostid = postid) AS rneg,
Step 10 : In file forumdisplay.php, find :
Code:
$threads = $db->query_read_slave("
SELECT $votequery $previewfield
thread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, replycount, postusername, postuserid, thread.iconid AS threadiconid,
$lastpost_info2, thread.dateline, IF(views<=replycount, replycount+1, views) AS views, notes, thread.visible, sticky, votetotal, thread.attach,
hiddencount, deletedcount
Replace with :
Code:
$threads = $db->query_read_slave("
SELECT $votequery $previewfield
thread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, replycount, postusername, postuserid, thread.iconid AS threadiconid,
$lastpost_info2, thread.dateline, IF(views<=replycount, replycount+1, views) AS views, notes, thread.visible, sticky, votetotal, thread.attach,
hiddencount, deletedcount,
(SELECT rsum FROM " . TABLE_PREFIX . "post where thread.firstpostid = postid) AS rsum,
(SELECT rpos FROM " . TABLE_PREFIX . "post where thread.firstpostid = postid) AS rpos,
(SELECT rneg FROM " . TABLE_PREFIX . "post where thread.firstpostid = postid) AS rneg
The addition of the bit referencing rsum/rpos/rneg causes $thread['rpos'], rsum, and rneg to be defined in the threadbit template, meaning you can now do custom thread markup on threads based on the reputation given to the first post in that thread.
Step 11 : In template threadbit, find :
Code:
<td class="alt1" id="td_threadtitle_$thread[realthreadid]" title="$thread[preview]">
$thread[title_editable]
<div>
Add underneath :
Code:
<if condition="$thread['rpos'] > 0">
<font color='green' size='-1'><B>+$thread[rpos]</B></font>
</if>
<if condition="$thread['rneg'] < 0">
<font color='red' size='-1'><B>$thread[rneg]</B></font>
</if>
This gives a small, iconless green "+X" or "-X" to threads where the first post in the thread has been given positive or negative reputation.
Step 12 : Make sure you have clicked the
Mark as Installed button on the top right of this page.
This is important, as only people who have marked the mod as installed will be informed about critical updates to the mod. Since I have several updates planned, rest assured that
you want to be informed about updates.
SQL Queries
This product adds a few queries to your board.
These queries should not slow down your board, because they only occur in relatively rare situations.
Here are the details of the queries :
- 4 queries whenever a member submits a reputation scoring.
- 3 queries whenever an admin manually deletes or edits a reputation scoring.