Title: Post Sorting Option v1.0

Author: John Briggs

Description:
This modification will provide an option in member control panel for members to choose to view threads in ASC or DESC order.

Copyright:  2006 John Briggs. All rights reserved.

Compatability: XMB 1.9.5

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.

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: editprofile.php
==================

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

    $eouchecked = '';
    if ($member['emailonu2u'] == 'yes') {
        $eouchecked = $cheHTML;
    }

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

    $selectasc = $selectdesc = '';
    if ($member['psorting'] == 'ASC') {
        $selectasc = $selHTML;
    } elseif ($member['psorting'] == 'DESC') {
        $selectdesc = $selHTML;
    }

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

    $useoldu2u      = (isset($useoldu2u) && $useoldu2u == 'yes') ? 'yes' : 'no';

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

    $psorting = (isset($_POST['psorting']) && $_POST['psorting'] == 'ASC') ? 'ASC' : 'DESC';

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

    $db->query("UPDATE $table_members SET email='$email',

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

 WHERE username='$user'");

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

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

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

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

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

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

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

        $selectasc = $selectdesc = '';
        if ($member['psorting'] == 'ASC') {
            $selectasc = $selHTML;
        } elseif ($member['psorting'] == 'DESC') {
            $selectdesc = $selHTML;
        }

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

        $useoldu2u      = (isset($useoldu2u) && $useoldu2u == 'yes') ? 'yes' : 'no';

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

        $psorting = (isset($_POST['psorting']) && $_POST['psorting'] == 'ASC') ? 'ASC' : 'DESC';

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

        $db->query("UPDATE $table_members SET $pwtxt email='$email',

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

 WHERE username='$xmbuser'");

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

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

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

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

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

        $useoldu2u     = (isset($useoldu2u) && $useoldu2u == 'yes') ? 'yes' : 'no';

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

        $psorting = (isset($_POST['psorting']) && $_POST['psorting'] == 'ASC') ? 'ASC' : 'DESC';

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

        $db->query("INSERT INTO $table_members (uid,

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

) VALUES ('', '$username',

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

, psorting) VALUES ('', '$username',

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

)");

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

, '$psorting')");

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

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

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

    $smileoffcheck = (isset($smileyoff) && $smileyoff == 'yes') ? 'checked="checked"' : '';

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

    if (X_MEMBER) {
        $self['psorting'] = (isset($self['psorting']) && $self['psorting'] == 'ASC') ? 'ASC' : 'DESC';
    } else {
        $self['psorting'] = (isset($self['psorting']) && $self['psorting'] == 'DESC') ? 'DESC' : 'ASC';
    }

======================
Find Code On 1st Occassion:
======================

$querypost = $db->query("

==================================
Find Code In-Line In Above Query Statement:
==================================

ASC

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

$self[psorting]

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

    $page = quickpage($posts, $ppp);

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

    if (isset($self['psorting']) && $self['psorting'] == 'DESC') {
        $page = '1';
    } else {
        $page = quickpage($posts, $ppp);
    }

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

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

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

            if ($posts > $ppp) {
                $topicpages = quickpage($posts, $ppp);
            } else {
                $topicpages = 1;
            }

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

            if (isset($self['psorting']) && $self['psorting'] == 'ASC' && ($posts > $ppp)) {
                $topicpages = quickpage($posts, $ppp);
            } else {
                $topicpages = 1;
            }

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

        if ( $threaddelete != 'yes') {
            $query =$db->query("SELECT COUNT(pid) FROM $table_posts WHERE pid<=$pid AND tid='$tid' AND fid='$fid'");
            $posts = $db->result($query,0);
            $topicpages = quickpage($posts, $ppp);

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

        if ( $threaddelete != 'yes') {
            $query =$db->query("SELECT COUNT(pid) FROM $table_posts WHERE pid<=$pid AND tid='$tid' AND fid='$fid'");
            $posts = $db->result($query,0);

            if (isset($self['psorting']) && $self['psorting'] == 'ASC') {
                $topicpages = quickpage($posts, $ppp);
            } else {
                $topicpages = '1';
            }

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

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

=================================
Add Code At Very Bottom Of File Above ?>:
=================================

// Post Sorting Option Mod Begin
$lang['psorting'] = "Post Sorting:";
$lang['psortingasc'] = "Ascending (Newest posts below)";
$lang['psortingdesc'] = "Descending (Newest posts above)";
// Post Sorting Option Mod End

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

========================================
Go to admin panel -> templates -> admintool_editprofile
========================================

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

<tr>
<td bgcolor="$altbg1" class="tablerow" width="22%">$lang[texttheme]</td>
<td bgcolor="$altbg2" class="tablerow">$themelist</td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[psorting]</td>
<td bgcolor="$altbg2">
<select name="psorting">
<option value="ASC" $selectasc>$lang[psortingasc]</option>
<option value="DESC" $selectdesc>$lang[psortingdesc]</option>
</select>
</td>
</tr>

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

===================================
Go to admin panel -> templates -> member_reg
===================================

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

<tr>
<td bgcolor="$altbg1" class="tablerow" width="22%">$lang[texttheme]</td>
<td bgcolor="$altbg2" class="tablerow">$themelist</td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[psorting]</td>
<td bgcolor="$altbg2">
<select name="psorting">
<option value="ASC">$lang[psortingasc]</option>
<option value="DESC">$lang[psortingdesc]</option>
</select>
</td>
</tr>

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

====================================
Go to admin panel -> templates -> memcp_profile
====================================

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

<tr>
<td bgcolor="$altbg1" class="tablerow" width="22%">$lang[texttheme]</td>
<td bgcolor="$altbg2" class="tablerow">$themelist </td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[psorting]</td>
<td bgcolor="$altbg2">
<select name="psorting">
<option value="ASC" $selectasc>$lang[psortingasc]</option>
<option value="DESC" $selectdesc>$lang[psortingdesc]</option>
</select>
</td>
</tr>

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