Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: MrMike on December 01, 2008, 12:24:55 AM

Title: Hiding Karma on a board-by-board basis?
Post by: MrMike on December 01, 2008, 12:24:55 AM
Is it possible to hide Karma from a particular group of message boards?

I have 2 boards out of ~70 that I'd like to hide it on- the people there are complaining about it endlessly (you'd have to know them, lol). They're obsessed with their karma and how it varies, etc etc etc. So I'd just like to hide it for this set of boards.

Is this possible? Give me an idea of how or where to do it and I'll hard-code it into my system.
Title: Re: Hiding Karma on a board-by-board basis?
Post by: [SiNaN] on December 25, 2008, 04:31:24 AM
You can use $context['current_board'] for that. Like this:

Display.template.php

Find:

// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
<br />
', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
elseif ($modSettings['karmaMode'] == '2')
echo '
<br />
', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '<br />';

// Is this user allowed to modify this member's karma?
if ($message['member']['karma']['allow'])
echo '
<a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
<a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a><br />';


Replace:

if (!in_array($context['current_board'], array(1, 2, 3, 4)))
{
// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
<br />
', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
elseif ($modSettings['karmaMode'] == '2')
echo '
<br />
', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '<br />';

// Is this user allowed to modify this member's karma?
if ($message['member']['karma']['allow'])
echo '
<a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
<a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';m=', $message['id'], ';sesc=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a><br />';
}


...where 1, 2, 3, 4 are the IDs of the boards.
Title: Re: Hiding Karma on a board-by-board basis?
Post by: MrMike on December 26, 2008, 12:48:44 PM
Thanks, Blue Dream. I "solved" this problem with the Karma Piggy modification (now the users *want* the Karma enabled, lol) but I'll save this code for another use I have in mind. Thank you again.
Title: Re: Hiding Karma on a board-by-board basis?
Post by: [SiNaN] on December 28, 2008, 03:48:11 AM
My pleasure.