News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Limiting Karma points to one per user?

Started by Adrift, May 31, 2004, 10:31:09 AM

Previous topic - Next topic

Adrift

I would like to set it up so users can only give one karma point to other users - a positive or negative. That way the total possible number of karma points any single user has can not be larger than the total number of users.

I'm currently doing something like this by setting wait time to 2147483647 hours, but is there a more elegant solution?
Thanks
Adrift

Oldiesmann

Yeah, it's possible. First, comment out the following db query in Sources/Karma.php:

// Delete any older items from the log. (karmaWaitTime is by hour.)
db_query("
DELETE FROM {$db_prefix}log_karma
WHERE " . time() . " - logTime > " . ($modSettings['karmaWaitTime'] * 3600), __FILE__, __LINE__);


And then

Find
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

// You decided to go back on your previous choice?
db_query("
UPDATE {$db_prefix}log_karma
SET action = $dir, logTime = " . time() . "
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);

// It was recently changed the OTHER way... so... reverse it!
if ($dir == 1)
updateMemberData($_REQUEST['uid'], array('karmaGood' => '+', 'karmaBad' => '-'));
else
updateMemberData($_REQUEST['uid'], array('karmaBad' => '+', 'karmaGood' => '-'));


Replace:
fatal_error('Sorry. You have already applauded or smitten this user. You cannot do this again.', false);

The only thing you might want to do is add some javascript to warn the person that they will not be allowed to undo that action.
Michael Eshom
Christian Metal Fans

Advertisement: