============================================================================================================================
Modification Name: Forum Based Minimal Posts Needed

Version: 1.0

Author: FunForum, John Briggs

Contributors: Steven Waters

Description:
This modification will add three options to your Forum Options.
There you can set a minimal postcount that's needed to make new threads, replies and a post count that's needed to enter a forum.
It will also add a block at the top of the threadlist and thread mentioning the amount of posts needed, if there are any needed.
These limitations do not count for Super Administrators.

Copyright:  2010 John Briggs. All Rights Reserved.

Compatability: XMB 1.9.5 SP1

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

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

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================

Upload provided file named "SQL.txt" & click "Submit Changes" button.

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above  ?>
============================

// Forum Based Minimal Posts Needed Mod Begin
$lang['mpnp'] = "Minimal number of posts needed before a <strong>reply</strong> can be made in this forum:<br /><font class=\"smalltxt\">If set to 0 then there is no minimum.</font>";
$lang['mpnt'] = "Minimal number of posts needed before a new <strong>thread</strong> can be started in this forum:<br /><font class=\"smalltxt\">If set to 0 then there is no minimum.</font>";
$lang['mpfa'] = "Minimal number of posts needed before a person can enter this <strong>forum</strong> and view its threads:<br /><font class=\"smalltxt\">If set to 0 then there is no minimum.</font>";
$lang['mpnpe'] = "Sorry but you do not have enough posts to reply in this forum.<br />You need at least *posts* post(s) to be able to reply in this forum.";
$lang['mpnte'] = "Sorry but you do not have enough posts to start a thread in this forum.<br />You need at least *posts* post(s) to be able to start a thread in this forum.";
$lang['mpfae'] = "Sorry but you do not have enough posts to view this forum and its threads.<br />You need at least *posts* post(s) to be able to view this forum and its content.";
$lang['mpnpi'] = " &raquo; You need at least *posts* post(s) to be able to reply in this forum.";
$lang['mpnti'] = " &raquo; You need at least *posts* post(s) to be able to start a thread in this forum.";
$lang['mpfai'] = " &raquo; You need at least *posts* post(s) to be able to view this forum and its threads.";
$lang['mpfi'] = "Forum Information";
// Forum Based Minimal Posts Needed Mod End

============================================================================================================================
=======
Step 3:
=======
==============
Edit File: cp.php
==============
==========
Find Code:
==========

        $forum['description'] = stripslashes($forum['description']);

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

        // Forum Based Minimal Posts Needed Mod Begin
        $forum['mpfa'] = (int) $forum['mpfa'];
        $forum['mpnp'] = (int) $forum['mpnp'];
        $forum['mpnt'] = (int) $forum['mpnt'];
        // Forum Based Minimal Posts Needed Mod End

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

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['texttheme']?></td>
        <td bgcolor="<?php echo $altbg2?>"><?php echo $themelist?></td>
        </tr>

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

        <!-- Forum Based Minimal Posts Needed Mod Begin -->
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['mpfa']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="text" name="mpfanew" value="<?php echo $forum['mpfa']?>" /></td>
        </tr>
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['mpnp']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="text" name="mpnpnew" value="<?php echo $forum['mpnp']?>" /></td></tr>
        </tr>
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['mpnt']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="text" name="mpntnew" value="<?php echo $forum['mpnt']?>" /></td></tr>
        </tr>
        <!-- Forum Based Minimal Posts Needed Mod End -->

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

                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting, awardmoney ) VALUES ('forum', '$newfname', '$newfstatus', '', '', ".(int)$newforder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newffup.", '1|1', 'yes', 'on', 'on', '', 'off', 'yes')");

===============================
Find Code IN-LINE In Above Statement:
===============================

) VALUES ('forum',

================
Replace Code With:
================

, mpnt, mpnp, mpfa ) VALUES ('forum',

==============================
Find Code At End Of Above Statement:
==============================

)");

================
Replace Code With:
================

, '0', '0', '0')");

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

                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting, awardmoney ) VALUES ('group', '$newgname', '$newgstatus', '', '', ".(int)$newgorder.", '', '', '', '', '', '', 0, 0, 0, 0, '', '', '', '', '', 'off', 'yes')");

===============================
Find Code IN-LINE In Above Statement:
===============================

) VALUES ('group',

================
Replace Code With:
================

, mpnt, mpnp, mpfa ) VALUES ('group',

==============================
Find Code At End Of Above Statement:
==============================

)");

================
Replace Code With:
================

, '0', '0', '0')");

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

                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting, awardmoney ) VALUES ('sub', '$newsubname', '$newsubstatus', '', '', ".(int)$newsuborder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newsubfup.", '1|1', 'yes', 'on', 'on', '', 'off', 'yes')");

===============================
Find Code IN-LINE In Above Statement:
===============================

) VALUES ('sub',

================
Replace Code With:
================

, mpnt, mpnp, mpfa ) VALUES ('sub',

==============================
Find Code At End Of Above Statement:
==============================

)");

================
Replace Code With:
================

, '0', '0', '0')");

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

            $descnew = addslashes($descnew);

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

            // Forum Based Minimal Posts Needed Mod Begin
            $mpnpnew = (int) $mpnpnew;
            $mpntnew = (int) $mpntnew;
            $mpfanew = (int) $mpfanew;
            // Forum Based Minimal Posts Needed Mod End

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

$db->query("UPDATE $table_forums SET name='$namenew', description='$descnew',

==============================
Find Code At End Of Above Statement:
==============================

 WHERE fid='$fdetails'");

================
Replace Code With:
================

, mpnp='$mpnpnew', mpnt='$mpntnew', mpfa='$mpfanew' WHERE fid='$fdetails'");

============================================================================================================================
=======
Step 4:
=======
===============
Edit File: post.php
===============
==========
Find Code:
==========

if (($fid == 0 && $tid == 0) || ( $forums['type'] != 'forum' && $forums['type'] != 'sub' && $forums['fid'] != $fid)) {
    $posterror = $lang['textnoforum'];
}

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

// Forum Based Minimal Posts Needed Mod Begin
if (isset($forums['mpfa']) && $forums['mpfa'] != 0) {
    if (X_GUEST) {
        $message = str_replace("*posts*", $forums['mpfa'], $lang['mpfae']);
        error($message);
    } else if (isset($self['postnum']) && $self['postnum'] < $forums['mpfa'] && !X_SADMIN) {
        $message = str_replace("*posts*", $forums['mpfa'], $lang['mpfae']);
        error($message);
    }
}
// Forum Based Minimal Posts Needed Mod End

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

    if (!isset($topicsubmit) || !$topicsubmit) {

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

    // Forum Based Minimal Posts Needed Mod Begin
    if (isset($forums['mpnt']) && $forums['mpnt'] != 0 && isset($self['postnum']) && $self['postnum'] < $forums['mpnt'] && !X_SADMIN) {
        $message = str_replace("*posts*", $forums['mpnt'], $lang['mpnte']);
        error($message);
    }
    // Forum Based Minimal Posts Needed Mod End

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

    if (!isset($replysubmit) || !$replysubmit) {

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

    // Forum Based Minimal Posts Needed Mod Begin
    if (isset($forums['mpnp']) && $forums['mpnp'] != 0 && isset($self['postnum']) && $self['postnum'] < $forums['mpnp'] && !X_SADMIN) {
        $message = str_replace("*posts*", $forums['mpnp'], $lang['mpnpe']);
        error($message);
    }
    // Forum Based Minimal Posts Needed Mod End

============================================================================================================================
=======
Step 5:
=======
=====================
Edit File: forumdisplay.php
=====================
==========
Find Code:
==========

loadtemplates(

================
Replace Code With:
================

loadtemplates(
'forumdisplay_mpn_info',

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

eval('echo "'.template('header').'";');

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

// Forum Based Minimal Posts Needed Mod Begin
if (isset($forum['mpfa']) && $forum['mpfa'] != 0) {
    if (X_GUEST) {
        $message = str_replace("*posts*", $forum['mpfa'], $lang['mpfae']);
        error($message);
    } else if (isset($self['postnum']) && $self['postnum'] < $forum['mpfa'] && !X_SADMIN) {
        $message = str_replace("*posts*", $forum['mpfa'], $lang['mpfae']);
        error($message);
    }
}
// Forum Based Minimal Posts Needed Mod End

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

$t_extension = get_extension($lang['toppedprefix']);

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

// Forum Based Minimal Posts Needed Mod Begin
$minimal_posts_needed = '';
if (isset($forum['mpnp']) && $forum['mpnp'] != 0 || isset($forum['mpnt']) && $forum['mpnt'] != 0 || isset($forum['mpfa']) && $forum['mpfa'] != 0) {
    $Ffie = $showfi = '';
    if (isset($forum['mpfa']) && $forum['mpfa'] != 0) {
        $lang['mpfai'] = str_replace("*posts*", $forum['mpfa'], $lang['mpfai']);
        $showfi .= $lang['mpfai'];
        $Ffie = '<br />';
    }

    if (isset($forum['mpnp']) && $forum['mpnp'] != 0) {
        $lang['mpnpi'] = str_replace("*posts*", $forum['mpnp'], $lang['mpnpi']);
        $showfi .= $Ffie; $showfi .= $lang['mpnpi'];
        $Ffie = '<br />';
        if (isset($forum['mpnp']) && isset($self['postnum']) && $self['postnum'] < $forum['mpnp'] && !X_SADMIN) {
            $replylink = '';
        }
    }

    if (isset($forum['mpnt']) && $forum['mpnt'] != 0) {
        $lang['mpnti'] = str_replace("*posts*", $forum['mpnt'], $lang['mpnti']);
        $showfi .= $Ffie;
        $showfi .= $lang['mpnti'];
        if (isset($forum['mpnt']) && isset($self['postnum']) && $self['postnum'] < $forum['mpnt'] && !X_SADMIN) {
            $newpolllink = $newtopiclink = '';
        }
    }
    eval('$minimal_posts_needed = "'.template('forumdisplay_mpn_info').'";');
}
// Forum Based Minimal Posts Needed Mod End

============================================================================================================================
=======
Step 6:
=======
===================
Edit File: viewthread.php
===================
==========
Find Code:
==========

loadtemplates(

================
Replace Code With:
================

loadtemplates(
'forumdisplay_mpn_info',

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

    eval('echo stripslashes("'.template('viewthread').'");');

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

    // Forum Based Minimal Posts Needed Mod Begin
    if (isset($forum['mpfa']) && $forum['mpfa'] != 0) {
        if (X_GUEST) {
            $message = str_replace("*posts*", $forum['mpfa'], $lang['mpfae']);
            error($message, false);
        } else if (isset($self['postnum']) && $self['postnum'] < $forum['mpfa'] && !X_SADMIN) {
            $message = str_replace("*posts*", $forum['mpfa'], $lang['mpfae']);
            error($message, false);
        }
    }

    $minimal_posts_needed = '';
    if (isset($forum['mpnp']) && $forum['mpnp'] != 0 || isset($forum['mpnt']) && $forum['mpnt'] != 0 || isset($forum['mpfa']) && $forum['mpfa'] != 0 ) {
        $Ffie = $showfi = '';
        if (isset($forum['mpfa']) && $forum['mpfa'] != 0) {
            $lang['mpfai'] = str_replace("*posts*", $forum['mpfa'], $lang['mpfai']);
            $showfi .= $lang['mpfai'];
            $Ffie = '<br />';
        }

        if (isset($forum['mpnp']) && $forum['mpnp'] != 0) {
            $lang['mpnpi'] = str_replace("*posts*", $forum['mpnp'], $lang['mpnpi']);
            $showfi .= $Ffie;
            $showfi .= $lang['mpnpi'];
            $Ffie = '<br />';
            if (isset($forum['mpnp']) && isset($self['postnum']) && $self['postnum'] < $forum['mpnp'] && !X_SADMIN) {
                $replylink = $quickreply = '';
            }
        }

        if (isset($forum['mpnt']) && $forum['mpnt'] != 0) {
            $lang['mpnti'] = str_replace("*posts*", $forum['mpnt'], $lang['mpnti']);
            $showfi .= $Ffie;
            $showfi .= $lang['mpnti'];

            if (isset($forum['mpnt']) && isset($self['postnum']) && $self['postnum'] < $forum['mpnt'] && !X_SADMIN) {
                $newpolllink = $newtopiclink = '';
            }
        }
        eval('$minimal_posts_needed = "'.template('forumdisplay_mpn_info').'";');
    }
    // Forum Based Minimal Posts Needed Mod End

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

    $querypost = $db->query("SELECT * FROM $table_posts WHERE fid='$fid' AND tid='$tid' ORDER BY pid");
    $posts = '';
    $tmoffset = ($timeoffset * 3600) + ($addtime * 3600);
    while ($post = $db->fetch_array($querypost)) {
    
=============
Replace With:
=============

    // Forum Based Minimal Posts Needed Mod Begin
    $querypost = $db->query("SELECT p.*, f.mpfa FROM $table_posts p LEFT JOIN $table_forums f ON p.fid=f.fid WHERE p.fid='$fid' AND p.tid='$tid' ORDER BY p.pid");
    $posts = '';
    $post_check = false;

    $tmoffset = ($timeoffset * 3600) + ($addtime * 3600);

    while ($post = $db->fetch_array($querypost)) {
        if (isset($post['mpfa']) && $post['mpfa'] > 0) {
            if (X_GUEST || (isset($self['postnum']) && $self['postnum'] < $post['mpfa'] && !X_SADMIN)) {
                error(str_replace('*posts*', $post['mpfa'], $lang['mpfae']));
            }
        }
        // Forum Based Minimal Posts Needed Mod End

============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
==================================
Create New Template: forumdisplay_mpn_info
==================================
================================
Add Code & Click Submit Changes:
================================

<table cellspacing="0" cellpadding="0" border="0" width="$tablewidth" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr class="category">
<td><strong><font color="$cattext">$lang[mpfi]</font></strong></td>
</tr>
<tr bgcolor="$altbg2" class="tablerow">
<td align="left">$showfi</td>
</tr>
</table>
</td>
</tr>
</table>
<br />

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
====================
Edit Template: viewthread
====================
==========
Find Code:
==========

$poll

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

$minimal_posts_needed

============================================================================================================================
=======
Step 9:
=======
===============================
Go To Administration Panel --> Templates
===============================
=======================================
Edit Templates: forumdisplay and forumdisplay_admin
=======================================
==========
Find Code:
==========

$subforums

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

$minimal_posts_needed

============================================================================================================================
Enjoy!