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.8 Engage Final SP2

Updated For 1.9.8 By: WormHole @ XMB Garage

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 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:
==========

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

===============
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 ".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')");
        }

=====================================
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 ".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 ('group', '$newgname', '$newgstatus', '', '', ".(int)$newgorder.", '', '', '', '', '', '', 0, 0, 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 ".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 ('sub', '$newsubname', '$newsubstatus', '', '', ".(int)$newsuborder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$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:
==========

        $guestpostingnew = formOnOff('guestpostingnew');

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

        $attachguestnew = formOnOff('attachguestnew');

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

            guestposting='$guestpostingnew'

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

            guestposting='$guestpostingnew',
            attachguest='$attachguestnew'

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

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

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

'viewthread_printable_row',
'viewthread_multipage'

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

'viewthread_printable_row',
'viewthread_multipage',
'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:
==========

} else if ($action == 'attachment' && $forum['attachstatus'] != 'off' && $pid > 0 && $tid > 0) {

===============
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:
===============

// Forum Based Guest Download Attachment Status Mod Begin
$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.";
// Forum Based Guest Download Attachment Status Mod End

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

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