##############################################################
## MOD Title: Advanced Karma Mod
## MOD Author: Nome <nome>
## MOD Original Author: countach44 <root>
## MOD Description: This will add the ability to give users karma points
## Stacks karma points in two different groups
## so that users both have + and - shown
## Has an hour based wait option (UNIX time based, no Windows here)
## MOD Version: 1.0.1
##
## Installation Level: easy
## Installation Time: 10 Minutes
## Files To Edit: 6
## viewtopic.php
## includes/usercp_viewprofile.php
## templates/subSilver/template.cfg
## templates/subSilver/profile_view_body.tpl
## templates/subSilver/viewtopic_body.tpl
## language/lang_english/lang_main.php
## Included Files: karma.php, icon_applaud.gif, icon_smite.gif,
## mysql_schema.sql (for not installed forums only!)
##############################################################
## Author Notes: Thanks to countach44 for starting the mode
## I've made a few changes to his file, so that the
## MOD looks more attractive. At least to me ;)
##
##############################################################
## This MOD is released under the GPL License.
## Intellectual Property is retained by the MOD Author(s) listed above
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ ALTER ]------------------------------------------
#
ALTER TABLE `phpbb_users` ADD `karma_plus` MEDIUMINT DEFAULT '0' NOT NULL ;
ALTER TABLE `phpbb_users` ADD `karma_minus` MEDIUMINT DEFAULT '0' NOT NULL ;
ALTER TABLE `phpbb_users` ADD `karma_time` BIGINT DEFAULT '0' NOT NULL ;
#
# NOTE: 'phpbb_' is our $table_prefix
#
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
//
// Calculate the number of days this user has been a member ($memberdays)
// Then calculate their posts per day
//
#
#-----[ BEFORE, ADD ]------------------------------------
#
//Fetch karma
$sql = "select karma_plus from " . USERS_TABLE . " where username='$profiledata[username]'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_plus = $array[0];
$sql = "select karma_minus from " . USERS_TABLE . " where username='$profiledata[username]'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_minus = $array[0];
#
#-----[ FIND ]------------------------------------------
#
'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
#
#-----[ AFTER, ADD ]------------------------------------
#
'KARMA_PLUS' => $karma_plus,
'KARMA_MINUS' => $karma_minus,
#
#-----[ FIND ]------------------------------------------
#
'L_EMAIL' => $lang['Email'],
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_KARMA' => $lang['Karma'],
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
'L_AUTHOR' => $lang['Author'],
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_KARMA' => $lang['Karma'],
#
#-----[ FIND ]------------------------------------------
#
//
// Again this will be handled by the templating
// code at some point
#
#-----[ BEFORE, ADD ]------------------------------------
# It's the only way I could get it working, not very neat though :(
//Fetch karma
$sql = "select karma_plus from " . USERS_TABLE . " where username='$poster'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_plus = $array[0];
$sql = "select karma_minus from " . USERS_TABLE . " where username='$poster'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_minus = $array[0];
$applaud_img = '';
$applaud_alt = '';
$applaud_url = '';
$smite_img = '';
$smite_alt = '';
$smite_url = '';
if ( ( $userdata['session_logged_in'] ) && ( $userdata['user_id'] != $poster_id ) )
{
$applaud_alt = $lang['Applaud'];
$applaud_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=applaud');
$applaud_img = '<img>';
$smite_alt = $lang['Smite'];
$smite_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=smite');
$smite_img = '<img>';
}
#
#-----[ FIND ]------------------------------------------
#
'POSTER_NAME' => $poster,
#
#-----[ AFTER, ADD ]------------------------------------
#
'POSTER_ID' => $poster_id,
#
#-----[ FIND ]------------------------------------------
#
'POSTER_JOINED' => $poster_joined,
#
#-----[ AFTER, ADD ]------------------------------------
#
'POSTER_KARMA_PLUS' => $karma_plus,
'POSTER_KARMA_MINUS' => $karma_minus,
#
#-----[ FIND ]------------------------------------------
#
'MINI_POST_IMG' => $mini_post_img,
#
#-----[ AFTER, ADD ]------------------------------------
#
'APPLAUD_IMG' => $applaud_img,
'SMITE_IMG' => $smite_img,
#
#-----[ FIND ]------------------------------------------
#
'L_MINI_POST_ALT' => $mini_post_alt,
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_APPLAUD_ALT' => $applaud_alt,
'L_SMITE_ALT' => $smite_alt,
#
#-----[ FIND ]------------------------------------------
#
'U_MINI_POST' => $mini_post_url,
#
#-----[ AFTER, ADD ]------------------------------------
#
'U_APPLAUD' => $applaud_url,
'U_SMITE' => $smite_url,
#*********************************************************************
#
# NOTE: You will have to apply these changes to all existing templates
# I use SubSilver as an example
#
#*********************************************************************
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/subSilver.cfg
#
#-----[ FIND ]------------------------------------------
#
$images['icon_minipost'] = "$current_template_images/icon_minipost.gif";
#
#-----[ AFTER, ADD ]------------------------------------
#
$images['icon_applaud'] = "$current_template_images/icon_applaud.gif";
$images['icon_smite'] = "$current_template_images/icon_smite.gif";
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td><span>{L_EMAIL_ADDRESS}:</span></td>
<td><span>{EMAIL_IMG}</span></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------
#
<tr>
<td><span>{L_KARMA}:</span></td>
<td><span>+{KARMA_PLUS}/-{KARMA_MINUS}</span></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
{postrow.POSTER_POSTS}
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------------
#
<font>{L_KARMA}: +{postrow.POSTER_KARMA_PLUS}/-{postrow.POSTER_KARMA_MINUS} <a>{postrow.APPLAUD_IMG}</a><a>{postrow.SMITE_IMG}</a></font>
#**************************************************************************
#
# NOTE: You will have to apply these changes to all existing language packs
# I use lang_english as an example
#
#**************************************************************************
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]------------------------------------
#
$lang['Karma'] = 'Karma';
$lang['Applaud'] = 'Applaud';
$lang['Smite'] = 'Smelt';
$lang['Return_To_Topic'] = 'Return to topic';
$lang['Too_Soon'] = 'You can't change karma yet. Not enough time has passed';
$lang['No_Self_Karma'] = 'You can't change your karma';
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ |