News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Showing Highest and Lowest Karma Rating in Stats Page

Started by Tristan Perry, October 24, 2004, 05:05:33 AM

Previous topic - Next topic

nokonium

#41
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'

echo '<tr>
<td class="catbg" colspan="2">Well Bogled</td>
<td class="catbg" colspan="2">Un-Bogled</td>
</tr>



Tristan Perry

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.

NukeWorker.com

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?

Dannii

Um yeah, but it's not done for the default theme. I've got it working in curveSMF only. i'll post it tomorrow
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Dannii

#45
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.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Elmacik

Home of Elmacik

Tristan Perry

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.

NukeWorker.com

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']
);
}

Dannii

Thats the source file. You want to edit the theme template file.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

nokonium

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?



Dannii

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.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

nokonium

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



nokonium

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.  :)



NukeWorker.com

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.

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

nokonium




ディン1031

#57
Hi

Some member told me the question to made a version with colored memberlinks. (For user who use this mod)

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
Support only via MOD Thread! NO PM Support!
My Forum: ayu][kult Forum
My Mods: My Small Mod Collection
My Parser: DIN1031's ModParser
Current Info: More away the next days, because i've to much work to do :x

LostProphecy

ooooh thanx for doing that for me :)

*runs to do now*
Angelus Ex Quo Nox

Killian

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? 

hxxp:dayton-online.com/index.php?action=stats [nonactive]

Advertisement: