News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Karma modification controlled by permissions?

Started by SomaliDoc, May 27, 2008, 06:06:44 PM

Previous topic - Next topic

SomaliDoc

Karma modification is controlled by number of posts? right!

I want it to be controlled by forum permissions, eg: only global moderators can modify the Karma?
Is this possible and how

Thanks

青山 素子

It is a permission. Check for "Change other people's karma" on the permission screen (for SMF 1.1).
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


SomaliDoc

thanks, I couldn't see that!!!

I think I need glasses.. 8)

One more question... How I can increase the given applauds...
For example: from 1 applaud to 10 applaud per 1 click

lax.slash

#3
I don't know how to change it through the ACP...

Admins can manually add Karma or remove Karma by:

Going to the User Control Panel, and looking for Karma in Forum Profile Information. Then, change the value(s) to what you want.

Hope that helps.

青山 素子

Did a quick check, and this should fix it.

Open Sources/Karma.php and find the line like the similar:


// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;


Change the numbers to the amount you wish to add or subtract. The -1 is the smite value, 1 is applaud.

Make sure to edit the file in a text or code editor, not a WYSIWYG like Dreamweaver.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


lax.slash

Quote from: Motoko-chan on May 28, 2008, 09:44:58 PM
Did a quick check, and this should fix it.

Open Sources/Karma.php and find the line like the similar:


// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;


Change the numbers to the amount you wish to add or subtract. The -1 is the smite value, 1 is applaud.

Make sure to edit the file in a text or code editor, not a WYSIWYG like Dreamweaver.

Sorry if this is considered stealing the topic.... ???
Can we possibly have an ACP feature added for modifying Karma increments?

SomaliDoc


SomaliDoc

I tried and modified in a code editor but the applaud button only substracts 1 & the smite button gives 65534 at once!!!!!

I think there should other things needed to be modified...

Here is the Karma code..

if (!defined('SMF'))
die('Hacking attempt...');

/* This file contains one humble function, which applauds or smites a user.

void ModifyKarma()
- gives or takes karma from a user.
- redirects back to the referrer afterward, whether by javascript or
  the passed parameters.
- requires the karma_edit permission, and that the user isn't a guest.
- depends on the karmaMode, karmaWaitTime, and karmaTimeRestrictAdmins
  settings.
- is accessed via ?action=modifykarma.
*/

// Modify a user's karma.
function ModifyKarma()
{
global $modSettings, $db_prefix, $txt, $ID_MEMBER, $user_info, $topic;

// If the mod is disabled, show an error.
if (empty($modSettings['karmaMode']))
fatal_lang_error('smf63');

// If you're a guest or can't do this, blow you off...
is_not_guest();
isAllowedTo('karma_edit');

checkSession('get');

// If you don't have enough posts, tough luck.
// !!! Should this be dropped in favor of post group permissions?  Should this apply to the member you are smiting/applauding?
if ($user_info['posts'] < $modSettings['karmaMinPosts'])
fatal_error($txt['smf60'] . $modSettings['karmaMinPosts'] . '.');

// And you can't modify your own, punk! (use the profile if you need to.)
if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $ID_MEMBER)
fatal_lang_error('smf61', false);

// The user ID _must_ be a number, no matter what.
$_REQUEST['uid'] = (int) $_REQUEST['uid'];

// Applauding or smiting?
$dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;

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

// Start off with no change in karma.
$action = 0;

// Not an administrator... or one who is restricted as well.
if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum'))
{
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);
}

// They haven't, not before now, anyhow.
if (empty($action) || empty($modSettings['karmaWaitTime']))
{
// Put it in the log.
db_query("
REPLACE INTO {$db_prefix}log_karma
(action, ID_TARGET, ID_EXECUTOR, logTime)
VALUES ($dir, $_REQUEST[uid], $ID_MEMBER, " . time() . ')', __FILE__, __LINE__);

// Change by one.
updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karmaGood' : 'karmaBad' => '+'));
}
else
{
// 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' => '-'));
}

// Figure out where to go back to.... the topic?
if (isset($topic))
redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . $_REQUEST['m']);
// Hrm... maybe a personal message?
elseif (isset($_REQUEST['f']))
redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . $_REQUEST['pm'] : ''));
// JavaScript as a last resort.
else
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>...</title>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
history.go(-1);
// ]]></script>
</head>
<body>&laquo;</body>
</html>';

obExit(false);
}

?>


Advertisement: