PDA

View Full Version : [Not-even-mini-RELEASE v2] Prune doesn't reduce user post count



tubedogg
Tue 27th Mar '01, 2:45am
Someone mentioned this in the other forum (I think it was Castel). It's hardly a hack, as it consists of commenting out 3 lines, but here's how to do it:

In functions.php (in the /admin directory) find

// ###################### Start delete thread #######################
It should be around line 1450, somewhere in there. Now, a few lines below that, find

if ($countposts) {
$DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$post[userid]'");
}
and replace it with

// if ($countposts) {
// $DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$post[userid]'");
// }

Then, a few lines below that, find

// ###################### Start delete post #######################
A few lines below that, find

if ($countposts) {
$DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$postinfo[userid]'");
}
and replace it with

// if ($countposts) {
// $DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$postinfo[userid]'");
// }

Now when you prune (or a post is deleted) the users' post count won't decrease.

conan
Tue 27th Mar '01, 3:40am
Whoa that's actually pretty good, I wonder if it's possible to do the same with the board's post count?

conan
Tue 27th Mar '01, 5:36am
Oh btw I have another question, does the counter still work when you delete a thread? I mean if you delete a thread will it reduce that user's post count?

tubedogg
Tue 27th Mar '01, 5:40am
With this hack, any time a post is deleted (be it via Pruning or by the user himself or the moderator of the forum, and whether you are deleting an individual post or a whole thread), the user's post count is *not* affected. So this makes his count truly a full count of the total number of posts he has made since registering. The reason it works this way is all the different ways to delete a post - pruning, moderator deleting, user deleting, thread being deleted - rely on these two functions to work. Once you remove the reduce count functionality from these two places, no matter how a post is deleted, the user's count stays the same.

conan
Tue 27th Mar '01, 5:58am
I see, the only drawback would be if a user spammed the board intentionaly to raise his or her post count, and then deleted his threads.

I guess if you don't allow users to delete their threads, but only to edit them you kinda solve this problem!
Nice hack indeed man!

JJR512
Thu 29th Mar '01, 3:28pm
I guess I'm the only person that likes it the way it is now. I like the fact that when a post is deleted, the post count goes down.

Messages are only deleted on my board for one main reason: The user accidentally double-posted. When I see a double post, I delete one. It makes things look nicer. And I don't think someone should get positive credit for a mistake, even if a genuine, simple mistake.

Now we have a very progressive moderating attitude on my board. We will allow a lot of stuff to go by, as long as people are not attacking each other, etc. But when situations do come up, I prefer to edit or censor, rather than deleting the message. By editing the message, and putting an explanation in the edited message, the person who posted the offending message will see right away that what he did was not acceptable, and will have an explanation. This is preferable, in my opinion, that the person coming back and seeing his message missing, and not knowing what is going on.

So deleting a post is not normally done on my board, and only as a very last resort. So if something is deleted, it was because it was very, very bad, and once again, I do not feel someone should continue to get positive credit, to keep credit for that post, if it was so bad that it had to be deleted.

Now I have things set so nobody can delete their own messages or threads, so we do not have a situation of innocent people getting their counts lowered because someone deleted the first post.

bira
Fri 30th Mar '01, 5:38am
You might want to read what I wrote here at the bottom:

http://vbulletin.com/forum/showthread.php?s=&threadid=12189

This entire hack is redundent.

Instead of so many code lines, you can achieve exactly the same result by changing in functions.php:



function deletethread($threadid,$countposts=1)


to



function deletethread($threadid,$countposts=0)


(this will ensure that post count does not get decreased when a thread is deleted)

and if you want post count not to change when specific posts are deleted as well, then in function.php change:



function deletepost($postid,$countposts=1,$threadid=0)


to



function deletepost($postid,$countposts=0,$threadid=0)

Streicher
Sun 27th May '01, 5:00am
hmm, bira's version of the hack does not work in vB 2.0 final and tubedogg`s first replacement is not anywhere in the funcions.php of the final release.

Can you help me?


Edit: forgotten the word "not" :rolleyes:

JamesUS
Sun 27th May '01, 6:17am
bira's version of the hack does work in vB 2.0 final


If bira's hack works what do you need help with? :)

Streicher
Sun 27th May '01, 6:44am
Originally posted by JamesUS


If bira's hack works what do you need help with? :)

Ups :rolleyes:

I have forgotten the little word "not". Bira's version of the hack does not work, too.

bira
Mon 28th May '01, 11:07pm
If you change $countposts=1 to $countposts=0 then there is no way on earth that the post count will change for the user when you delete.


it WILL change if you run "update counters", because that operation is a simple COUNT query of the database. So, if you don't want your users' post count to ever change, then change $countpost to equal 0, and never run "update counters" :D

BluSmurf
Tue 29th May '01, 1:33pm
sorry bira but I've too tried your hack and it didnt work. :(

bira
Tue 29th May '01, 5:00pm
this isn't my "hack" and I don't support it, nor use it myself so I'm sorry if this comes off rude, but I don't really care :D ;)

Christian
Mon 11th Jun '01, 8:12am
Does anyone know which lines to modify in 2.0?

Here are the functions:



// ###################### Start delete thread #######################
function deletethread($threadid,$countposts=1) {
global $DB_site;

// decrement users post counts
if ($threadinfo=getthreadinfo($threadid)) {
$postids="";
$attachmentids="";

$posts=$DB_site->query("SELECT userid,attachmentid,postid FROM post WHERE threadid='$threadid'");
while ($post=$DB_site->fetch_array($posts)) {
if ($countposts) {
if (!isset($userpostcount["$post[userid]"])) {
$userpostcount["$post[userid]"] = -1;
} else {
$userpostcount["$post[userid]"]--;
}
}
$postids.=$post['postid'].",";
$attachmentids.=$post['attachmentid'].",";
}

if (is_array($userpostcount)) {
while(list($postuserid,$subtract)=each($userpostco unt)) {
$DB_site->query("UPDATE user SET posts=posts$subtract WHERE userid='$postuserid'");
}
}

if ($attachmentids!="") {
$DB_site->query("DELETE FROM attachment WHERE attachmentid IN ($attachmentids"."0)");
}
if ($postids!="") {
$DB_site->query("DELETE FROM searchindex WHERE postid IN ($postids"."0)");
$DB_site->query("DELETE FROM post WHERE postid IN ($postids"."0)");
}
if ($threadinfo['pollid']!=0) {
$DB_site->query("DELETE FROM poll WHERE pollid='$threadinfo[pollid]'");
$DB_site->query("DELETE FROM pollvote WHERE pollid='$threadinfo[pollid]'");
}
$DB_site->query("DELETE FROM thread WHERE threadid='$threadid'");
$DB_site->query("DELETE FROM thread WHERE open=10 AND pollid='$threadid'"); // delete redirects
$DB_site->query("DELETE FROM threadrate WHERE threadid='$threadid'");
$DB_site->query("DELETE FROM subscribethread WHERE threadid='$threadid'");
}
}

// ###################### Start delete post #######################
function deletepost($postid,$countposts=1,$threadid=0) {
global $DB_site;

// decrement user post count
if ($postinfo=getpostinfo($postid)) {
if ($countposts) {
$DB_site->query("UPDATE user SET posts=posts-1 WHERE userid='$postinfo[userid]'");
}
if ($postinfo['attachmentid']) {
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
$DB_site->query("UPDATE thread SET attach = attach - 1 WHERE threadid = '$threadid'");
}

$DB_site->query("DELETE FROM searchindex WHERE postid=$postid");
$DB_site->query("DELETE FROM post WHERE postid='$postid'");
}
}


Thanks in advance

Blue2000
Wed 13th Jun '01, 3:42pm
here Christian i done this and it worked fine for me


// if ($countposts) {
// if (!isset($userpostcount["$post[userid]"])) {
// $userpostcount["$post[userid]"] = -1;
// } else {
// $userpostcount["$post[userid]"]--;
// }
// }

MichaelG
Thu 14th Jun '01, 5:39am
I still get errors, does any1 know which functions to modify?

Thnx i a

Michael

OK, found out myself:
In functions.php search for:

// ###################### Start delete thread #######################
function deletethread($threadid,$countposts=1) {
global $DB_site;

// decrement users post counts
if ($threadinfo=getthreadinfo($threadid)) {
$postids="";
$attachmentids="";

$posts=$DB_site->query("SELECT userid,attachmentid,postid FROM post WHERE threadid='$threadid'");
while ($post=$DB_site->fetch_array($posts)) {
if ($countposts) {
if (!isset($userpostcount["$post[userid]"])) {
+++OLD+++ $userpostcount["$post[userid]"] = -1; +++OLD+++
$userpostcount["$post[userid]"]--;
} else {
$userpostcount["$post[userid]"]--;
}

So all you have to do is change $userpostcount["$post[userid]"] = -1; to $userpostcount["$post[userid]"]--;

This was for deleting threads, deleting posts works as shown by tubedogg
Hope I could help some1 with that...

Cya
Michael

Dolamite
Sat 30th Jun '01, 4:01pm
i get these errors when following the above directions..... i have 2.0.1



Parse error: parse error, expecting `T_VARIABLE' or `'$'' in MY LOCATION (EDITED OUT)functions.php on line 1554

Warning: Cannot add header information - headers already sent by (output started at MY LOCATION (EDITED OUT)functions.php:1554) in MY LOCATION (EDITED OUT)functions.php on line 1183

Fatal error: Call to undefined function: makelogincode() in MY LOCATION (EDITED OUT)global.php on line 299

Warning: Unable to call doshutdown() - function does not exist in Unknown on line 0

weezle
Sat 21st Jul '01, 1:22am
Cant get this hack to work with VBBFinal??? Can someone help me

TripleH
Sat 21st Jul '01, 3:08am
Ok. I got the threads one to work now because of the new hack posted..

whenever i try to use tubedogg's hack about the deleted posts one, it always gives me errors...

Something wrong??

Christine
Sun 9th Sep '01, 10:23pm
Is there a clean set of instructions for not reducing member or board counts on delete for 2.0.3?

Thanks!!! :D

padd
Tue 9th Oct '01, 7:44am
Yeah a version for 2.0.3 would be great please

Chris Stewart
Sun 14th Oct '01, 1:58am
Could someone post the whole modded fuctions.php doc for us newbies?:D

Freddie Bingham
Sun 14th Oct '01, 2:17am
You can not post source code.

Chris Stewart
Sun 14th Oct '01, 2:20am
Could you email me the page or send it over PM or something? All my info is in my profile. I would do it myself but for some reason my whole fuctions.php (and others) file is all thrown together. It's not laid out all nice and neat.

Email is Fool1515@mediaone.net

Heineken77
Tue 16th Oct '01, 2:47am
Originally posted by bira
If you change $countposts=1 to $countposts=0 then there is no way on earth that the post count will change

LMFAO .. sorry ... but I found this VERY amusing ;) ehehheehehe

Thanks bro :)

almighty one
Tue 23rd Oct '01, 8:11pm
come on someone must have worked this out please post how i hate to revert my functions template back to older version to use this

Heineken77
Wed 24th Oct '01, 3:54am
I've been waiting for a definitive answer myself :(

defweb
Fri 26th Oct '01, 11:58pm
need a definitive answer for version 2.03 still