Title: Auto Subscribe To Threads Option v1.0

Author: John Briggs

Description:
This modification will provide an option in member control panel for members to choose to auto subscribe to threads on posting.
This modification will auto-check the checkbox in post reply and quick reply to Receive an email on reply.

Copyright:  2009 John Briggs. All rights reserved.

Compatability: XMB 1.9.11

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.

=======================================================================================================================================
=======
Step 1:
=======

==============================================================================================
Go To Admin Panel -> Insert Raw SQL -> Copy & Paste Code Below & click "Submit Changes" button
==============================================================================================

ALTER TABLE `$table_members` ADD `autosub` set('yes','no') NOT NULL default 'no';

=======================================================================================================================================
=======
Step 2:
=======

==================
Edit File: editprofile.php
==================

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

    $invchecked = '';
    if ($member['invisible'] == 1) {
        $invchecked = $cheHTML;
    }

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

    // Auto Subscribe To Threads Option Mod Begin
    $autosubchecked = '';
    if ($member['autosub'] == 'yes') {
        $autosubchecked = $cheHTML;
    }
    // Auto Subscribe To Threads Option Mod End

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

    $newsletter = formYesNo('newnewsletter');

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

    // Auto Subscribe To Threads Option Mod Begin
    $autosub = formYesNo('autosub');
    // Auto Subscribe To Threads Option Mod End

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

    $db->query("UPDATE ".X_PREFIX."members SET email='$email',

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

 WHERE username='$user'");

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

, autosub='$autosub' WHERE username='$user'");

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

=================
Edit File: memcp.php
=================

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

        $invchecked = '';
        if ($member['invisible'] == 1) {
            $invchecked = $cheHTML;
        }

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

        // Auto Subscribe To Threads Option Mod Begin
        $autosubchecked = '';
        if ($member['autosub'] == 'yes') {
            $autosubchecked = $cheHTML;
        }
        // Auto Subscribe To Threads Option Mod End

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

        $newsletter = formYesNo('newnewsletter');

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

        // Auto Subscribe To Threads Option Mod Begin
        $autosub = formYesNo('autosub');
        // Auto Subscribe To Threads Option Mod End

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

        $db->query("UPDATE ".X_PREFIX."members SET $pwtxt email='$email',

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

 WHERE username='$xmbuser'");

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

, autosub='$autosub' WHERE username='$xmbuser'");

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

=====================
Edit File: member.php
=====================

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

            $useoldu2u = formYesNo('useoldu2u');

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

            // Auto Subscribe To Threads Option Mod Begin
            $autosub = formYesNo('autosub');
            // Auto Subscribe To Threads Option Mod End

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

                $db->query("INSERT INTO ".X_PREFIX."members (username,

===================================
Find Code In-Line In Above Statement 2 Times:
===================================

) VALUES ('$username',

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

, autosub) VALUES ('$username',

========================================
Find Code At End Of Above Query Statement 2 Times:
========================================

)");

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

, '$autosub')");

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

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

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

$allowbbcode = ($forum['allowbbcode'] == 'yes') ? $lang['texton']:$lang['textoff'];

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

// Auto Subscribe To Threads Option Mod Begin
$autosubcheck = (isset($self['autosub']) && $self['autosub'] == 'yes') ? 'checked="checked"' : '';
$self['autosub'] = (isset($self['autosub']) && $self['autosub'] == 'yes') ? 'yes' : 'no';
// Auto Subscribe To Threads Option Mod End

=======================================================================================================================================
=======
Step 6:
=======

===================
Edit File: post.php
===================

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

if (isset($emailnotify) && $emailnotify == 'yes') {
    $emailnotifycheck = $cheHTML;
} else {
    $emailnotifycheck = '';
    $emailnotify = 'no';
}

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

// Auto Subscribe To Threads Option Mod Begin
if (isset($self['autosub']) && $self['autosub'] == 'yes') {
    $autosubcheck = $cheHTML;
} else {
    $autosubcheck = '';
    $self['autosub'] = 'no';
}

$autosubcheck = (isset($self['autosub']) && $self['autosub'] == 'yes') ? 'checked="checked"' : '';
$self['autosub'] = (isset($self['autosub']) && $self['autosub'] == 'yes') ? 'yes' : 'no';
// Auto Subscribe To Threads Option Mod End

=========================
Find Code 2nd & 3rd Occassions:
=========================

if (isset($emailnotify) && $emailnotify == 'yes') {

==============================
Replace Code With On Both Occassions:
==============================

if (isset($emailnotify) && $emailnotify == 'yes' || isset($self['autosub']) && $self['autosub'] == 'yes') {

=======================================================================================================================================
=======
Step 7:
=======

==============================================
Go To Admin Panel -> Translations & Download Language File:
==============================================

===============
Edit Language File:
===============

==========================
Add Code At Very Bottom Of File:
==========================

// Auto Subscribe To Threads Option Mod Begin
$lang['autosub'] = "Auto subscribe to all threads you post in?";
// Auto Subscribe To Threads Option Mod End

============================================
Go To Admin Panel -> Translations & Upload Language File:
============================================

=======================================================================================================================================
=======
Step 8:
=======

=======================================================
Go To Admin Panel -> Templates -> viewthread_quickreply
=======================================================

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

<td width="15%"> <div align="left"><input type="checkbox" name="emailnotify" value="yes" /></div></td>

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

<td width="15%"> <div align="left"><input type="checkbox" name="emailnotify" value="yes" $autosubcheck /></div></td>

=======================================================================================================================================
=======
Step 9:
=======

=======================================
Go To Admin Panel -> Templates -> post_newthread
=======================================

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

<input type="checkbox" name="bbcodeoff" value="yes" $codeoffcheck /> $lang[bbcodeoff]<br /><input
type="checkbox" name="emailnotify" value="yes" $emailnotifycheck /> $lang[textemailnotify]

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

<input type="checkbox" name="bbcodeoff" value="yes" $codeoffcheck /> $lang[bbcodeoff]<br />
<input type="checkbox" name="emailnotify" value="yes" $emailnotifycheck $autosubcheck /> $lang[textemailnotify]

=======================================================================================================================================
========
Step 10:
========

===================================
Go To Admin Panel -> Templates -> post_reply
===================================

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

<input type="checkbox" name="emailnotify" value="yes" $emailnotifycheck/>

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

<input type="checkbox" name="emailnotify" value="yes" $emailnotifycheck $autosubcheck />

=======================================================================================================================================
========
Step 11:
========

=====================================
Go To Admin Panel -> Templates -> post_newpoll
=====================================

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

<input type="checkbox" name="emailnotify" value="yes" />

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

<input type="checkbox" name="emailnotify" value="yes" $emailnotifycheck $autosubcheck />

=======================================================================================================================================
========
Step 12:
========

=======================================================
Go To Admin Panel -> Templates -> admintool_editprofile
=======================================================

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

<input type="checkbox" name="emailonu2u" value="yes" $eouchecked /> $lang[textemailonu2u]<br />

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

<input type="checkbox" name="autosub" value="yes" $autosubchecked /> $lang[autosub]<br />

=======================================================================================================================================
========
Step 13:
========

====================================
Go To Admin Panel -> Templates -> member_reg
====================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textemailonu2u]</td>
<td bgcolor="$altbg2"><input type="checkbox" name="emailonu2u" value="yes" /></td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[autosub]</td>
<td bgcolor="$altbg2"><input type="checkbox" name="autosub" value="yes" /></td>
</tr>

=======================================================================================================================================
========
Step 13:
========

======================================
Go To Admin Panel -> Templates -> memcp_profile
======================================

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textemailonu2u]</td>
<td bgcolor="$altbg2"><input type="checkbox" name="emailonu2u" value="yes" $eouchecked /></td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[autosub]</td>
<td bgcolor="$altbg2"><input type="checkbox" name="autosub" value="yes" $autosubchecked /></td>
</tr>

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