[BETA] No Increase Of User Post Counts
Verfasst: 11.05.2004 15:45
Code: Alles auswählen
#############################################################
## MOD Title: No Increase Of User Post Counts
## MOD Author: dOcToR bEaT < doctorbeat@eh-clan.de > (Andy) http://www.Eimer.EH-clan.de
## MOD Description: Features:
## - select forums not to increase user post counts
## - automaticly resync user post count on delete, move or split topics/posts over MCP.
## - configuration over ACP interface
##
## Mod Extension:
## - this extension is recommended, if you want to decrease user post counts of already existing forums before installation of No Increase Of User Post Counts
## - manualy resync user post counts over ACP with "Resync User Post Counts" from R45 (http://www.phpbb.com/phpBB/viewtopic.php?t=133360)
## - view included file "resync_user_post_counts_ext.txt" for installation instructions of this extension
##
## MOD Version: 1.0
##
## phpBB Version: 2.0.8
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: 5
## modcp.php
## 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 based on "Disable Post Count Increase" by Xore (http://www.phpbb.com/phpBB/viewtopic.php?t=138032)
##
##############################################################
## MOD History:
##
## 2004-04-20 - Version 1.0.0
## - First version
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
# Change the prefix 'phpbb_' accordingly. 'phpbb_' is the default prefix
#
ALTER TABLE `phpbb_forums` ADD `forum_count_posts` TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER `forum_last_post_id`;
#
#-----[ OPEN ]------------------------------------------
#
modcp.php
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT poster_id, COUNT(post_id) AS posts
FROM " . POSTS_TABLE . "
WHERE topic_id IN ($topic_id_sql)
GROUP BY poster_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sql = "SELECT p.poster_id, COUNT(p.post_id) AS posts
FROM (" . POSTS_TABLE . " p
LEFT JOIN " . FORUMS_TABLE . " f ON f.forum_count_posts = 1 AND p.forum_id = f.forum_id)
WHERE p.forum_id = f.forum_id
AND p.topic_id IN ($topic_id_sql)
GROUP BY p.poster_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
}
#
#-----[ FIND ]------------------------------------------
#
$sql = "UPDATE " . POSTS_TABLE . "
SET forum_id = $new_forum_id
WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
}
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
$sql = "SELECT forum_count_posts FROM ". FORUMS_TABLE . " WHERE forum_id = " .$new_forum_id;
$result = $db->sql_query($sql);
if( $row = $db->sql_fetchrow($result) )
{
$new_forum_count_posts = $row['forum_count_posts'];
}
$sql = "SELECT forum_count_posts FROM ". FORUMS_TABLE . " WHERE forum_id = " .$forum_id;
$result = $db->sql_query($sql);
if( $row = $db->sql_fetchrow($result) )
{
$old_forum_count_posts = $row['forum_count_posts'];
}
if( $old_forum_count_posts < $new_forum_count_posts )
{
$sql = "SELECT poster_id, COUNT(post_id) AS posts
FROM " . POSTS_TABLE . " WHERE topic_id IN ($topic_list)
GROUP BY poster_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
}
$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'];
}
$db->sql_freeresult($result);
if ( sizeof($count_sql) )
{
for($i = 0; $i < sizeof($count_sql); $i++)
{
if ( !$db->sql_query($count_sql[$i]) )
{
message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
}
}
}
}
else if( $old_forum_count_posts > $new_forum_count_posts )
{
$sql = "SELECT poster_id, COUNT(post_id) AS posts
FROM " . POSTS_TABLE . "
WHERE topic_id IN ($topic_list)
GROUP BY poster_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
}
$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'];
}
$db->sql_freeresult($result);
if ( sizeof($count_sql) )
{
for($i = 0; $i < sizeof($count_sql); $i++)
{
if ( !$db->sql_query($count_sql[$i]) )
{
message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
}
}
}
}
#
#-----[ 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 ]------------------------------------------
#
$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']) . "
#
#-----[ IN-LINE FIND ]------------------------------------------
#
forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ",
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
forum_count_posts = " . intval($HTTP_POST_VARS['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']) . "
#
#-----[ 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
Code: Alles auswählen
##############################################################
## MOD Title: No Increase Of User Post Counts - extension for Resync User Post Counts by R45 (http://www.phpbb.com/phpBB/viewtopic.php?t=133360)
## MOD Author: dOcToR bEaT < doctorbeat@eh-clan.de > (Andy) http://www.Eimer.EH-clan.de
## MOD Description: Extension of Resync User Post Counts for No Increase Of User Post Counts
##
## MOD Version: 0.0.1
##
## Installation Level: Easy
## Installation Time: 1 Minute
## Files To Edit: 1
## admin/admin_post_count_resync.php
## 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:
##
## - use simple method to resync post counts with No Increase Of User Post Counts
## - simple method is recommended, if you want to decrease user post counts of already existing forums after install of No Increase Of User Post Counts
## - use advanced method to resync post counts ignoring the No Increase Of User Post Counts
##
##############################################################
## MOD History:
##
## 2004-04-20 - Version 0.0.1
## - First version
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_post_count_resync.php
#
#-----[ FIND ]------------------------------------------
#
if($arguments == '')
{
if($mode != 'simple')
{
return 0;
}
}
$sql = "SELECT COUNT(*) as numrows
FROM " . POSTS_TABLE . "
WHERE poster_id = $user_id".$arguments;
#
#-----[ REPLACE WITH ]------------------------------------------
#
if($arguments == '')
{
if($mode != 'simple')
{
return 0;
}
else
{
$sql = "SELECT COUNT(*) as numrows
FROM (" . POSTS_TABLE . " p
LEFT JOIN " . FORUMS_TABLE . " f ON f.forum_count_posts = 1 AND p.forum_id = f.forum_id)
WHERE p.poster_id = $user_id
AND p.forum_id = f.forum_id".$arguments;
}
}
else
{
$sql = "SELECT COUNT(*) as numrows
FROM " . POSTS_TABLE . "
WHERE poster_id = $user_id".$arguments;
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
1. ja1. Wenn jemand in einem markierten Forum postet, erhöhen sich seine Postanzahl nicht?
2. Wenn dieser Beitrag dann gelöscht wird geht seine/ihre Beitragsanzahl nicht runter?
3. Wenn ein Thema aus einem Forum, in dem Beiträge nicht gezählt werden, in ein anderes Forum, in dem Beiträge gezählt werden, verschoben wird, dann erhöht sich die Postanzahl aller Benutzer, die in diesem Thema geposten haben?
4. Wenn ein Thema aus einem Forum, in dem Beiträge gezählt werden, in ein anderes Forum, in dem Beiträge nicht gezählt werden, verschoben wird, dann sinkt die Postanzahl aller Benutzer, die in diesem Thema geposten haben?
2. ja
3. ja
4. ja
5. Mit der Erweiterung für den Mod Resync User Post Counts kann man jeder Zeit die Postanzahlen aller Benutzer manuell auf ihren korrekten Wert setzen.
Der Mod funktioniert auch mit "Split Topic Type" von Ptirhiik

- "Disable Post Count Increase" von Xore erfüllt nur 1.+2.(http://www.phpbb.com/phpBB/viewtopic.php?t=138032)
- "Stop Post Count From Increasing" von The Pelican erfüllt scheinbar 3.+4. nicht mehr (http://www.phpbb.com/phpBB/viewtopic.ph ... &start=100)
Deshalb habe ich diesen Mod gemacht

Wäre cool, wenn ihn jemand von euch ausprobiert, um den beta-Status abschließen zu können
