============================================================================================================================
Modification Name: Minimum Experience Level For Forum Access

Version: 1.0

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Description: This modification will allow you to specify a minimum experience level a user must have before they may access a given forum.
                   This modification requires the Experience RPG Stats Graph to be installed before it can be used.

Compatability: XMB 1.9.5 SP1

Install Note: This modification requires Experience RPG Stats Graph to be installed.
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
====================================
===================================
Paste The Following Code and Submit Changes:
===================================

ALTER TABLE $table_forums ADD experience SMALLINT(3) NOT NULL default '0';

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

// Minimum Experience Level For Forum Access Mod Begin
$lang['mefa_experience'] = 'Minimum Experience Level Required for Access:<br /><span class="smalltxt">(Enter 0 to disable)</span>';
$lang['mefa_noaccess'] = 'You must be at least Level *level* to view this forum!';
// Minimum Experience Level For Forum Access Mod End

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

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

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

        // Minimum Experience Level For Forum Access Mod Begin
        $forum['experience'] = (int) $forum['experience'];
        // Minimum Experience Level For Forum Access 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:
===============

        <!-- Minimum Experience Level For Forum Access Mod Begin -->
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['mefa_experience']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="text" name="experiencenew" value="<?php echo $forum['experience']?>" size="5" /></td>
        </tr>
        <!-- Minimum Experience Level For Forum Access Mod End -->
        
==========
Find Code:
==========

 ) VALUES ('forum',

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

, experience ) VALUES ('forum',

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

)");

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

, '0')");

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

 ) VALUES ('group',

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

, experience ) VALUES ('group',

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

)");

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

, '0')");

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

 ) VALUES ('sub',

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

, experience ) VALUES ('sub',

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

)");

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

, '0')");

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

            $descnew = addslashes($descnew);

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

            // Minimum Experience Level For Forum Access Mod Begin
            $experiencenew = (int) $experiencenew;
            // Minimum Experience Level For Forum Access 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:
================

, experience='$experiencenew' 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:
===============

// Minimum Experience Level For Forum Access Mod Begin
if (isset($forums['experience']) && $forums['experience'] > 0) {
    if (X_GUEST || (floor((pow(log10($self['postnum']), 3) + 1)) < $forums['experience'] && !X_SADMIN)) {
        error(str_replace("*level*", $forums['experience'], $lang['mefa_noaccess']));
    }
}
// Minimum Experience Level For Forum Access Mod End

============================================================================================================================
=======
Step 5:
=======
=====================
Edit File: forumdisplay.php
=====================
====================
Find Code (2nd Instance:
=====================

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

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

// Minimum Experience Level For Forum Access Mod Begin
if (isset($forum['experience']) && $forum['experience'] > 0) {
    if (X_GUEST || (floor((pow(log10($self['postnum']), 3) + 1)) < $forum['experience'] && !X_SADMIN)) {
        error(str_replace("*level*", $forum['experience'], $lang['mefa_noaccess']));
    }
}
// Minimum Experience Level For Forum Access Mod End

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

if (!$action) {

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

// Minimum Experience Level For Forum Access Mod Begin
if (isset($forum['experience']) && $forum['experience'] > 0) {
    if (X_GUEST || (floor((pow(log10($self['postnum']), 3) + 1)) < $forum['experience'] && !X_SADMIN)) {
        error(str_replace("*level*", $forum['experience'], $lang['mefa_noaccess']));
    }
}
// Minimum Experience Level For Forum Access 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:
=============

    $querypost = $db->query("SELECT p.*, f.experience 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 = '';
    $tmoffset = ($timeoffset * 3600) + ($addtime * 3600);

    while ($post = $db->fetch_array($querypost)) {
        // Minimum Experience Level For Forum Access Mod Begin
        if (isset($post['experience']) && $post['experience'] > 0) {
            if (X_GUEST || (floor((pow(log10($self['postnum']), 3) + 1)) < $post['experience'] && !X_SADMIN)) {
                error(str_replace('*level*', $post['experience'], $lang['mefa_noaccess']));
            }
        }
        // Minimum Experience Level For Forum Access Mod End

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