##
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit: viewtopic.php
## includes/functions_post.php
## language/lang_english/lang_main.php
## templates/subSilver/subSilver.cfg
## templates/subSilver/viewtopic_body.tpl
## Included Files: thanks.php
## templates/subSilver/thanks.tpl
## templates/subSilver/thanks_popup.tpl
## templates/subSilver/images/lang_english/icon_thank.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:
##
## A mod which allows you to thank a post that a user has posted.
## When the Thanks button is pressed a page is displayed saying they have successfully thanked the user for their post.
## You can choose whether that page should be a popup or not; by editing the $popup_enabled to 0 or 1 in viewtopic.php and thanks.php
## If set to 0, the page displayed will automatically be redirected to the post in 5 seconds.
##
## You can view the thanks given and thanks received by a user in the topic under their posts.
## You are also shown the users who have thanked the specific post.
## When the post has been deleted the thanked received for the poster is decreased as well as the thanks given by other users.
##
##############################################################
## MOD History:
##
## 2007-10-26 - Version 0.2.6
## - Updates thanks_given and thanked_received when posts are deleted
##
## 2006-10-29 - Version 0.2.5a
## - Thanks icon updated
##
## 2006-10-23 - Version 0.2.5
## - Bug Fix: Thanks button was sometimes displayed even though the user had thanked the post
##
## 2006-10-22 - Version 0.2.4
## - Removes the thanks button from posts that the user has already thanked
##
## 2006-10-21 - Version 0.2.3
## - Updated the way "Thanked 2 Times in 1 Posts" is displayed. Posts are now referred to the total number of posts that were thanked by other users instead of the user's total posts.
##
## 2006-10-19 - Version 0.2.2
## - Bug Fix: Adjusted Thanked by row in viewtopic to wrap the users who thanked the post
##
## 2006-10-19 - Version 0.2.1
## - Bug Fix: Moved Thanks icon back next to quote icon since the ICQ icon gets displayed over the thanks icon if the user has an ICQ number set (couldn't find a reasonable solution)
##
## 2006-09-27 - Version 0.2.0
## - Moved Thanks icon to right hand side of where Profile, PM, links are displayed
## - Made the username of people who thanked a user link to their profile
## - Be able to select whether the thanks should popup or be displayed on the same page
##
## 2006-09-12 - Version 0.1.1
## - Bug Fix: Thanks received wasn't updating correctly
##
## 2006-09-11 - Version 0.1.0
## - Initial Release (for phpBB 2.0.21)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
# Change phpbb_posts and phpbb_users to your tables
#
ALTER TABLE `phpbb_posts` ADD `thanks_count` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
ALTER TABLE `phpbb_posts` ADD `thanks_from_user_id` TEXT NULL;
ALTER TABLE `phpbb_users` ADD `user_thanks_received` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
ALTER TABLE `phpbb_users` ADD `user_thanks_given` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
#
#-----[ COPY ]------------------------------------------
#
copy root/thanks.php to thanks.php
copy root/templates/subSilver/thanks.tpl to templates/subSilver/thanks.tpl
copy root/templates/subSilver/thanks_popup.tpl to templates/subSilver/thanks_popup.tpl
copy root/templates/subSilver/images/lang_english/icon_thank.gif to templates/subSilver/images/lang_english/icon_thank.gif
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
$pagination = generate_pagination("viewtopic.$phpEx?". $pagination_printertopic . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&". $pagination_highlight . $pagination_finish_rel, $total_replies, $pagination_ppp, $start);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Start Thank Post by User Mod
//
// Set to 1 to use pop-ups instead of using the same window
$popup_enabled = 0;
if ($popup_enabled == 1) {
$thanks_javascript ='<SCRIPT>
<Begin>
</script>';
}
//
// End Thank Post by User Mod
//
#
#-----[ FIND ]------------------------------------------
#
'FORUM_ID' => $forum_id,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
'THANKS_JAVASCRIPT' => $thanks_java.script,
#
#-----[ FIND ]------------------------------------------
#
$search = '<a>' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '</a>';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Start Thank Post by User Mod
//
$thanks_img = '';
if ( ($userdata['session_logged_in']) && ($userdata['user_id'] != $poster_id) ) {
// Posts SQL
$sql = "SELECT thanks_from_user_id
FROM " . POSTS_TABLE . "
WHERE post_id = " . $postrow[$i]['post_id'];
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain post information", '', __LINE__, __FILE__, $sql);
}
$post_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$already_thanked = 0;
if ($post_row['thanks_from_user_id'] != null) {
$thanked_users = explode("|",$post_row['thanks_from_user_id']);
$thanked_count = count($thanked_users);
// Loop through all users who thanked the post
for ($x = 0; $x < $thanked_count; $x++) {
if ($thanked_users[$x] == $userdata['user_id']) {
$already_thanked = 1;
}
}
}
// If the user hasn't thanked this post
if ($already_thanked == 0) {
$temp_url = append_sid("thanks.$phpEx?p=" . $postrow[$i]['post_id']);
if ($popup_enabled == 1) {
$thanks_img = '<a><img></a>';
}
else {
$thanks_img = '<a><img></a>';
}
}
}
//
// End Thank Post by User Mod
//
#
#-----[ FIND ]------------------------------------------
#
$template->assign_block_vars('postrow', array(
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//
// Start Thank Post by User Mod
//
// If the user isn't anonymous
if ($postrow[$i]['user_id'] != ANONYMOUS) {
// From Users SQL
$sql = "SELECT user_posts, user_thanks_given, user_thanks_received
FROM " . USERS_TABLE . "
WHERE user_id = " . $postrow[$i]['user_id'];
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// Thanked Posts SQL
$sql = "SELECT COUNT(thanks_count) AS thanks_count
FROM " . POSTS_TABLE . "
WHERE poster_id = " . $postrow[$i]['user_id'] . "
AND thanks_count <> 0";
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain posts information", '', __LINE__, __FILE__, $sql);
}
$thanked_post_count = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$thanks_given = $lang['Thanks_thanks'] . ': ' . $user_row['user_thanks_given'];
$thanks_received = $lang['Thanks_thanked_1'] . ' ' . $user_row['user_thanks_received'] . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_post_count['thanks_count'] . ' ' . $lang['Thanks_thanked_3'];
}
else {
$thanks_given = "";
$thanks_received = "";
}
//
// End Thank Post by User Mod
//
#
#-----[ FIND ]------------------------------------------
#
'POSTER_NAME' => $poster,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'POSTER_THANKS_GIVEN' => $thanks_given,
'POSTER_THANKS_RECEIVED' => $thanks_received,
#
#-----[ FIND ]------------------------------------------
#
'EDIT' => $edit,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'THANKS_IMG' => $thanks_img,
#
#-----[ FIND ]------------------------------------------
#
$template->assign_block_vars('postrow.switch_no_buddy_ignore', array());
}
//-- fin mod : profile cp --------------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Start Thank Post by User Mod
//
if ($postrow[$i]['thanks_count'] >= 1) {
$thanked_by = "";
$thanked_users = explode("|",$postrow[$i]['thanks_from_user_id']);
$thanked_count = $postrow[$i]['thanks_count'];
// Loop through all users who thanked the post
for ($x = 0; $x <thanked_count>sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($x >= 1) { $thanked_by .= ", "; }
// Add user to thanked by list
$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $user_row['user_id'];
$thanked_by .= '<a>' . $user_row['username'] . '</a>';
}
$template->assign_block_vars('postrow.thanks', array(
'L_THANKS_TEXT' => $lang['Thanks_thanked_by'],
'THANKS_USERS' => $thanked_by)
);
}
//
// End Thank Post by User Mod
//
#
#-----[ OPEN ]---------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]---------------------------------
#
function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
global $userdata, $user_ip;
#
#-----[ AFTER, ADD ]---------------------------------
#
//
// Start Thank Post by User Mod
//
// Thanked Listing SQL
$sql = "SELECT thanks_from_user_id, thanks_count, poster_id
FROM " . POSTS_TABLE . "
WHERE post_id = '$post_id'";
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain posts information", '', __LINE__, __FILE__, $sql);
}
$post_thanks = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// If this post was thanked, then continue
if ($post_thanks['thanks_from_user_id']) {
$thanked_users = explode("|", $post_thanks['thanks_from_user_id']);
// Loop through all users who thanked the post
for ($i = 0; $i <count>sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}
$from_user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$thanks_given = $from_user_row['user_thanks_given'] - 1;
// Update DB with the new thanks given
$update_sql = "UPDATE " . USERS_TABLE . "
SET user_thanks_given = '" . $thanks_given . "'
WHERE user_id = " . $from_user;
if ( !($result = $db->sql_query($update_sql)) ) {
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $update_sql);
}
// Remove 1 from the user who was thanked
$sql = "SELECT user_thanks_received
FROM " . USERS_TABLE . "
WHERE user_id = " . $to_user;
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}
$to_user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$thanks_received = $to_user_row['user_thanks_received'] - 1;
// Update DB with the new thanks given
$update_sql = "UPDATE " . USERS_TABLE . "
SET user_thanks_received = '" . $thanks_received . "'
WHERE user_id = " . $to_user;
if ( !($result = $db->sql_query($update_sql)) ) {
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $update_sql);
}
}
}
//
// End Thank Post by User Mod
//
#
#-----[ OPEN ]---------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]---------------------------------
#
//
// That's all, Folks!
#
#-----[ BEFORE, ADD ]---------------------------------
#
//
// Start Thank Post by User Mod
//
$lang['Thanks_title'] = 'Thank User for Post';
$lang['Thanks_text'] = 'Thank this user for their post';
$lang['Thanks_thanked_by'] = 'Thanked by';
$lang['Thanks_thanks'] = 'Thanks';
$lang['Thanks_thanked_1'] = 'Thanked';
$lang['Thanks_thanked_2'] = 'Times in';
$lang['Thanks_thanked_3'] = 'Posts';
$lang['Thanks_not_logged_in'] = 'You aren't logged in.';
$lang['Thanks_no_post_specified'] = 'No post was specified.';
$lang['Thanks_no_such_post'] = 'Post doesn't exist.';
$lang['Thanks_anonymous'] = 'You can't thank an anonymous post.';
$lang['Thanks_self'] = 'You can't thank your own post.';
$lang['Thanks_already_thanked'] = 'You have already thanked this post.';
$lang['Thanks_success_1'] = 'Post by';
$lang['Thanks_success_2'] = 'in thread';
$lang['Thanks_success_3'] = 'has successfully been thanked.';
$lang['Thanks_success_back'] = 'Click here if you can't wait or if redirection is not supported by your browser';
$lang['Thanks_success_redirect'] = 'Redirecting to the topic/post you came from in 5 seconds.';
//
// End Thank Post by User Mod
//
#
#-----[ OPEN ]---------------------------------
#
templates/Integra2/Integra2.cfg
#
#-----[ FIND ]---------------------------------
#
$images['icon_edit'] = "$current_template_images/{LANG}/icon_edit.gif" width="$topic_iw" height="$topic_ih" class="imgtopic";
#
#-----[ AFTER, ADD ]---------------------------------
#
$images['icon_thank'] = "$current_template_images/{LANG}/icon_thank.gif" width="$topic_iw" height="$topic_ih" class="imgtopic";
#
#-----[ OPEN ]------------------------------------------
#
templates/Integra2/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<script></script>
#
#-----[ BEFORE, ADD ]---------------------------------
#
{THANKS_JAVASCRIPT}
#
#-----[ FIND ]------------------------------------------
#
{postrow.QUOTE_IMG}
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{postrow.QUOTE_IMG}
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
{postrow.QUOTE_IMG} {postrow.THANKS_IMG}
#
#-----[ FIND ]------------------------------------------
#
</tr>
<END>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<BEGIN>
<tr>
<td>
<table>
<tr>
<td><span>{postrow.thanks.L_THANKS_TEXT}: {postrow.thanks.THANKS_USERS}</span></td>
</tr>
</table>
</td>
</tr>
<END>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM