Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Tristan Perry on October 24, 2004, 05:05:33 AM

Title: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on October 24, 2004, 05:05:33 AM
Hello,
  This small mod adds the top 5 karma ratings, and the lowest 5 karma ratings to the stats page. You can see an example of it here:
http://forums.tauonline.org/index.php?action=stats (http://forums.tauonline.org/index.php?action=stats)

Update: This has been updated on 4/12/04. The changes are:



Here's what to change:

In /Sources/Stats.php
Find:

// Activity by month.

Add above it:
// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}


In /Themes/(ThemeFolder)/Stats.template.php
Find:

foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo '
</table>
</td>
</tr><tr>
<td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';


Replace with:
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';

if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}

if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Rating</td>
<td class="catbg" colspan="2">Lowest Karma Rating</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['gkarma'] as $gkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$gkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['bkarma'] as $bkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr valign="top"><td class="windowbg2" width="80%" align="left">'.
$bkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr></table>';
}
}

echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
                        </tr>
<tr>
                                <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
                                <td class="windowbg2" colspan="4">';




If you want it to show more (Or less) stats then:
In /Sources/Stats.php
Find the following:

SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5

SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5 5

And replace the number bolded above to however many results you want shown.



That's it! Please say if you have any questions/queries about this,
TauOnline.Org (http://tauonline.org)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: A.M.A on October 24, 2004, 11:16:48 AM
nice tip .. thanks for sharing it.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on October 24, 2004, 11:29:29 AM
Quote from: A.M.A on October 24, 2004, 11:16:48 AM
nice tip .. thanks for sharing it.
Thanks and your welcome  :) Also whatever happened to the links to all these tips? They were in the sticky, but now they aren't.. Was it too much work?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: A.M.A on October 24, 2004, 11:56:55 AM
nope .. just thinking it is not hard to find a tip in here.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on October 25, 2004, 05:26:16 AM
Quote from: A.M.A on October 24, 2004, 11:56:55 AM
nope .. just thinking it is not hard to find a tip in here.
Ah right.  :) Will it come back if this board gets bigger?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: GiNi3D on October 25, 2004, 09:57:08 AM
Nice idea Tau, very useful. :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on October 25, 2004, 10:13:35 AM
Quote from: GiNi3D on October 25, 2004, 09:57:08 AM
Nice idea Tau, very useful. :)
Thanks  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Burpee on November 16, 2004, 08:55:36 AM
Hmm... would it be possible to show the lowest and highest totals, instead of the votes casted upon each user?

PS: Nice trick, Tau :D
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on November 16, 2004, 12:49:16 PM
Quote from: Burpee on November 16, 2004, 08:55:36 AM
Hmm... would it be possible to show the lowest and highest totals, instead of the votes casted upon each user?

PS: Nice trick, Tau :D
Yeah it's possible, it's just that at the time of making the code, I couldn't be bothered to show the totals! I'll edit my first post soon to show the rating, or the totals depending on what setting you choose  :)



EDIT: It appears it's not as easy as I thought it'd be.. I've got the main bit of this script working, I just can't get an ordered list to show up... 

E.g: (Taken from my forum when testing this script)
Brother Edwin      -3
Orion                   -1
Fire Eater         -1
Feugan AM      -1
misfits Tau punk -2

... I'm not good enough with arrays right now to complete this... I can give you the code that I have done at the moment, although it doesn't show an ordered list and so is kind of pointless.. I'll keep working on this, although I doubt I can do this at the moment... Sorry  :-[ If anyone wants to help out, It'd be appreciated
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Burpee on November 16, 2004, 04:36:20 PM
Hmm... perhaps you should share the code you have right now so people can try and help you...
I probably can't help you, but ofcourse I'm willing to give it a try :P
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on November 17, 2004, 03:04:40 PM
Quote from: Burpee on November 16, 2004, 04:36:20 PM
Hmm... perhaps you should share the code you have right now so people can try and help you...
I probably can't help you, but ofcourse I'm willing to give it a try :P
I've updated my first post to do this  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: BigMike on November 17, 2004, 05:31:07 PM
Wow, I tried doing this on my forum a while back and just gave up. Having a max and min is nice, but I was just trying to show the max listings. All you would have to do is sum their max and mins and then sort the highest n number of returns, and store those into a new array. Then run a counter from 0 to the number of names -1 and you would have it.

I dont have time right now, but when I do I'll see if I can figure it out. But Im only going to figure out how to show the Higest totals, not the lowest..

Here's your code running on my forum: http://board.marlincrawler.com/index.php?action=stats (http://board.marlincrawler.com/index.php?action=stats)
Thanks for the code and I'll see what I can do...
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on November 18, 2004, 11:02:09 AM
Quote from: BigMike on November 17, 2004, 05:31:07 PM
Wow, I tried doing this on my forum a while back and just gave up. Having a max and min is nice, but I was just trying to show the max listings. All you would have to do is sum their max and mins and then sort the highest n number of returns, and store those into a new array. Then run a counter from 0 to the number of names -1 and you would have it.

I dont have time right now, but when I do I'll see if I can figure it out. But Im only going to figure out how to show the Higest totals, not the lowest..

Here's your code running on my forum: http://board.marlincrawler.com/index.php?action=stats (http://board.marlincrawler.com/index.php?action=stats)
Thanks for the code and I'll see what I can do...
Cool, thanks  :) Also I'm glad you liked the code  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ozmafans on December 02, 2004, 09:33:53 AM
Hey this is great and all, but I have a question:

http://www.ozmafans.com/forum

People seem to show up multiple times.

For example: "stefanie" has the highest at +123, but also the lowest at -118 ? How is this possible?

I just read some of the comments, I understand now. If someone could make this a real feature, that includes BOTH totals and the original stats (as both are interesting) I would love it.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ozmafans on December 02, 2004, 01:35:04 PM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ozmafans on December 02, 2004, 02:11:46 PM
sorry for double-replying, but I am noticing now that after increasing the count to 10, the stats are no longer in order.

To see for yourself, www.ozmafans.com/forum
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NiXnAx on December 02, 2004, 02:45:14 PM
Quote from: ozmafans on December 02, 2004, 01:35:04 PM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.

You only need to change ASC to DESC to get the top 5 karma total.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ozmafans on December 02, 2004, 09:27:15 PM
Quote from: NiXnAx on December 02, 2004, 02:45:14 PM
Quote from: ozmafans on December 02, 2004, 01:35:04 PM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.

You only need to change ASC to DESC to get the top 5 karma total.
Thank you for that tip, I know very little about php/sql.

The problem seems to be that say I had -100 karma points given to me, and 100 positive karma points given to me.

karmaBad (100) - karmaGood (100) = -200, when it should really be 0. Is there an absolute value function?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NiXnAx on December 02, 2004, 09:40:55 PM
when you remove good karma from bad karma, you usually get negative karma. (that is supposed when you are nice on the forum), and int (the value of karma, stored in the database cannot be negative) ant that is the reason there is two karma colums. So when you substract 100 (goodkarma) from 100 (badkarma) you get, well you guessed it, 0.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ozmafans on December 03, 2004, 09:35:32 AM
Quote from: NiXnAx on December 02, 2004, 09:40:55 PM
when you remove good karma from bad karma, you usually get negative karma. (that is supposed when you are nice on the forum), and int (the value of karma, stored in the database cannot be negative) ant that is the reason there is two karma colums. So when you substract 100 (goodkarma) from 100 (badkarma) you get, well you guessed it, 0.
okay, then the question is:

Why will person X on the forum show in the stats page a -30, but on the actual forum have a -3 ? Something here is wrong..

PLUS - The sorting is definitely out of order.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on December 03, 2004, 11:50:59 AM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
Ahhh! I never knew you could do that! Thanks, I'll look this over and see if I can get all the problems reported here sorted out so that the mod will show the highest and lower karma totals as well  :)

Quote from: ozmafans on December 02, 2004, 09:27:15 PM
Thank you for that tip, I know very little about php/sql.

The problem seems to be that say I had -100 karma points given to me, and 100 positive karma points given to me.

karmaBad (100) - karmaGood (100) = -200, when it should really be 0. Is there an absolute value function?
That's not true. The data stored in the fields 'karmaGood' and 'KarmaBad' are both positive numbers, therefore if you had 100 good karma, and 100 bad karma, the sum would be:

100 - 100, which would equal 0, not -200.

The mistake you're making is thinking that the data stored is 'karmaBad' has a negative sign in it. You're thinking the sum would be:

-100 - 100, which would, as you say, equal -200.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals.  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NiXnAx on December 03, 2004, 01:26:50 PM
Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)

NP

But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';


Because you might want to show the most users online stats ;)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on December 03, 2004, 01:30:46 PM
Quote from: NiXnAx on December 03, 2004, 01:26:50 PM
Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)

NP

But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';


Because you might want to show the most users online stats ;)
Thanks! That might be a good thing to keep  :P
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Burpee on December 04, 2004, 08:13:19 AM
How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on December 04, 2004, 08:53:36 AM
Quote from: Burpee on December 04, 2004, 08:13:19 AM
How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.
Thanks  :) I meant to add that, but must have forgot. I've changed my first post to reflect these changes  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: EG on January 06, 2005, 05:48:28 PM
I was wondering whether it would be possible to use this mod to show the table of LLama captures..

since that uses Karma, but... doesnt rely on Karma being enabled ???

*EDIT*

yes just added this code into the stats.template.php and it shows the data without karma being enabled :) 

if( $modSettings['karmaMode'] == 0 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}


brilliant mod :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: vipmoney on January 20, 2005, 10:03:30 PM
hello Guys,

Nice mod, I already implemented and it works great...

Now, I ask from some extra stuf... if possible off course:  ;)

- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing

Is that possible ? or is it difficult ?

I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.

best regards,
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on January 21, 2005, 12:17:56 PM
Quote from: vipmoney on January 20, 2005, 10:03:30 PM
hello Guys,

Nice mod, I already implemented and it works great...

Now, I ask from some extra stuf... if possible off course:  ;)

- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing

Is that possible ? or is it difficult ?

I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.

best regards,
Your welcome, I'm glad it's working for you  :) As for the rank thing, I'm fairly busy right now and so won't be able to make the changes I'm afraid..
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: vipmoney on January 23, 2005, 07:55:53 PM
Thanks anyway Tau
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: redone on January 24, 2005, 02:36:02 PM
Thanks for the mod it works really well!

:)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on January 24, 2005, 03:04:45 PM
Quote from: redone on January 24, 2005, 02:36:02 PM
Thanks for the mod it works really well!

:)
Your welcome  :) I'm glad it's worked.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Alisha on January 24, 2005, 09:44:57 PM
Flawless Install! Thanks! :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: redone on January 30, 2005, 09:46:44 AM
Thank you for that mod. I installed it too and it works really well.

Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NukeWorker.com on April 17, 2005, 03:27:30 PM
It would be nice to have thebar graph next to it, like the rest of the page.  It would fit in better.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: HaVaNa7 on April 19, 2005, 10:48:30 AM
Quote from: NukeWorker.com on April 17, 2005, 03:27:30 PM
It would be nice to have thebar graph next to it, like the rest of the page.  It would fit in better.
???
Anybody knows how?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on May 03, 2005, 04:54:42 AM
I've got the graph working, and I'll post it once it's perfect.

The <table> stuff should be moved outside of the foreach.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Xarcell on June 09, 2005, 09:05:55 PM
I installed the mod using teh directions from the first post. It works, however top karma guy is -10. How's that? What do I need to do tto fix that. I know nothing about php...

-Xarcell
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on June 09, 2005, 09:28:32 PM
Is that his actual karma?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: trenchteam on June 21, 2005, 08:26:36 PM
thanks. works great.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: nokonium on June 25, 2005, 10:53:47 AM
Neat mod, I'm playing with it now.

We use totals and have renamed them. How do I change the titles "Highest Karma Total" & Lowest Karma Total?

Ignore this, I've found them in the stats.template and changed them to reflect our particular admin applied 'karma' (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.nokonium.plus.com%2Fblack-cat%2Fdevils%2Fdevil-wink.gif&hash=ac7e4233d6bda381a7bdd563740a6df0482bfa7d)

echo '<tr>
<td class="catbg" colspan="2">Well Bogled</td>
<td class="catbg" colspan="2">Un-Bogled</td>
</tr>
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on June 25, 2005, 11:14:47 AM
Quote from: nokonium on June 25, 2005, 10:53:47 AM
Neat mod, I'm playing with it now.

We use totals and have renamed them. How do I change the titles "Highest Karma Total" & Lowest Karma Total?

Find:

<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>


Replace the titles with whatever you wish. Thanks for the feedback on this.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NukeWorker.com on June 27, 2005, 08:50:11 AM
Quote from: eldacar on May 03, 2005, 04:54:42 AM
I've got the graph working, and I'll post it once it's perfect.

The <table> stuff should be moved outside of the foreach.

Can you share the code for the graph please?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on June 27, 2005, 09:04:59 AM
Um yeah, but it's not done for the default theme. I've got it working in curveSMF only. i'll post it tomorrow
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on July 22, 2005, 11:07:48 PM
Search:
foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo '
</table>
</td>
</tr><tr>
<td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';


Replace:
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';

if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}

if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2" width="50%"><b>Highest Positive Karma</b></td>
<td class="catbg" colspan="2" width="50%"><b>Highest Negative Karma</b></td>
</tr>
<tr>
<td colspan="1" class="windowbg" >
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">
<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>';

foreach($context['gkarma'] as $gkarma)
{
echo '<td width="60%" valign="top">'.
$gkarma['Link']
.'</td>
<td width="20%" align="left" valign="top">', $gkarma['Karma'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $gkarma['karma_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
<td width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr>';
}

echo'</table></td><td colspan="1" class="windowbg" >
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';

foreach($context['bkarma'] as $bkarma)
{
echo '<tr valign="top"><td width="60%" valign="top">'.
$bkarma['Link']
.'</td>
<td width="20%" align="left" valign="top">', $bkarma['Karma'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $bkarma['karma_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
<td width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr>';
}
}

echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
                        </tr>
<tr>
                                <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
                                <td class="windowbg2" colspan="4">';


Let me know if that doesn't work.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Elmacik on September 02, 2005, 01:44:19 PM
is this for 1.1 beta 3?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on September 02, 2005, 01:54:59 PM
AFAIK this works for 1.1 as well as 1.0. :) I'm running it fine on 1.1, and it used to work on 1.0.0 with me and so I presume it still works for the latest versions of 1.1 and 1.0.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NukeWorker.com on September 03, 2005, 11:30:28 AM
My code in stats.php does not look anything like that.  This is what I have.  What do I need to do to get the bar graph in this code:

foreach ($context['top_time_online'] as $i => $member)
{
$context['top_time_online'][$i]['time_percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
$temp[] = $member['id'];
}

// Cache the ones we found for a bit, just so we don't have to look again.
cache_put_data('stats_total_time_members', $temp, 480);

// Top 10 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 10", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 10", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 10", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 10", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on September 04, 2005, 08:42:30 AM
Thats the source file. You want to edit the theme template file.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: nokonium on September 04, 2005, 11:46:26 AM
I'm fiddling with 1.1.4b and although I get the totals, I don't get the graphs. I pasted the code on page 4 instead of the stats.template code on page 1, was that correct?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on September 05, 2005, 12:21:20 AM
My code is for 1.0 and I don't know how it would have changed for 1.1 sorry.

Looking at my code again, I'm not sure what I'm doing. Can you change it to karmamode 2? I don't think I've put bars for mode 1.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: nokonium on September 05, 2005, 01:54:25 AM
I'm setting 1.1.4b up as close as I can to our live board, which has the totals. If it was possible it would have been good to add the graphs.

Thanks
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: nokonium on January 02, 2006, 06:55:03 AM
I've added the code for this to RC2 and it only displays two empty boxes. Could you please have a look at is for RC2.  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: NukeWorker.com on January 05, 2006, 08:06:57 PM
Quote from: nokonium on January 02, 2006, 06:55:03 AM
I've added the code for this to RC2 and it only displays two empty boxes. Could you please have a look at is for RC2.  :)

Yeah, when I upgraded to rc2, it stoped working.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Dannii on January 05, 2006, 09:32:49 PM
I'll have a look at it.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: nokonium on January 06, 2006, 02:50:05 AM
Thanks Eldacar
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ディン1031 on January 19, 2006, 10:23:24 AM
Hi

Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))

So this is the changed part in the stats.php for this (I hope this is the current version) ;D


// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}


Change this too




// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;

loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}


Bye
DIN1031
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LostProphecy on January 19, 2006, 05:48:12 PM
ooooh thanx for doing that for me :)

*runs to do now*
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Killian on January 25, 2006, 02:30:41 PM
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list.  Any ideas? 

http://dayton-online.com/index.php?action=stats
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Spork on February 05, 2006, 04:46:50 PM
This is a great mod, exactly what i've been looking for.Thanks!
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: mrselnombre on March 14, 2006, 10:29:37 AM
Quote from: Killian on January 25, 2006, 02:30:41 PM
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list.  Any ideas? 

http://dayton-online.com/index.php?action=stats

i have this too, but it only started when i moved to a new server with php5
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: londonhogfan on April 11, 2006, 12:16:15 AM
anyone know a fix for this?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: CeZa on April 11, 2006, 01:57:35 PM
thanks my friend :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: marciano on June 12, 2006, 02:02:14 PM
hello , i need what is mod (top karma total) is showing in the index of my forum ,

help me!! (si alguien sabe español mejor, perdon por mi ingles)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LostProphecy on June 13, 2006, 02:05:00 AM
i only wish the member colours worked with it... the code that the guy from the other mod put in here doesn't work and has never worked for me...
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LostProphecy on June 13, 2006, 02:07:26 AM
Quote from: ディン1031 on January 19, 2006, 10:23:24 AM
Hi

Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))

So this is the changed part in the stats.php for this (I hope this is the current version) ;D


// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}


Change this too




// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;

loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}


Bye
DIN1031

really wants this code to work but it just doesn't work and doesn't show any colours...

P.s - has anyone actually managed to get the bar graphs displaying for this karma yet in RC2?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: steve51184 on June 24, 2006, 07:24:44 PM
Quote from: mrselnombre on March 14, 2006, 10:29:37 AM
Quote from: Killian on January 25, 2006, 02:30:41 PM
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list.  Any ideas? 

http://dayton-online.com/index.php?action=stats

i have this too, but it only started when i moved to a new server with php5

same here my negative karma holders are showing up at the top of the Highest Karma Total list

can i get some help on this please?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ディン1031 on July 10, 2006, 01:05:13 AM
Quote from: ディン1031 on January 19, 2006, 10:23:24 AM
Hi

Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))

So this is the changed part in the stats.php for this (I hope this is the current version) ;D


// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}


Change this too




// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}

// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;

loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}


Bye
DIN1031
It's correct know... never thought that i forgot this *runs* (never tested it :P).

*runs*

Bye
DIN1031
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LostProphecy on July 10, 2006, 06:43:01 AM
thanks for that din :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ssoltz on July 21, 2006, 03:49:11 PM
Just so I'm clear...

Does the code at the top of this topic work for 1.1RC2 yet?

Thanks,
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LostProphecy on July 22, 2006, 09:14:16 AM
yep sure does :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ssoltz on July 24, 2006, 01:04:45 PM
Thanks, Proph...all add it today and report if I have any issues.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ssoltz on July 25, 2006, 05:34:48 PM
Just to let you all know, I had to use:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

for highest total and:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

for lowest...

MySQL version perhaps?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: The Fat Boy on August 04, 2006, 01:21:13 PM
OK.  It works perfectly for me.  I was curious how I could just get the top 5 or the bottom 5 alone, and not have them in the stats list.  I am using Lunabyte Enigma 2.0, and I want to put the top 5 or bottom 5 in a box.  So basically, I just need the php to ask for either set of information in a simple mode.  But its way over my head to do it.  I suppose I could keep tinkering and I'll get it, but I figured I'd ask first.
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: vipmoney on December 15, 2006, 02:53:51 AM

this work on 1.1 ?

thanks ;)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ssoltz on December 21, 2006, 12:36:10 PM
Yes,

But just to let you know, if you use my code, it doesn't seem to work on MySQL 5. I guess FLOOR works differently in 5 or has been depracated...not sure and definitely over my head.

Good luck!
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Zenigata on February 15, 2007, 09:52:19 AM
Quote from: ssoltz on July 25, 2006, 05:34:48 PM
Just to let you all know, I had to use:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

for highest total and:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

for lowest...

Thank you. With this fix it works even with SMF 1.1.2
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Tristan Perry on March 04, 2007, 11:08:57 AM
Quote from: ssoltz on July 25, 2006, 05:34:48 PM
Just to let you all know, I had to use:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

for highest total and:

SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

for lowest...

MySQL version perhaps?
Ah, good point. Thanks for that fix, first post updated :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: JohnyNS on June 26, 2007, 03:59:19 PM
Hi,

   this is great mod and works on my smf 1.1.3 forum   :D


But I whant to make it show on the top of my board on index page of my forum, but i can't make it work.

Can somebody help me  ?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LHW on August 10, 2007, 03:17:54 PM
My SMF version is 1.1.3, and MySQL is at 5.0.27-standard.  For the most part, it works great...until someone goes into Negative Karma.

Right now, there's one person at my board with a negative karma, and he's listed at the top of the "Highest Karma" list.  Shouldn't he be at the bottom of the "Lowest Karma" list??

In the hopes that I mistyped something, I re-edited the files, and the results are the same.  Any idea on how to correct this?

Thanks!
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: ディン1031 on August 10, 2007, 05:15:47 PM
Because MySQL have a bug there on some Versions. You need to use trick for this that it work.

Replace the FLOOR(karmaGood-karmaBad) with FLOOR(1000000+karmaGood-karmaBad) than it should work correct ;). I used this in my SSI Karma mod that it work correct. Why 1000000 because the maximum Karma is 999999 more is not allowed in the table so it would never go under 0 ;).

Bye
DIN1031
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: LHW on August 10, 2007, 05:25:19 PM
Thanks, DIN!  That worked perfectly!  ;D

Kudos to you!!  :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Neorics on September 22, 2007, 01:38:14 PM
possible to show those stats in the board index? at the bottom
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: metallica48423 on October 24, 2007, 12:53:58 AM
it should be, but tbh i have no idea what to put where.  You'd have to modify the Sources/BoardIndex.php and the Boardindex.template.php
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Neorics on October 24, 2007, 11:48:05 AM
nah... i added the highest karma SSI mod and used that...
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: metallica48423 on October 24, 2007, 12:45:37 PM
that works :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: steve51184 on January 30, 2010, 08:01:15 PM
does this work on smf 2.0 rc2 or is there an alternative hack/mod for something like this?
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: Arttu on February 25, 2010, 11:12:43 AM
Thanks :)
Title: Re: Showing Highest and Lowest Karma Rating in Stats Page
Post by: steve51184 on May 10, 2010, 06:20:49 PM
anything like this for smf 2.0 rc2/3?