Title: Forum Based Guest Download Attachment Status v1.0

Author: John Briggs

Description:
This mod will provide a option in your forum options to allow/disallow downloading of attachments by guests.

Compatability: XMB 1.9.5

Copyright:  2006 John Briggs. All rights reserved.

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

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

Author Note:
You downloaded this hack from XMBMods.com, the #1 source for XMB related downloads.
Please visit http://www.xmbmods.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:
==========

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

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

        $attachgueston = $attachguestoff = '';
        switch ($forum['attachguest']) {
            case 'on':
                $attachgueston = $selHTML;
                break;
            default:
                $attachguestoff = $selHTML;
                break;
        }

==========
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 $forum['description']?></textarea></td>
        </tr>

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

        <?php
        printsetting1($lang['attachgueststatus'], 'attachguestnew', $attachgueston, $attachguestoff);
        ?>

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

            if ($newfname != $lang['textnewforum']) {
                $newfname = addslashes($newfname);
                $db->query("INSERT INTO $table_forums ( type, fid, 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', '', '', '$newforder', '1', '', 'no', 'yes', 'yes', '', '', '0', '0', '$newffup', '1|1', 'yes', 'on', 'on', '', 'off')");
            }

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

 ) VALUES ('forum',

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

, attachguest ) VALUES ('forum',

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

)");

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

, 'on')");

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

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

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

 ) VALUES ('group',

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

, attachguest ) 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, fid, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting ) VALUES ('sub', '', '$newsubname', '$newsubstatus', '', '', '$newsuborder', '1', '', 'no', 'yes', 'yes', '', '', '0', '0', '$newsubfup', '1|1', 'yes', 'on', 'on', '', 'off')");
            }

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

 ) VALUES ('sub',

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

, attachguest ) VALUES ('sub',

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

)");

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

, 'yes')");

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

            $check_vars = array('allowhtmlnew', 'allowsmiliesnew', 'allowbbcodenew', 'allowimgcodenew', 'attachstatusnew', 'pollstatusnew', 'guestpostingnew');
            foreach ($check_vars as $key) {
                if ($$key != 'on' && $$key != 'yes') {
                    $$key = 'off';
                }
            }

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

            $attachguestnew = ($attachguestnew == 'on') ? 'on' : 'off';

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

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

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

 WHERE fid='$fdetails'");

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

, attachguest='$attachguestnew' WHERE fid='$fdetails'");

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

=========================
Edit File: viewthread.php
=========================

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

loadtemplates(

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

loadtemplates('viewthread_post_attachment_no',

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

                eval("\$post['message'] .= \"".template('viewthread_post_attachmentimage')."\";");

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

                if (isset($forum['attachguest']) && $forum['attachguest'] == 'off' && X_GUEST) {
                    eval("\$post['message'] .= \"".template('viewthread_post_attachment_no')."\";");
                } else {
                    eval("\$post['message'] .= \"".template('viewthread_post_attachmentimage')."\";");
                }
==========
Find Code:
==========

                eval("\$post['message'] .= \"".template('viewthread_post_attachment')."\";");

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

                if (isset($forum['attachguest']) && $forum['attachguest'] == 'off' && X_GUEST) {
                    eval("\$post['message'] .= \"".template('viewthread_post_attachment_no')."\";");
                } else {
                    eval("\$post['message'] .= \"".template('viewthread_post_attachment')."\";");
                }

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

} elseif ($action == "attachment" && $forum['attachstatus'] != 'off') {

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

    if (isset($forum['attachguest']) && $forum['attachguest'] == 'off' && X_GUEST) {
        error($lang['attachguesterror']);
    }

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

================================
Edit File: lang/English.lang.php
================================

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

$lang['attachgueststatus'] = "Guest Download Attachment Status:<br /><span class=\"smalltxt\">To disable guests from downloading attachments set this to off.</span>";
$lang['attachguesterror'] = "Sorry, you must be registered or logged in to download attachments.";

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

=======================================
Go to administration panel -> templates
=======================================

==============================================
Create template: viewthread_post_attachment_no
==============================================

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

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

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