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 nfmovil, October 09, 2016, 05:55:42 PM

Previous topic - Next topic

nfmovil

Quote from: Adrift on May 31, 2004, 10:31:09 AM
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

Quote from: Oldiesmann on May 31, 2004, 07:59:16 PM
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.

Hi, I get error 500 with this code in smf 2.0.12.
there is some new code for this mod?

Irisado

Please avoid reviving topics which are twelve years old in future.  Topic split with quotes added for context.

Since the topic you posted in relates to a version of SMF which isn't from the 2.0.x line, I'd imagine this could be part of your issue, or have you previously used it successfully with 2.0.11 or earlier?
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

Advertisement: