============================================================================================================================
Modification Title: Forum Based Restrict Guest Browsing v1.0

Author: John Briggs & WormHole

Updated by : Ahmad

Description:
This modification will restrict viewing of specific forums selected in the admin forum options to members only and block guests.

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. 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: cp.php
==============
==========
Find Code:
==========

        $type31 = $type32 = $type33 = $type34 = '';
        if ($forum['private'] == 2) {
            $type32 = $selHTML;
        } elseif ($forum['private'] == 3) {
            $type33 = $selHTML;
        } elseif ($forum['private'] == 4) {
            $type34 = $selHTML;
        } elseif ($forum['private'] == 1) {
            $type31 = $selHTML;
        }

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

        // Forum Based Restrict Guest Browsing Mod Begin
        $fmemonly_yes = $fmemonly_no = '';
        switch ($forum['fmemonly']) {
            case 'yes':
                $fmemonly_yes = $selHTML;
                break;
            default:
                $fmemonly_no = $selHTML;
                break;
        }
        // Forum Based Restrict Guest Browsing Mod End

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

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['textdesc']?></td>
        <td bgcolor="<?php echo $altbg2?>"><textarea rows="4" cols="30" name="descnew"><?php echo htmlspecialchars($forum['description'])?></textarea></td>
        </tr>

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

        <!-- Forum Based Restrict Guest Browsing Mod Begin -->
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['fmemonlystatus']?></td>
        <td bgcolor="<?php echo $altbg2?>">
        <select name="fmemonlynew">
        <option value="yes" <?php echo $fmemonly_yes?>><?php echo $lang['textyes']?></option>
        <option value="no" <?php echo $fmemonly_no?>><?php echo $lang['textno']?></option>
        </select>
        </td>
        </tr>
        <!-- Forum Based Restrict Guest Browsing Mod End -->

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

            if ($newfname != $lang['textnewforum']) {
                $newfname = addslashes($newfname);
                $db->query("INSERT INTO $table_forums ( type, name,

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

 ) VALUES ('forum',

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

, fmemonly ) VALUES ('forum',

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

)");

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

, 'yes')");

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

            if ($newgname != $lang['textnewgroup']) {
                $newgname = addslashes($newgname);
                $db->query("INSERT INTO $table_forums 

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

 ) VALUES ('group',

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

, fmemonly ) VALUES ('group',

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

)");

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

, 'yes')");

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

            if ($newsubname != $lang['textnewsubf']) {
                $newsubname = addslashes($newsubname);
                $db->query("INSERT INTO $table_forums ( type, name,

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

 ) VALUES ('sub',

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

, fmemonly ) VALUES ('sub',

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

)");

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

, 'yes')");

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

            $guestpostingnew = (isset($guestpostingnew) && $guestpostingnew == 'on') ? 'on' : 'off';

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

            // Forum Based Restrict Guest Browsing Mod Begin
            $fmemonlynew = (isset($fmemonlynew) && $fmemonlynew == 'yes') ? 'yes' : 'no';
            // Forum Based Restrict Guest Browsing Mod End

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

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

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

 WHERE fid='$fdetails'");

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

, fmemonly='$fmemonlynew' WHERE fid='$fdetails'");

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

$forum = $db->fetch_array($query);

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

// Forum Based Restrict Guest Browsing Mod Begin
if (isset($forum['fmemonly']) && $forum['fmemonly'] != 'yes' && X_GUEST) {
    error($lang['fmemonlyerror']);
}
// Forum Based Restrict Guest Browsing Mod End

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

$forum = $db->fetch_array($query);

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

// Forum Based Restrict Guest Browsing Mod Begin
if (isset($forum['fmemonly']) && $forum['fmemonly'] != 'yes' && X_GUEST) {
    error($lang['fmemonlyerror']);
}
// Forum Based Restrict Guest Browsing Mod End

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

// Forum Based Restrict Guest Browsing Mod Begin
$lang['fmemonlystatus'] = "Allow Guests to view this forum?";
$lang['fmemonlyerror'] = "Sorry! But you must be registered or logged in to view this forum.";
// Forum Based Restrict Guest Browsing Mod End

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