Title: U2U Status v1.0

Author: John Briggs

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

Copyright:  2009 John Briggs. All rights reserved.

Compatability: XMB 1.9.8 SP3

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 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 Admin Panel --> Insert Raw SQL
==============================
======================
Add Code and Click Submit
======================

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;
        } else if (!empty($avataroff)) {
            $avchecked[2] = true;
        } else {
            $avchecked[0] = true;
        }

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

        // U2U Status Mod Begin
        $u2ustatuson = $u2ustatusoff = '';
        settingHTML('u2ustatus', $u2ustatuson, $u2ustatusoff);
        // U2U Status Mod End

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

        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);

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

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

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

        $smileyinsertnew = formOnOff('smileyinsertnew');

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

        // U2U Status Mod Begin
        $u2ustatusnew = formOnOff('u2ustatusnew');
        // U2U Status Mod End

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

        $db->query("UPDATE ".X_PREFIX."settings SET

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

        $db->query("UPDATE ".X_PREFIX."settings SET
            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:
================

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

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

$newu2umsg = '';
if (X_MEMBER) {

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

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

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

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

    $u2uquery = $db->query("SELECT * FROM ".X_PREFIX."u2u WHERE owner='$xmbuser' AND folder='Inbox' ORDER BY dateline DESC LIMIT 0, 5");
    $u2unum = $db->num_rows($u2uquery);
    $messages = '';
    $tmOffset = ($timeoffset * 3600) + ($addtime * 3600);
    while($message = $db->fetch_array($u2uquery)) {
        $postdate = gmdate($dateformat, $message['dateline'] + $tmOffset);
        $posttime = gmdate($timecode, $message['dateline'] + $tmOffset);
        $senton = $postdate.' '.$lang['textat'].' '.$posttime;

        $message['subject'] = html_entity_decode($message['subject']);
        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').'";');
    }
    $db->free_result($u2uquery);

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

    // U2U Status Mod Begin
    $u2ublock = '';
    if (!($SETTINGS['u2ustatus'] == 'off' && isset($self['status']) && $self['status'] == 'Member')) {
        $u2uquery = $db->query("SELECT * FROM $table_u2u WHERE owner = '$xmbuser' AND type = 'incoming' ORDER BY dateline DESC LIMIT 0, 15");
        $u2unum = $db->num_rows($u2uquery);
        $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;

            $message['subject'] = html_entity_decode($message['subject']);
            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').'";');
        }
        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 Admin 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>)

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

$u2ublock

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

<td 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 Admin 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="{$THEME['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>
<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 Admin Panel --> Templates
==========================
===============================
Create New Template: memcp_home_u2u
===============================
======================
Add Code and Click Submit:
======================

<table cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
<tr>
<td bgcolor="$THEME[bordercolor]">
<table border="0" cellspacing="$THEME[borderwidth]" cellpadding="$THEME[tablespace]" width="100%">
<tr class="category">
<td colspan="4"><font color="$THEME[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 Admin Panel --> Templates
==========================
================================
Create New Template: member_profile_u2u
================================
======================
Add Code and Click Submit:
======================

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

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

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

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