TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 316
  • Total: 316

Karma Blocks Package v0.4

Started by ontap, March 22, 2006, 11:43:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

slebe

it works! thx Maxâ„¢

Soph

Hello,

ssi_topkarma of Karma v0.4 count only KarmaGood instead of KarmaGood-KarmaBad :o

is it normal ?  :uglystupid2:

exemple :

v.0.4:
$karma_results db_query("SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT $topkarma"__FILE____LINE__);

V.0.3 :

$karma_results 
db_query("SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT $topkarma"__FILE____LINE__);


Max

Quote from: Soph on January 04, 2007, 04:43:15 PM
Hello,

ssi_topkarma of Karma v0.4 count only KarmaGood instead of KarmaGood-KarmaBad :o

is it normal ?  :uglystupid2:

yea theres no need to count the karmaBad in the top karma ;)

Soph

i have modified it to count it  ;)

else it display (in my forum) 63 Karma or i have 63 :) - 16 :tickedoff:

Roar_Fan

I wanted to sort by Total Karma (Good - Bad) but the ORDER BY was returning some strange results. Turns out that on some installs of SQL the unsigned status of karmaGood and karmaBad causes issue. I changed these to blank, and presto.. it worked. If anyone else is having the same problem, try this sql query is phpmyadmin:

SELECT realName, karmaGood, karmaBad, ID_MEMBER, karmaGood - karmaBad as karmaTotal FROM smf_members ORDER BY karmaTotal DESC

if karmaTotal is returning a value of around 10000000000000.. then you've got the same problem i had!


Soph

Because user have "negatif" Karma you have this result

do you have many user with more bad karma than good karma ?

in my forum, i have only 2 users where karmaGood-karmaBad < 0 then i "cheat" : i take in my DB:  20 result but i display only (it's a Top Ten) 10 result where the karmaTotal is > 0  ;)

that i use :
//              Karma Package V0.4
//                Top Karma Block
//        Created By Maxâ„¢ - Leave Credits!

function ssi_topkarma($topkarma = 3, $output_method = 'echo')
{
global $context, $settings, $options, $txt, $scripturl, $db_prefix;

echo '
<table border="0" cellpadding="0" cellspacing="2" width="100%"> ';
$karma_results = db_query("SELECT realName, karmaGood, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 20", __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']
);
}
mysql_free_result($karma_results);
$recompte=1;
echo '
<td width="100%" valign="top">';

foreach($context['htkarma'] as $htkarma)
{

$total = $htkarma['Good']-$htkarma['Bad'];
if (($recompte<=10) && ($total>=0)) {
echo '
<table border="0" cellpadding="0" cellspacing="3" width="100%">
<td> '.$htkarma['Link'].'</td><td width="20%" align="right"><font color="'. $txt['karma_applaud_color'] .'"> '.$total.'</font>
</td></table>';
$recompte++;
}
}
echo '</td></tr></table>';

}


I know it's not the best code to solve this problem but it work  ;)

PS: Sorry for my English.

Roar_Fan

Soph. KarmaGood - KarmaBad was returning a positive figure of over 1000000, putting them at the top. THe ONLY way i could find to fix it was to change the database schema itself.

and yeah.. i have about a 50/50 ratio of positives to negatives. Its a very opinionated board!

Soph

Quote from: Roar_Fan on January 23, 2007, 09:13:33 PM
Soph. KarmaGood - KarmaBad was returning a positive figure of over 1000000
yeah i have same result that what i use my code.
But if you have many user with karmaBad more than theire karmaGood, my code is'nt good to solve the problem.

QuoteTHe ONLY way i could find to fix it was to change the database schema itself.
i think it's better, add a row karmatotal to smf_members and update it in source code when user add or remove karma.

jacortina

Quote from: Roar_Fan on January 23, 2007, 09:13:33 PM
Soph. KarmaGood - KarmaBad was returning a positive figure of over 1000000, putting them at the top. THe ONLY way i could find to fix it was to change the database schema itself.

and yeah.. i have about a 50/50 ratio of positives to negatives. Its a very opinionated board!


It's presenting it as a large positive because of unsigned integer wraparound.

uint(1) - uint(2) is usually not presented as -1 but as the integer limit in the positive direction (unsigned MEANS no sign, no positive, no negative and results are most often given in the same data type as the arguments).

Stirred

#99
Hey!!

Thanks for this Mod, it kicks ass for anyone who wants to get more with Karma.

Well i give in return my block:
echo '<img src="http://YOUR SITE/Themes/YOUR THEME/images/TPdivider.gif"> <font size="1pt" face="Verdana">Últimos Classificados:</font>';
echo '<hr>';
ssi_karmalog(6);
echo '<br>';
echo '<img src="http://YOUR SITE/Themes/YOUR THEME/images/up.gif"> <font size="1pt" face="Verdana">Membros + <font color="green">Aplaudidos</font>:</font>';
echo '<hr>';
ssi_topkarma(5);
echo '<br>';
echo '<img src="http://YOUR SITE/Themes/YOUR THEME/images/down.gif"> <font size="1pt" face="Verdana">Membros + <font color="red">Avisados</font>:</font>';
echo '<hr>';
ssi_lowestkarma(5);


It's in Portuguese but you can change to whatever you want in order suit to your site.

This website is proudly hosted on Crocweb Cloud Website Hosting.