============================================================================================================================
Modification Name: U2U Popup Alert

Version: 1.0

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Original Code by: huskysgrl

Last Updated: April 21, 2010

Updated for 1.9.5 by: WormHole @ XMB Garage and Adam Clarke @ xmbservices.com

Description:
This modification will display a javascript alert when you have new U2U messages.
This modification gives the option to the user to have the popup appear on every page or just the index page.
This modification gives the option to the user to enable/disable the popup feature.
This modification gives the option to view the u2u or not.

Supported Version: XMB 1.9.5 SP1

Notes: This modification is released under the GPL License v3. A copy is provided with this software package.

Please backup your files before installing this modification.
Neither XMBGarage nor the author can be held responsible if your board stops functioning properly due to you installing this modification.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================
=================================
Paste In The Following Code and Hit Submit
=================================

ALTER TABLE $table_members ADD `u2ualert` INT(1) NOT NULL default '0';

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
========================
Add To End Of File Above  ?>
========================

// U2U Popup Alert Mod Begin
$lang['u2ualert1'] = "U2U Alert Feature";
$lang['u2ualert2'] = "On Every Page";
$lang['u2ualert3'] = "On Index Only";
$lang['u2ualert4'] = "No Alert";
$lang['u2ualert5'] = " unread U2U message. Would you like to view it now?";
$lang['u2ualert6'] = " unread U2U messages. Would you like to view them now?";
// U2U Popup Alert Mod End

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

        $ppp           = isset($ppp) ? (int) $ppp : $postperpage;
        
==========
Add Below:
==========

        // U2U Popup Alert Mod Begin
        $u2ualert = isset($u2ualert) ? (int) $u2ualert : 0;
        // U2U Popup Alert Mod End
        
==========
Find Code:
==========

        $db->query("INSERT INTO $table_members
        
=============================
Add In Same Line Before ) VALUES (
=============================

, u2ualert
        
===============================
Add To End Of Same Line BEFORE  )");
===============================

, '$u2ualert'

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

        eval('echo stripslashes("'.template('memcp_profile').'");');
        
===============
Add Code Above:
===============

        // U2U Popup Alert Mod Begin
        $u2uasel1 = $u2uasel2 = $u2uasel3 = '';
        switch($member['u2ualert']) {
            case 2:
                $u2uasel3 = 'selected="selected"';
                break;
            case 1:
                $u2uasel2 = 'selected="selected"';
                break;
            case 0:
            default:
                $u2uasel1 = 'selected="selected"';
                break;
        }
        // U2U Popup Alert Mod End
        
==========
Find Code:
==========

        $pppnew         = isset($pppnew) ? (int) $pppnew : $SETTINGS['postperpage'];
        
===============
Add Code Below:
===============

        // U2U Popup Alert Mod Begin
        $u2ualert = (isset($u2ualert) && is_numeric($u2ualert)) ? (int) $u2ualert : 0;
        // U2U Popup Alert Mod End
        
==========
Find Code:
==========

        $db->query("UPDATE $table_members SET $pwtxt
        
==============================================
Add To End Of Line BEFORE WHERE username='$xmbuser'");
==============================================

, u2ualert='$u2ualert'

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

// if the user is registered, check for new u2u's
    $newu2umsg = '';
    if (X_MEMBER) {
        $query = $db->query("SELECT count(readstatus) FROM $table_u2u WHERE owner='$self[username]' AND folder='Inbox' AND readstatus='no'");
        $newu2unum = $db->result($query, 0);
        if ( $newu2unum > 0) {
            $newu2umsg = "<a href=\"#\" onclick=\"Popup('u2u.php', 'Window', 700, 450);\">$lang[newu2u1] $newu2unum $lang[newu2u2]</a>";
        }
    }
        
================
Replace Code With:
================

// if the user is registered, check for new u2u's
$newu2umsg = '';
if (X_MEMBER) {
    $query = $db->query("SELECT count(readstatus) FROM $table_u2u WHERE owner='$self[username]' AND folder='Inbox' AND readstatus='no'");
    $newu2unum = $db->result($query, 0);
    if ($newu2unum > 0) {
        $newu2umsg = "<a href=\"#\" onclick=\"Popup('u2u.php', 'Window', 700, 450);\">$lang[newu2u1] $newu2unum $lang[newu2u2]</a>";
        // U2U Popup Alert Mod Begin
        $newu2umsg .= "\n";
        switch($self['u2ualert']) {
            case 2:
                if (strpos($url, 'u2u.php') === false) {
                    loadtemplates('u2u_alert');
                    eval('$newu2umsg .= "'.template('u2u_alert').'";');
                }
                break;
            case 1:
                if (strpos($url, 'index.php') !== false) {
                    loadtemplates('u2u_alert');
                    eval('$newu2umsg .= "'.template('u2u_alert').'";');
                }
                break;
            case 0:
                break;
            default:
                break;
        }
        // U2U Popup Alert Mod End
    }
}

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

<script language="JavaScript">
var u2unum = $newu2unum;
function u2uAlert() {
    u2uAlertMsg = "$lang[newu2u1] "+u2unum;
    msgWord     = (u2unum > 1) ? "$lang[u2ualert5]" : "$lang[u2ualert6]";
    msgWord     = (u2unum < 2) ? "$lang[u2ualert5]" : "$lang[u2ualert6]";

    u2uAlertMsg = u2uAlertMsg + msgWord;
    
    if (confirm(u2uAlertMsg)) {
        Popup('u2u.php', 'Window', 700, 450);
    }
}
setTimeout('u2uAlert();', 10);
</script>

=====================================================================================================
IF YOU HAVE THE U2U FULL PAGE HACK INSTALLED, DO THE FOLLOWING STEP, OTHERWISE PLEASE SKIP ON TO STEP 7
=====================================================================================================
===============================
Go To Administration Panel --> Templates
===============================
===================
Edit Template: u2u_alert
===================
==========
Find Code:
==========

        Popup('u2u.php', 'Window', 700, 450);
        
================
Replace CodeWith:
================

        window.location = 'u2u.php';
        
============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
=====================
Edit Template: member_reg
=====================
==========
Find Code:
==========

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

==============
Add CodeBelow:
==============

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[u2ualert1]</td>
<td bgcolor="$altbg2"><select name="u2ualert">
<option value="2">$lang[u2ualert2]</option>
<option value="1">$lang[u2ualert3]</option>
<option value="0">$lang[u2ualert4]</option>
</select>
</td>
</tr>

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
=======================
Edit Template: memcp_profile
=======================
==========
Find Code:
==========

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

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

<tr>
<td bgcolor="$altbg1" class="tablerow" width="22%">$lang[u2ualert1]</td>
<td bgcolor="$altbg2" class="tablerow"><select name="u2ualert">
<option value="2" $u2uasel3>$lang[u2ualert2]</option>
<option value="1" $u2uasel2>$lang[u2ualert3]</option>
<option value="0" $u2uasel1>$lang[u2ualert4]</option>
</select>
</td>
</tr>

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