PDA

View Full Version : PM Statistics bar in thread view


Zzed
08-15-2002, 10:00 PM
This hack was requested by SgtSling.

This is a very simple hack that displays the PM statistics of a user in the thread view screen.
It requires no template modifications because it appends itself on to $post[posts]. ;)

Here is how to implement this hack.

In showthread.php look for the following code:

while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {

if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}
$postbits .= getpostbit($post);
}


And replace it with the following:

while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {

if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}

$pmcount=$DB_site->query_first("select count(*) as msgs from privatemessage where userid = $post[userid]");
$pmratio = 100 * $pmcount[msgs] / $pmquota;
if($pmratio > 100) {
$pmratio = 100;
}
$pmstats = "<p><font face=\"verdana\" size=\"1\">PM Stats:</font><br>";
$pmstats = "$pmstats<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\" bordercolor=\"#000000\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"><tr><td bgcolor=\"#b5b5b5\"><img src=\"images/polls/bar3.gif\" width=\"$pmratio%\" height=\"9\"></td></tr></table>";
$pmstats = "$pmstats\n$pmcount[msgs]/$pmquota";
$post[posts]="$post[posts]$pmstats";

$postbits .= getpostbit($post);
}


Click on the following link for a screenshot of this hack: http://www.ls1.com/forums/showthread.php?threadid=110647

[D]Vincent
08-16-2002, 08:46 AM
Great hack, nice idea. I might install this a little later.

Zzed
08-16-2002, 08:57 AM
Thank you. You are too kind. :)

DudeSicko
08-16-2002, 08:59 AM
I get this when i install it.

PHP Parse error: parse error, unexpected T_STRING in C:\Inetpub\webhotel\xxxxxxxx\forum\showthread.php on line 435

Zzed
08-16-2002, 09:07 AM
Originally posted by DudeSicko
I get this when i install it.

PHP Parse error: parse error, unexpected T_STRING in C:\Inetpub\webhotel\xxxxxxxx\forum\showthread.php on line 435

Sorry :( My bad. :(

I copied and pasted this from my editor and it copied the "\" along with the line breaks.

It's fixed now. :)

morrow
08-16-2002, 01:52 PM
I like that a lot! Is there any way I can get instructions and code if possible so I can add that to my site?

Thanks

Dennis

Zzed
08-16-2002, 02:41 PM
Originally posted by morrow
I like that a lot! Is there any way I can get instructions and code if possible so I can add that to my site?

Thanks

Dennis

Here you go: Spoiler Tag Instructions (http://www.vbulletin.com/forum/showthread.php?s=&postid=305075#Post305075) :)

TECK
08-16-2002, 03:22 PM
Who is the person who rated "1" this thread?
If you think is really worth nothing, why don't you write up one similar... better?

/me just rated the thread 5

Attrox
08-16-2002, 05:15 PM
Nice idea, I may install it soon. And yes, I'm not sure why this has a thread rating so low...

Boofo
08-16-2002, 07:33 PM
Can this be made to work with private messages in the privmsg template?

Also, I want that spoiler vbcode, can I have it? Please? :)

Zzed
08-16-2002, 07:55 PM
Originally posted by Boofo
Can this be made to work with private messages in the privmsg template?

Also, I want that spoiler vbcode, can I have it? Please? :)
Yes it can. You just need to modify the query string to do that. Feel free to PM or Email me if you need help with that. :)

And the link for the spoiler tag is in Post #7 of this thread. ;)

joeboo
08-16-2002, 07:56 PM
oh ho.. daddy likes this hack :) i will install it soon

Zzed
08-18-2002, 05:00 AM
If you are interested inseeing the PM stats in the private message view screen do the make the following changes.

In private.php:
Look for the following code:

eval("dooutput(\"".gettemplate("privmsg")."\");");


Change it to the following:

$pmcount=$DB_site->query_first("select count(*) as msgs from privatemessage where userid = $fromuserinfo[userid]");
$pmratio = 100 * $pmcount[msgs] / $pmquota;
if($pmratio > 100) {
$pmratio = 100;
}
$pmstats = "<p><font face=\"verdana\" size=\"1\">PM Stats:</font><br>";
$pmstats = "$pmstats<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\" bordercolor=\"#000000\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"><tr><td bgcolor=\"#b5b5b5\"><img src=\"images/polls/bar3.gif\" width=\"$pmratio%\" height=\"9\"></td></tr></table>";
$pmstats = "$pmstats\n$pmcount[msgs]/$pmquota";
$fromuserinfo[posts]="$fromuserinfo[posts]$pmstats";

eval("dooutput(\"".gettemplate("privmsg")."\");");

Donkeyballz
08-18-2002, 05:22 AM
Hey,

This looks good, I'm gonna install it :D

Boofo
08-18-2002, 05:31 AM
Is there a way to have it only show up for Admins and Supermods? Great job, by the way! Works execellent. :)

Anything on the other that we talked about? ;)

Zzed
08-18-2002, 06:00 AM
Here is the supermod/admin version ;)

if(($bbuserinfo[usergroupid]==5) OR ($bbuserinfo[usergroupid]==6)) {
$pmcount=$DB_site->query_first("select count(*) as msgs from privatemessage where userid = $fromuserinfo[userid]");
$pmratio = 100 * $pmcount[msgs] / $pmquota;
if($pmratio > 100) {
$pmratio = 100;
}
$pmstats = "<p><font face=\"verdana\" size=\"1\">PM Stats:</font><br>";
$pmstats = "$pmstats<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\" bordercolor=\"#000000\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"><tr><td bgcolor=\"#b5b5b5\"><img src=\"images/polls/bar3.gif\" width=\"$pmratio%\" height=\"9\"></td></tr></table>";
$pmstats = "$pmstats\n$pmcount[msgs]/$pmquota";
$fromuserinfo[posts]="$fromuserinfo[posts]$pmstats";
}
eval("dooutput(\"".gettemplate("privmsg")."\");");

NexDog
08-18-2002, 06:04 AM
Um, sorry if I'm missing the boat but what stats is it reading? How many PMs someone has received or what excatly?

Zzed
08-18-2002, 06:18 AM
It is the total number of PM's a user has in their inbox and sent items folder.

Boofo
08-18-2002, 06:32 AM
Thank you very much! Works great! :)

BTW: Will this count messages that they have in another folder? Like if they create a folder and move messages to it?

Zzed
08-18-2002, 06:38 AM
You're very welcome. :)

It counts all the messages that belong to a particular userid.

NexDog
08-18-2002, 10:40 AM
Thanks for clarifying that for me. Not sure if I can use it but it's great idea. :)

DudeSicko
09-04-2002, 09:18 AM
Great works fine now :)

Thx.

Bison
12-17-2002, 07:41 AM
If I have certain PM quota's for different usergroups, how do I get the numbers to display the amount each user HAS in the statistics column under their usergroup ... viewable to everyone?

Right now, I can get it to show the amount that the logged in user has but when I view everyone's PM count, it displays the amount that I set for the admin under everyone.

If I login under a regular user's account, it displays the right amount that they are authorized, but eveyone else has the same numbers as well!

subu1
12-19-2002, 05:22 AM
hey Friends and sorry for my english. How can i this Creat Hack to Place on another Place into the showthread, also I want to see this on the last Place, behind (level, MemberID,Age etc.)

can you help me?

thanks friends

subu1
12-26-2002, 01:50 PM
huhu???? *g*