All pastes #591430 Raw Edit

Stuff

public text v1 · immutable
#591430 ·published 2007-06-27 06:22 UTC
rendered paste body
############################################################# 
## MOD Title: Unincrement user posts 
## MOD Author: junglist < junglist@radiolodz.pl > N/A http://www.radiolodz.pl/nocnytrans/forum/
## MOD Description: In some forums user_post value won't be increased.
## MOD Version: 1.0.0 
## 
## Installation Level: Easy 
## Installation Time: 5 Minutes 
## Files To Edit: 4
##		  admin/admin_forums.php
##		  includes/functions_post.php
##		  language/lang_english/lang_admin.php
##		  templates/subSilver/admin/forum_edit_body.tpl 
## Included Files: N/A 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
## This mod is for forums where user_posts value is important for some reasons (points/cash mod, premisions).
## If You have forum eg OFFTOPIC where post shouldn't be counted You can simply add this flag with this mod to any forum.
############################################################## 
## MOD History: 
## 
##   2004-01-02 - Version 1.0.0 
##      - First version 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ SQL ]------------------------------------------ 
# 
ALTER TABLE `phpbb_forums` ADD `forum_count_posts` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `forum_last_post_id`;

# 
#-----[ OPEN ]------------------------------------------ 
#
admin/admin_forums.php

# 
#-----[ FIND ]------------------------------------------ 
# 
				$forumstatus = $row['forum_status'];

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
				if( $row['forum_count_posts'] == 1)
				{
					$count_posts = "checked=\"checked\"";
				}
				else
				{
					$count_posts = '';
				}

# 
#-----[ FIND ]------------------------------------------ 
# 
				$forum_id = ''; 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

				$count_posts = "checked=\"checked\"";
# 
#-----[ FIND ]------------------------------------------ 
# 
				'S_STATUS_LIST' => $statuslist,
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
				'S_COUNT_POSTS' => $count_posts,
# 
#-----[ FIND ]------------------------------------------ 
# 
				'L_FORUM_STATUS' => $lang['Forum_status'],
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
				'L_FORUM_COUNT_POSTS' => $lang['Forum_count_posts'],
# 
#-----[ FIND ]------------------------------------------ 
# 
			$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 
forum_status,

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 
 forum_count_posts,

# 
#-----[ FIND ]------------------------------------------ 
# 
				VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['count_posts']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 
, " . intval($HTTP_POST_VARS['forumstatus']) . "

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 
, " . intval($HTTP_POST_VARS['count_posts']) . "

# 
#-----[ FIND ]------------------------------------------ 
# 

$sql = "UPDATE " . FORUMS_TABLE . " 
SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . " 
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]); 

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 
forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", 

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 
forum_count_posts = " . intval($HTTP_POST_VARS['count_posts']) . ",

# 
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
# 
	if ($mode != 'poll_delete')
	{
		$sql = "UPDATE " . USERS_TABLE . "
			SET user_posts = user_posts $sign 
			WHERE user_id = $user_id";
		if (!$db->sql_query($sql, END_TRANSACTION))
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}
	}

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
	if ($mode != 'poll_delete')
	{
		$sql = "SELECT forum_count_posts FROM ". FORUMS_TABLE . " WHERE forum_id = " . $forum_id;
		$result = $db->sql_query($sql);
		if( $row = $db->sql_fetchrow($result) ) 
		{ 
			if( $row['forum_count_posts'] == 1 )
			{

				$sql = "UPDATE " . USERS_TABLE . "
					SET user_posts = user_posts $sign 
					WHERE user_id = $user_id";
				if (!$db->sql_query($sql, END_TRANSACTION))
				{
					message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
				}
			}
		}
	}

# 
#-----[ OPEN ]------------------------------------------ 
#
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
# 
$lang['Forum_status'] = 'Forum status';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
$lang['Forum_count_posts'] = 'Increment user posts';

# 
#-----[ OPEN ]------------------------------------------ 
#
templates/subSilver/admin/forum_edit_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
	<tr> 
	  <td class="row1">{L_FORUM_STATUS}</td>
	  <td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
	</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	<tr> 
	  <td class="row1">{L_FORUM_COUNT_POSTS}</td>
	  <td class="row2"><input type="checkbox" name="count_posts" value="1" {S_COUNT_POSTS} /></td>
	</tr>

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM