=======================================================================================================================================
Title: U2U Status

Version: 1.0

Author: John Briggs

Description: This modification will provide a new tool in the admin panel to turn the U2U messenger on and off.
                   This modification will prevent members only when set to off and still allow staff to access it.

Copyright:  2011 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 v3. 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
===================================
===================================
Paste The Following Code and Submit Changes:
===================================

ALTER TABLE `$table_settings` ADD `u2ustatus` set('on','off') NOT NULL default 'on';

=======================================================================================================================================
=======
Step 2:
=======
=============
Edit File: cp.php
=============
==========
Find Code:
==========

        $avchecked[0] = $avchecked[1] = $avchecked[2] = false;

        if (!empty($avatarlist)) {
            $avchecked[1] = true;
        } elseif (!empty($avataroff)) {
            $avchecked[2] = true;
        } else {
            $avchecked[0] = true;
        }

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

        // U2U Status Mod Begin
        $u2ustatuson = $u2ustatusoff = '';
        switch ($SETTINGS['u2ustatus']) {
            case 'on':
                $u2ustatuson = $selHTML;
                break;
            default:
                $u2ustatusoff = $selHTML;
                break;
        }
        // U2U Status Mod End

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

        printsetting1($lang['textmemliststatus'], 'memliststatusnew', $memliston, $memlistoff);

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

        // U2U Status Mod Begin
        printsetting1($lang['u2ustatus'], 'u2ustatusnew', $u2ustatuson, $u2ustatusoff);
        // U2U Status Mod End

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

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

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

        // U2U Status Mod Begin
        $u2ustatusnew = ($u2ustatusnew == 'on') ? 'on' : 'off';
        // U2U Status Mod End

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

        $db->query("UPDATE $table_settings SET langfile='$langfilenew'

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

");

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

, u2ustatus='$u2ustatusnew'");

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

        $u2ulink = "<a href=\"#\" onclick=\"Popup('u2u.php', 'Window', 700, 450);\">$lang[banu2u]</a> - ";

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

        $u2ulink = '';
        if (!($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
            $u2ulink = "<a href=\"#\" onclick=\"Popup('u2u.php', 'Window', 700, 450);\">$lang[banu2u]</a> - ";
        }

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

// if the user is registered, check for new u2u's
$newu2umsg = '';
if (X_MEMBER) {

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

// if the user is registered, check for new u2u's
$newu2umsg = '';
if (X_MEMBER && !($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {

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

loadtemplates(

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

loadtemplates(
'index_welcome_member_u2u',

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

        eval("\$welcome = \"".template("index_welcome_member")."\";");

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

        // U2U Status Mod Begin
        $u2ulink = '';
        if (X_MEMBER && !($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
            eval('$u2ulink = "'.template('index_welcome_member_u2u').'";');
        }
        // U2U Status Mod End

=======================================================================================================================================
=======
Step 5:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

loadtemplates(

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

loadtemplates(
'member_profile_u2u',

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

            if ($memberinfo['showemail'] == "yes") {
                eval("\$emailblock = \"".template("member_profile_email")."\";");
            } else {
                $emailblock = '';
            }

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

            // U2U Status Mod Begin
            $u2ublock = '';
            if (X_MEMBER && !($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
                eval('$u2ublock = "'.template('member_profile_u2u').'";');
            }
            // U2U Status Mod End

=======================================================================================================================================
=======
Step 6:
=======
=================
Edit File: memcp.php
=================
==========
Find Code:
==========

loadtemplates(

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

loadtemplates(
'memcp_home_u2u',

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

    $query = $db->query("SELECT * FROM $table_u2u WHERE owner='$xmbuser' AND type='incoming' ORDER BY dateline DESC LIMIT 0, 15");
    $u2unum = $db->num_rows($query);
    $messages = '';

    $tmOffset = ($timeoffset * 3600) + ($addtime * 3600);

    while ($message = $db->fetch_array($query)) {
        $postdate = gmdate("$dateformat",$message['dateline'] + $tmOffset);
        $posttime = gmdate("$timecode",$message['dateline'] + $tmOffset);
        $senton = "" .$postdate. " " .$lang['textat']. " " .$posttime. "";

        if ($message['subject'] == '') {
            $message['subject'] = "&laquo;" .$lang['textnosub']. "&raquo;";
        }

        if ($message['readstatus'] == "yes") {
            $read = $lang['textread'];
        } else {
            $read = $lang['textunread'];
        }

        $message['subject'] = stripslashes(censor($message['subject']));
        eval("\$messages .= \"".template("memcp_home_u2u_row")."\";");
    }

    if ($u2unum == 0) {
        eval("\$messages = \"".template("memcp_home_u2u_none")."\";");
    }

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

    // U2U Status Mod Begin
    $u2ublock = '';
    if (!($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
        $query = $db->query("SELECT * FROM $table_u2u WHERE owner = '$xmbuser' AND type = 'incoming' ORDER BY dateline DESC LIMIT 0, 15");
        $u2unum = $db->num_rows($query);
        $messages = '';
        $tmOffset = ($timeoffset * 3600) + ($SETTINGS['addtime'] * 3600);
        while ($message = $db->fetch_array($query)) {
            $postdate = gmdate($dateformat, $message['dateline'] + $tmOffset);
            $posttime = gmdate($timecode, $message['dateline'] + $tmOffset);
            $senton = $lang['lastreply1'].' '.$postdate.' '.$lang['textat'].' '.$posttime;

            if ($message['subject'] == '') {
                $message['subject'] = $lang['textnosub'];
            }

            if ($message['readstatus'] == 'yes') {
                $read = $lang['textread'];
            } else {
                $read = $lang['textunread'];
            }

            $message['subject'] = stripslashes(censor($message['subject']));
            eval('$messages .= "'.template('memcp_home_u2u_row').'";');
        }

        if ($u2unum == 0) {
            eval('$messages = "'.template('memcp_home_u2u_none').'";');
        }
        eval('$u2ublock = "'.template('memcp_home_u2u').'";');
    }
    // U2U Status Mod End

=======================================================================================================================================
=======
Step 7:
=======
==============
Edit File: u2u.php
==============
==========
Find Code:
==========

if (X_GUEST) {
    error($lang['u2unotloggedin'], false, $u2uheader, $u2ufooter, false, true, false, false);
    exit;
}

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

// U2U Status Mod Begin
if ($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member') {
    error($lang['u2ustatusdisabled'], false, $u2uheader, $u2ufooter, false, true, false, false);
}
// U2U Status Mod End

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

            eval("\$u2u = \"".template('viewthread_post_u2u')."\";");

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

            // U2U Status Mod Begin
            $u2u = '';
            if (X_MEMBER && !($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
                eval('$u2u = "'.template('viewthread_post_u2u').'";');
            }
            // U2U Status Mod End

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

// U2U Status Mod Begin
$lang['u2ustatus'] = "U2U Status:<br /><span class=\"smalltxt\">( Disabled for members only. )</span>";
$lang['u2ustatusdisabled'] = "Sorry, the board administrator has disabled the U2U messenger.";
// U2U StatusMod End

=======================================================================================================================================
========
Step 10:
========
===============================
Go To Administration Panel --> Templates
===============================
=======================
Edit Template: member_profile
=======================
==========
Find Code:
==========

(<a href="#" onclick="Popup('u2u.php?action=send&amp;username=$encodeuser', 'Window', 700, 450);">$lang[textu2u]</a>)&nbsp;

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

$u2ublock

=======================================================================================================================================
========
Step 11:
========
===============================
Go To Administration Panel --> Templates
===============================
=============================
Edit Template: index_welcome_member
=============================
==========
Find Code:
==========

<td align="center" width="33%"><a href="#" onclick="Popup('u2u.php','Window', 700, 450);"><strong>$lang[textu2umessenger]</strong></a></td>

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

$u2ulink

=======================================================================================================================================
========
Step 12:
========
===============================
Go To Administration Panel --> Templates
===============================
======================
Edit Template: memcp_home
======================
==========
Find Code:
==========

<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr>
<td bgcolor="$bordercolor"><table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr class="category">
<td colspan="4"><font color="$cattext"><strong>$lang[textlatestu2us]</strong></font></td>
</tr>
<tr>
<td class="header">$lang[textsubject]</td>
<td class="header">$lang[textfrom]</td>
<td class="header">$lang[textsent]</td>
<td class="header">$lang[mcpread]</td>
</tr>
$messages
<tr>
<td colspan="4" class="header" valign="top"><a href="#" onclick ="Popup('u2u.php','Window', 700, 450);">[$lang[viewcompleteinbox]]</a></td>
</tr>
</table></td>
</tr>
</table>

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

$u2ublock

=======================================================================================================================================
========
Step 13:
========
===============================
Go To Administration Panel --> Templates
===============================
Create New Template: memcp_home_u2u
===============================
========================
Add Code and Submit Changes:
========================

<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr class="category">
<td colspan="4"><font color="$cattext"><strong>$lang[textlatestu2us]</strong></font></td>
</tr>
<tr class="header">
<td>$lang[textsubject]</td>
<td>$lang[textfrom]</td>
<td>$lang[textsent]</td>
<td>$lang[mcpread]</td>
</tr>
$messages
<tr class="header">
<td colspan="4" valign="top">[<a href="#" onclick ="Popup('u2u.php','Window', 700, 450);">$lang[viewcompleteinbox]</a>]</td>
</tr>
</table>
</td>
</tr>
</table>

=======================================================================================================================================
========
Step 14:
========
===============================
Go To Administration Panel --> Templates
================================
Create New Template: member_profile_u2u
================================
========================
Add Code and Submit Changes:
========================

(<a href="#" onclick="Popup('u2u.php?action=send&amp;username=$encodeuser', 'Window', 700, 450);">$lang[textu2u]</a>)&nbsp;

=======================================================================================================================================
========
Step 15:
========
===============================
Go To Administration Panel --> Templates
======================================
Create New Template: index_welcome_member_u2u
======================================
========================
Add Code and Submit Changes:
========================

<td align="center" width="33%"><a href="#" onclick="Popup('u2u.php','Window', 700, 450);"><strong>$lang[textu2umessenger]</strong></a></td>

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