Code:##############################################################
## MOD Title: Users Reputations System v.1.0.0
## MOD Author: antongranik < anton@granik.com > (Anton Granik) http://granik.com
## MOD Description: Allows users to give reputation points to each others, earn it by posts and by "living" on forum, see the history of givings. Admin can edit users' reputations in admin cp. The whole system can be a text or a graphic version (5 different medals) and simple or advanced version (with choosing of how much reputation to give). You can get help on the system in the guide/ folder.
## MOD Version: 1.0.0
##
## Ported for phpNuke by PTM (http://www.topfunzone.com) and Refiner (http://support.rogbbtonukemods.com/)
##Updated for ravennuke latest by Snype (http://phpnuke-install.com)any help and support can be found at my site
##
## Installation Level: (Intermediate)
## Installation Time: 30 Minutes
## Files To Edit (15):
## viewonline.php
## viewtopic.php
## profile.php
## posting.php
## modcp.php
## includes/page_header.php
## includes/constants.php
## includes/usercp_viewprofile.php
## admin/index.php
## admin/admin_users.php
## templates/subSilver/profile_view_body.tpl
## templates/subSilver/viewtopic_body.tpl
## templates/subSilver/admin/user_edit_body.tpl
## language/lang_english/lang_main.php
## language/lang_english/lang_admin.php
##
## Included Files (21):
## reputation.php
## reputation_common.php
## reputation_mod_install_db_v100.php
## reputation_mod_install_users_v100.php
## reputation_mod_update_v001_to_002.php
## reputation_mod_update_v002_to_100.php
## admin/admin_reputation.php
## includes/functions_reputation.php
## language/lang_english/lang_reputation.php
## templates/subSilver/reputation.tpl
## templates/subSilver/admin/reputation_config_body.tpl
## images/reputation_add_minus.gif
## images/reputation_add_plus.gif
## images/reputation_medal_neg.gif
## images/reputation_medal_size_1.gif
## images/reputation_medal_size_2.gif
## images/reputation_medal_size_3.gif
## images/reputation_medal_size_4.gif
## images/reputation_medal_size_5.gif
## images/reputation_neg.gif
## images/reputation_pos.gif
##
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## 1. For the latest release always go to http://granik.com/forum/viewtopic.php?t=16
## 2. Official support forum is http://granik.com/forum/viewforum.php?f=3 If you download this mod from other sides then the mentioned sites above, it might cause malicious code to enter into your phpBB Forum.
## 3. Russian translation is included in folder lang_russian/
## 4. In folder different medals/buckets/ there are different medals. The medals are buckets with paint. :) Just copy these files to your forum_root_directory/images/
## 5. Special thanks to my wife and daughter for leaving me untouched while writing this mod :) , rockboyteek, Raul Duke, cherokee red, Patrick Simmons, aboyd, Infamy and all those I have forgotten for testing and helping...
## 6. Tested on phpbb 2.0.19, 2.0.20.
##############################################################
## MOD History:
##
## 2006-04-22, release version 1.0.0:
## 1) Changed page_constant to the proper one (officially reserved 5 constants).
## 2) Wrote the guide (look in folder guide/).
## 3) Fixed the bug with wrong points to subtract from your points when you give (thanks to aboyd).
## 4) Fixed the collisions with some mods (viewtopic and viewprofile didn't show up) (thanks to Infamy).
## 5) Fixed the bug in database ('user_reputation' field has to be float, not decimal) (thanks to Infamy).
##
## 2006-03-13, Version RC2 (0.0.2):
## 1) The stats in viewtopic are made only visible to admins/mods (configurable in admin cp) (idea: cherokee red)
## 2) Ability to set the limit of the amount of reputation points one can give out to a user (configurable in admin cp) (idea: Raul Duke)
## 3) Changed multiplications constants from 1-5 to 1.0-1.4 (to level a bit the givings)
## 4) The user gets a private message when he receives new reputation points (configurable in admin cp)
## 5) The admin can now see and edit users' reputations in admin cp -> user admin -> management
## 6) The ability to turn on the simple version of reputation givings: set default amount in admin cp and users won't think how much to give (idea: Patrick Simmons)
## 7) Fixed the bugs with postings by a new user (bug found: Raul Duke) and wrong givings' stats of a user (bug found: rockboyteek)
## 8) Now the reputations are decreased when a moderator removes the topics through ModCP.
##
## 2006-02-16, Version RC1 (0.0.1)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
# STEP 1/3: Uploading all new files
#
copy upload/*.php to *.php
copy upload/includes/*.php to includes/
copy upload/admin/*.php to admin/
copy upload/images/*.* to images/
copy upload/language/lang_english/*.php to language/lang_english/
copy upload/templates/subSilver/*.* to templates/subSilver/ ALSO UPLOAD TO THEMES/YOURTHEME/FORUMS
copy upload/templates/subSilver/admin/*.* to templates/subSilver/admin/
#
# STEP 2/3: Modifying existing phpBB2 Files
#
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/viewonline.php
#
#-----[ FIND ]------------------------------------------
#
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "faq.$phpEx";
break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
case PAGE_REPUTATION:
$location = $lang['Reputation'];
$location_url = "reputation.$phpEx";
break;
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/viewtopic.php
#
#-----[ FIND ]--------------------------------------
#
include_once("modules/$module_name/includes/bbcode.php");
#
#-----[ AFTER, ADD ]------------------------------------------
#
include('reputation_common.'.$phpEx);
include('includes/functions_reputation.'.$phpEx);
#
#-----[ FIND ]------------------------------------------
#
else
{
$l_edited_by = '';
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD Reputation Mod v.1.0.0
$reputation = '';
if ($postrow[$i]['user_id'] != ANONYMOUS)
{
if ($rep_config['rep_disable'] == 0)
{
if ($postrow[$i]['user_reputation'] == 0)
{
$reputation = $lang['Zero_reputation'];
} else
{
if ($rep_config['graphic_version'] == 0)
{
// Text version
$reputation = $lang['Reputation'] . ": ";
if ($postrow[$i]['user_reputation'] > 0)
{
$reputation .= "<strong><font color=\"green\">" . round($postrow[$i]['user_reputation'],1) . "</font></strong>";
} else {
$reputation .= "<strong><font color=\"red\">" . round($postrow[$i]['user_reputation'],1) . "</font></strong>";
}
$reputation_add = '';
} else {
// Graphic version
get_reputation_medals($postrow[$i]['user_reputation']);
}
}
$reputation .= " <a href=\"" . append_sid("reputation.$phpEx?a=add&" . POST_USERS_URL . "=" . $postrow[$i]['user_id']) . "&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&c=" . substr(md5($bbcode_uid),0,8) . "\" target=\"_blank\" onClick=\"popupWin = window.open(this.href, '" . $lang['Reputation'] . "', 'location,width=700,height=400,top=0,scrollbars=yes'); popupWin.focus(); return false;\"><img src=\"images/reputation_add_plus.gif\" alt=\"\" border=\"0\"><img src=\"images/reputation_add_minus.gif\" alt=\"\" border=\"0\"></a>";
$sql = "SELECT COUNT(user_id) AS count_reps
FROM " . REPUTATION_TABLE . " AS r
WHERE r.user_id = " . $postrow[$i]['user_id'] . "
GROUP BY user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain reputation stats for this user", '', __LINE__, __FILE__, $sql);
}
$row_rep = $db->sql_fetchrow($result);
if ($row_rep)
{
$reputation .= "<br /><a href=\"" . append_sid("reputation.$phpEx?a=stats&" . POST_USERS_URL . "=" . $postrow[$i]['user_id']) . "\" target=\"_blank\" onClick=\"popupWin = window.open(this.href, '" . $lang['Reputation'] . "', 'location,width=700,height=400,top=0,scrollbars=yes'); popupWin.focus(); return false;\">" . $lang['Votes'] . "</a>: " . $row_rep['count_reps'];
}
}
}
// END ADD Reputation Mod v.1.0.0
#
#-----[ FIND ]------------------------------------------
#
//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
#
#-----[ INLINE, ADD AFTER]------------------------------------------
#
, u.user_reputation
#
#-----[ FIND ]------------------------------------------
#
'POSTER_FROM' => $poster_from,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD Reputation Mod v.1.0.0
'REPUTATION_ADD' => $reputation_add,
'REPUTATION' => $reputation,
// END ADD Reputation Mod v.1.0.0
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/profile.php
#
#-----[ FIND ]------------------------------------------
#
include_once($phpbb_root_path . 'common.'.$phpEx);
#
#-----[ AFTER, ADD ]------------------------------------------
#
include($phpbb_root_path . 'reputation_common.'.$phpEx);
include('includes/functions_reputation.'.$phpEx);
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/posting.php
#
#-----[ FIND ]------------------------------------------
#
include_once("modules/Forums/includes/functions_post.php");
#
#-----[ AFTER, ADD ]------------------------------------------
#
include($phpbb_root_path . 'reputation_common.'.$phpEx);
include('includes/functions_reputation.'.$phpEx);
#
#-----[ FIND ]------------------------------------------
#
update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
#
#-----[ AFTER, ADD ]------------------------------------------
#
update_reputations($mode, $user_id);
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/modcp.php
#
#-----[ FIND ]------------------------------------------
#
include_once("modules/$module_name/includes/functions_admin.php");
#
#-----[ AFTER, ADD ]------------------------------------------
#
include($phpbb_root_path . 'reputation_common.'.$phpEx);
#
#-----[ FIND ]------------------------------------------
#
$count_sql = array();
while ( $row = $db->sql_fetchrow($result) )
{
$count_sql[] = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts - " . $row['posts'] . "
WHERE user_id = " . $row['poster_id'];
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
$count_sql = array();
while ( $row = $db->sql_fetchrow($result) )
{
$rep = ($rep_config['posts_to_earn'] != 0) ? (1/$rep_config['posts_to_earn']) : 0;
$count_sql[] = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts - " . $row['posts'] . ", user_reputation = user_reputation - " . $rep . "
WHERE user_id = " . $row['poster_id'];
}
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/includes/page_header.php
#
#-----[ FIND ]------------------------------------------
#
'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_REPUTATION' => $lang['Reputation'],
'U_REPUTATION' => append_sid('reputation.'.$phpEx),
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
define('PAGE_GROUPCP', -11);
#
#-----[ AFTER, ADD ]------------------------------------------
#
define('PAGE_REPUTATION', -1280);
#
#-----[ FIND ]------------------------------------------
#
define('VOTE_USERS_TABLE', $prefix.'_bbvote_voters');
#
#-----[ AFTER, ADD ]------------------------------------------
#
define('REPUTATION_TABLE', $prefix.'_reputation');
define('REPUTATION_CONFIG_TABLE', $prefix.'_reputation_config');
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
{
$u_search_author = urlencode(str_replace(array('&', ''', '"', '<', '>'), array('&', "'", '"', '<', '>'), $profiledata['username']));
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD Reputation Mod v.1.0.0
$reputation = '';
if ($rep_config['rep_disable'] == 0)
{
if ($profiledata['user_reputation'] == 0)
{
$reputation = $lang['Zero_reputation'];
} else
{
if ($rep_config['graphic_version'] == 0)
{
// Text version
if ($profiledata['user_reputation'] > 0)
{
$reputation .= "<strong><font color=\"green\">" . round($profiledata['user_reputation'],1) . "</font></strong>";
} else {
$reputation .= "<strong><font color=\"red\">" . round($profiledata['user_reputation'],1) . "</font></strong>";
}
} else {
// Graphic version
get_reputation_medals($profiledata['user_reputation']);
}
}
$sql = "SELECT COUNT(user_id) AS count_reps
FROM " . REPUTATION_TABLE . " AS r
WHERE r.user_id = " . $profiledata['user_id'] . "
GROUP BY user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain reputation stats for this user", '', __LINE__, __FILE__, $sql);
}
$row_rep = $db->sql_fetchrow($result);
if ($row_rep)
{
$reputation .= " <br /><span class=\"gensmall\">(<a href=\"" . append_sid("reputation.$phpEx?a=stats&" . POST_USERS_URL . "=" . $profiledata['user_id']) . "\" target=\"_blank\" onClick=\"popupWin = window.open(this.href, '" . $lang['Reputation'] . "', 'location,width=700,height=400,top=0,scrollbars=yes'); popupWin.focus(); return false;\">" . $lang['Votes'] . "</a>: " . $row_rep['count_reps'] . ")</span>";
}
}
// END ADD Reputation Mod v.1.0.0
#
#-----[ FIND ]------------------------------------------
#
'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD Reputation Mod v.1.0.0
'REPUTATION' => $reputation,
// END ADD Reputation Mod v.1.0.0
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/admin/index.php
#
#-----[ FIND ]------------------------------------------
#
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "index.$phpEx?pane=right";
break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
case PAGE_REPUTATION:
$location = $lang['Reputation'];
$location_url = "reputation.$phpEx";
break;
#
#-----[ FIND ]------------------------------------------
#
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "index.$phpEx?pane=right";
break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
case PAGE_REPUTATION:
$location = $lang['Reputation'];
$location_url = "reputation.$phpEx";
break;
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/admin/admin_users.php
#
#-----[ FIND ]------------------------------------------
#
$icq = ( !empty($HTTP_POST_VARS['icq']) ) ? trim(strip_tags( $HTTP_POST_VARS['icq'] ) ) : '';
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$reputation = ( !empty($HTTP_POST_VARS['reputation']) ) ? trim(strip_tags( $HTTP_POST_VARS['reputation'] ) ) : '';
#
#-----[ FIND ]------------------------------------------
#
$icq = stripslashes($icq);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$reputation = intval(stripslashes($reputation));
#
#-----[ FIND ]------------------------------------------
#
$sql = "UPDATE " . USERS_TABLE . "
SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "',
#
#-----[ INLINE, ADD AFTER]------------------------------------------
#
user_reputation = '" . str_replace("\'", "''", $reputation) . "',
#
#-----[ FIND ]------------------------------------------
#
$icq = stripslashes($icq);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$reputation = intval($reputation);
#
#-----[ FIND ]------------------------------------------
#
$icq = $this_userdata['user_icq'];
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$reputation = $this_userdata['user_reputation'];
#
#-----[ FIND ]------------------------------------------
#
$s_hidden_fields .= '<input type="hidden" name="icq" value="' . str_replace("\"", """, $icq) . '" />';
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$s_hidden_fields .= '<input type="hidden" name="reputation" value="' . str_replace("\"", """, $reputation) . '" />';
#
#-----[ FIND ]------------------------------------------
#
'ICQ' => $icq,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
'REPUTATION' => $reputation,
#
#-----[ FIND ]------------------------------------------
#
'L_ICQ_NUMBER' => $lang['ICQ'],
#
#-----[ BEFORE, ADD ]------------------------------------------
#
'L_REPUTATION' => $lang['Reputation'],
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/templates/subSilver/profile_view_body.tpl
ALSO DO THIS TO YOUR CURRENT THEME ASWELL THEMES/YOURTHEME/FORUMS
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_INTERESTS}:</span></td>
<td> <b><span class="gen">{INTERESTS}</span></b></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_REPUTATION}:</span></td>
<td> <span class="gen">{REPUTATION}</span></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/templates/subSilver/viewtopic_body.tpl
ALSO DO THIS TO YOUR CURRENT THEME ASWELL THEMES/YOURTHEME/FORUMS
#
#-----[ FIND ]------------------------------------------
#
<br />{postrow.POSTER_FROM}
#
#-----[ AFTER, ADD ]------------------------------------------
#
<br />{postrow.REPUTATION}
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/templates/subSilver/admin/user_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1"><span class="gen">{L_ICQ_NUMBER}</span></td>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
<tr>
<td class="row1"><span class="gen">{L_REPUTATION}</span></td>
<td class="row2">
<input class="post" type="text" name="reputation" size="10" maxlength="15" value="{REPUTATION}" />
</td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Reputation mod v.1.0.0
$lang['Reputation'] = 'Reputation';
$lang['No_votes'] = 'No votes';
$lang['Votes'] = 'votes';
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Reputation mod v.1.0.0
$lang['Reputation'] = 'Reputation';
$lang['Reputation_Config_Title'] = 'Reputation System Configuration';
$lang['Reputation_Config_Explain'] = 'Here you can set the options for Users Reputation System.';
$lang['Rep_config_updated'] = 'Reputation System config updated';
$lang['Click_return_rep_config'] = '%sReturn to Reputation System config%s';
$lang['Disable_rep'] = 'Disable Reputation System';
$lang['Graphic_version'] = 'Graphic version';
$lang['Show_stats_to_mods'] = 'Show the stats of given points only to administrators/moderators';
$lang['PM_notify'] = 'Notify users through PM when they receive new reputation points';
$lang['Posts_to_earn'] = 'Amount of posts to earn 1 reputation point (0 - to disable)';
$lang['Days_to_earn'] = 'Amount of days on forum to earn 1 reputation point (0 - to disable)';
$lang['Flood_control_time'] = 'Minimum amount of minutes between reputation givings by the same user (no use for admins and mods)';
$lang['Medal1_to_earn'] = 'Amount of reputation points to earn the 1st size medal';
$lang['Medal2_to_earn'] = 'Amount of reputation points to earn the 2nd size medal';
$lang['Medal3_to_earn'] = 'Amount of reputation points to earn the 3rd size medal';
$lang['Medal4_to_earn'] = 'Amount of reputation points to earn the 4th size medal';
$lang['Given_rep_to_earn'] = 'Amount of given reputation to earn 1 reputation point (0 - to disable)';
$lang['Repsum_limit'] = 'Limit of giving reputation points to a user (0 - no limits)';
$lang['Default_amount'] = 'Turn the simple version on and set the default amount of every giving to this number (0 - to disable)';
#
# STEP 3/3: Updating the database
#
Run:
reputation_mod_install_db_v100.php
reputation_mod_install_users_v100.php
Then delete them!
IF THIS FAILS PLEASE USE MY SQL FILE AND MANUALLY ADD THEM VIA PHPMYADMIN
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
|