Title: Forum Based Minimum Characters Per Post v1.0

Author: John Briggs

Description:
This modification will allow you to set in forum options the minimum characters required in posts in order to make a post.

Compatability: XMB 1.9.8 SP3

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. 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 Admin Panel -> Insert Raw SQL
==============================

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

============================================================================================================================
=======
Step 2:
=======
==============
Edit File: cp.php
==============

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

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

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

        // Forum Based Minimum Characters Per Post Mod Begin
        $forum['minchars'] = (int) $forum['minchars'];
        // Forum Based Minimum Characters Per Post Mod End

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

        <input type="checkbox" name="guestpostingnew" value="on" <?php echo $checked8?> /><?php echo $lang['textanonymousposting']?><br />
        </td>
        </tr>

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

        <!-- Forum Based Minimum Characters Per Post Mod Begin -->
        <?php
        printsetting2($lang['minchars'], 'mincharsnew', $forum['minchars'], 2);
        ?>
        <!-- Forum Based Minimum Characters Per Post Mod End -->


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

        if ($newfname != $lang['textnewforum']) {
            $newfname = addslashes($newfname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting) VALUES ('forum', '$newfname', '$newfstatus', '', '', ".(int)$newforder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newffup.", '1|1', 'yes', 'on', 'on', '', 'off', 'off', 'yes')");
        }

=============================
Find Code In Above Statement In-line:
=============================


) VALUES ('forum',

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

, minchars) VALUES ('forum',

============================
Find Code At End Of The Same Line:
============================

)");

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

, '0')");

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

        if ($newgname != $lang['textnewgroup']) {
            $newgname = addslashes($newgname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting, closethreads, favatar, minchars) VALUES ('group', '$newgname', '$newgstatus', '', '', ".(int)$newgorder.", '', '', '', '', '', '', 0, 0, 0, 0, '', '', '', '', '', 'off', 'off', 'yes', '0')");
        }

=============================
Find Code In Above Statement In-line:
=============================

) VALUES ('group',

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

, minchars) VALUES ('group',

============================
Find Code At End Of The Same Line:
============================

)");

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

, '0')");

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

        if ($newsubname != $lang['textnewsubf']) {
            $newsubname = addslashes($newsubname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting, closethreads, favatar, minchars) VALUES ('sub', '$newsubname', '$newsubstatus', '', '', ".(int)$newsuborder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newsubfup.", '1|1', 'yes', 'on', 'on', '', 'off', 'off', 'yes', '0')");
        }

=============================
Find Code In Above Statement In-line:
=============================

) VALUES ('sub',

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

, minchars) VALUES ('sub',

============================
Find Code At End Of The Same Line:
============================

)");

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

, '0')");

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

        $guestpostingnew = formOnOff('guestpostingnew');

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

        // Forum Based Minimum Characters Per Post Mod Begin
        $mincharsnew = formInt('mincharsnew');
        // Forum Based Minimum Characters Per Post Mod End

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

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

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

        $db->query("UPDATE ".X_PREFIX."forums SET
            minchars='$mincharsnew',

============================================================================================================================
=======
Step 3:
=======
===============
Edit File: post.php
===============
=======================
Find Code (First Occurence):
=======================

            if ($forums['guestposting'] != 'on' && $username == 'Anonymous') {
                error($lang['textnoguestposting']);
            }

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

            // Forum Based Minimum Characters Per Post Mod Begin
            $forums['minchars'] = intval($forums['minchars']);
            if (strlen($message) < $forums['minchars']) {
                $message = str_replace("*chars*", $forums['minchars'], $lang['mincharsmsg']);
                error($message);
            }
            // Forum Based Minimum Characters Per Post Mod End

=================
Find Code & Delete:
=================

        if (!$subject && !$message) {
            error($lang['postnothing']);
        }

=========================
Find Code (Second Occurence):
=========================

            if ($forums['guestposting'] != 'on' && $username == 'Anonymous') {
                error($lang['textnoguestposting']);
            }

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

            // Forum Based Minimal Characters Per Post Mod Begin
            if (trim($message) == '') {
                error($lang['mincharsnomsg']);
            }

            $forums['minchars'] = intval($forums['minchars']);
            if (strlen($message) < $forums['minchars']) {
                $message = str_replace("*chars*", $forums['minchars'], $lang['mincharsmsg']);
                error($message);
            }
            // Forum Based Minimal Characters Per Post Mod End


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

            if ((trim($subject) == '' && $pid == $isfirstpost['pid']) && !(isset($delete) && $delete == 'yes')) {
                error($lang['textnosubject']);
            }

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

            // Forum Based Minimum Characters Per Post Mod Begin
            if (trim($message) == '') {
                error($lang['mincharsnomsg']);
            }

            $forums['minchars'] = intval($forums['minchars']);
            if (strlen($message) < $forums['minchars']) {
                $message = str_replace("*chars*", $forums['minchars'], $lang['mincharsmsg']);
                error($message);
            }
            // Forum Based Minimum Characters Per Post Mod End

============================================================================================================================
=======
Step 4:
=======
=======================
Edit File: lang/English.lang.php
=======================
==================================
Add Code At Very Bottom Of File Above ?>
==================================

// Forum Based Minimum Chars Per Post Mod Begin
$lang['minchars'] = "Minimum characters per post needed:<br /><span class=\"smalltxt\">If set to 0 then there is no minimum.</span>";
$lang['mincharsmsg'] = "Sorry! You need to type at least *chars* characters to be able to post in this forum. Please go back and try again.";
$lang['mincharsnomsg'] = "You have not entered a message to post. Please go back and do so now.";
// Forum Based Minimum Chars Per Post Mod End

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