Title: Forum Based Post Count Controls v1.0

Author: John Briggs

Update by: MasterTuga
Update by: Robert Chapin (miqrogroove)

Description: This modification will provide a option in your forum options to allow/dissalow post count increase for members.

Copyright:  2009 The XMB Group

Compatibility: XMB 1.9.11

Install Note: Before adding this modification to your forum you should back up all files related to this mod.

License Note: This modification is released under the GPL License. A copy is provided with this software.

Version: 1.3

Last Updated: 17 March 2009
=======================================================================================================

=======
Step 0:
=======

===================================
Go To Admin Panel -> Insert Raw SQL
===================================

Paste the following code and hit submit:

ALTER TABLE `$table_forums` ADD `fpcount` set('yes','no') NOT NULL default 'yes';

=======================================================================================================================
=======
Step 1:
=======

=================
Edit File: cp.php
=================

==========
Find Code:
==========

        if ($forum['attachstatus'] == "on") {
            $checked6 = $cheHTML;
        } else {
            $checked6 = '';
        }

===============
Add Code Below:
===============

        $fpcountyes = $fpcountno = '';
        switch ($forum['fpcount']) {
            case 'yes':
                $fpcountyes = $selHTML;
                break;
            default:
                $fpcountno  = $selHTML;
                break;
        }

==========
Find Code:
==========

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['textdeleteques']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="checkbox" name="delete" value="<?php echo $forum['fid']?>" /></td>
        </tr>

===============
Add Code Below:
===============

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['fpcountstatus']?></td>
        <td bgcolor="<?php echo $altbg2?>">
        <select name="fpcountnew">
        <option value="yes" <?php echo $fpcountyes?>><?php echo $lang['textyes']?></option>
        <option value="no" <?php echo $fpcountno?>><?php echo $lang['textno']?></option>
        </select>
        </td>
        </tr>
		
==========
Find Code:
==========

        $delete = formInt('delete');

===============
Add Code Below:
===============

        $fpcountnew = formYesNo('fpcountnew');
		
==========
Find Code:
==========

        $db->query("UPDATE ".X_PREFIX."forums SET

===============
Add Code Below:
===============

            fpcount='$fpcountnew',

=======================================================================================================================
=======
Step 2:
=======

===================
Edit File: post.php
===================

==========
Find Code:
==========

            $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+1 WHERE username='$username'");
        
=============
Replace With:
=============

			if ($forum['fpcount'] == 'yes') {
                $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+1 WHERE username='$username'");
            }
			
==========
Find Code:
==========

            $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+1 WHERE username='$username'");
        
=============
Replace With:
=============

			if ($forum['fpcount'] == 'yes') {
                $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+1 WHERE username='$username'");
            }
			
==========
Find Code:
==========

                $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='".$db->escape_var($orig['author'])."'");
        
=============
Replace With:
=============

            	if ($forum['fpcount'] == 'yes') {
                    $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='".$db->escape($orig['author'])."'");
            	}
				
=======================================================================================================================

=======
Step 3:
=======

=====================
Edit File: header.php
=====================

==========
Find Code:
==========

/* Set Up HTML Templates and Themes */

===============
Add Code Above:
===============

// Assert Forum Based Post Count Controls Translation
if (!isset($lang['fpcountstatus'])) {
    require_once(ROOT.'include/translation.inc.php');
    setNewLangValue('fpcountstatus', 'Count New Posts?:');
    loadLang($langfile);
}

=======================================================================================================================

=======
Step 4:
=======

============================
Edit File: topicadmin.php:
============================

==========
Find Code:
==========

                    $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-{$result['pidcount']} WHERE username='".$db->escape_var($result['author'])."'");
        
=============
Replace With:
=============

                    if ($forums['fpcount'] == 'yes') {
                        $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-{$result['pidcount']} WHERE username='".$db->escape_var($result['author'])."'");
                    }
					
==========
Find Code:
==========

                        $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-{$result['pidcount']} WHERE username='$dbauthor'");
        
=============
Replace With:
=============

                    if ($forums['fpcount'] == 'yes') {
                        $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-{$result['pidcount']} WHERE username='$dbauthor'");
                    }
					
==========
Find Code:
==========

                        $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='$dbauthor'");
        
=============
Replace With:
=============

                        if ($forums['fpcount'] == 'yes') {
                            $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='$dbauthor'");
                        }
					
==========
Find Code:
==========

                    $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+{$result['pidcount']} WHERE username='".$db->escape_var($result['author'])."'");
        
=============
Replace With:
=============

                    if ($otherforum['fpcount'] == 'yes') {
                        $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum+{$result['pidcount']} WHERE username='".$db->escape_var($result['author'])."'");
                    }
					
        
=======================================================================================================================

=======
Step 5:
=======

============================
Edit File: tools.php:
============================

==========
Find Code:
==========

             . " INNER JOIN (SELECT author, COUNT(pid) as pcount FROM ".X_PREFIX."posts GROUP BY author) AS query2 ON m.username = query2.author "
        
=============
Replace With:
=============

             . " INNER JOIN (SELECT author, COUNT(pid) as pcount FROM ".X_PREFIX."posts AS p INNER JOIN ".X_PREFIX."forums f ON p.fid=f.fid WHERE fpcount='yes' GROUP BY author) AS query2 ON m.username = query2.author "
					
=======================================================================================================================
=============
Enjoy
=============