============================================================================================================================
Modification Name: U2U Birthday Message

Version: 1.0

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Description: This modification will automatically send a happy birthday u2u to users on their birthday.

Supported Version: XMB 1.9.5 SP1

Notes: This modification is released under the GPL 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 The Following Code and Submit Changes:
===================================

ALTER TABLE $table_settings ADD `birthdayu2u` VARCHAR(3) NOT NULL default 'on';
ALTER TABLE $table_settings ADD `bdayu2umsg` TEXT NOT NULL;
UPDATE $table_settings SET bdayu2umsg='Hello *USER*,

The staff at *BBNAME* wishes you a happy birthday. We hope you have a fun filled and happy birthday.

Best wishes,

*BBNAME* Staff';

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

// U2U Birthday Message Mod Begin
$lang['bdayu2u_subject'] = "Happy Birthday!";
$lang['bdayu2u_status'] = "Birthday U2U Status:";
$lang['bdayu2u_message'] = "Birthday U2U Message:<br /><small><em>(Use *BBNAME* and *USER* to substitute your board's name and the user's username)</em></small>";
// U2U Birthday Message Mod End

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

        $sightmlon = $sightmloff = '';
        if ($SETTINGS['sightml'] == "on") {
            $sightmlon = $selHTML;
        } else {
            $sightmloff = $selHTML;
        }
        
===============
Add Code Below:
===============

        // U2U Birthday Message Mod Begin
        $birthdayu2uon = $birthdayu2uoff = '';
        switch ($SETTINGS['birthdayu2u']) {
            case on:
                $birthdayu2uon = $selHTML;
                break;
            default:
                $birthdayu2uoff = $selHTML;
                break;
        }
        // U2U Birthday Message Mod End
        
==========
Find Code:
==========

        $SETTINGS['tickercontents'] = stripslashes($SETTINGS['tickercontents']);
        
===============
Add Code Below:
===============

        // U2U Birthday Message Mod Begin
        $SETTINGS['bdayu2umsg'] = stripslashes($SETTINGS['bdayu2umsg']);
        // U2U Birthday Message Mod End

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

        printsetting4($lang['tickercontents'], 'tickercontentsnew', $SETTINGS['tickercontents'], 5, 50);
        
===============
Add Code Below:
===============

        // U2U Birthday Message Mod Begin
        printsetting1($lang['bdayu2u_status'], 'birthdayu2unew', $birthdayu2uon, $birthdayu2uoff);
        ?>
        <tr>
        <td class="tablerow" bgcolor="<?php echo $altbg1?>"><?php echo $lang['bdayu2u_message']?></td>
        <td class="tablerow" bgcolor="<?php echo $altbg2?>"><textarea rows="5" name="bdayu2umsgnew" cols="50"><?php echo $SETTINGS['bdayu2umsg']?></textarea></td>
        </tr>
        <?php
        // U2U Birthday Message Mod End

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

        $tickercontentsnew = addslashes($tickercontentsnew);
        
===============
Add Code Below:
===============

        // U2U Birthday Message Mod Begin
        $bdayu2umsgnew = addslashes($bdayu2umsgnew);

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

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

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

        // U2U Birthday Message Mod Begin
        $birthdayu2unew = ($birthdayu2unew == 'on') ? 'on' : 'off';
        // U2U Birthday Message Mod End
        
==========
Find Code:
==========

        $db->query("UPDATE $table_settings SET
        
==========================
Add To End Of Line BEFORE  ");
==========================

, birthdayu2u='$birthdayu2unew', bdayu2umsg='$bdayu2umsgnew'

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

// if the user is registered, check for new u2u's
        
===============
Add Code Above:
===============

// U2U Birthday Message Mod Begin
// Check for new birthdays...
if ($SETTINGS['birthdayu2u'] == 'on') {
    $todaybday = '-'.date('m-d');
    $bdayquery = $db->query("SELECT username FROM $table_members WHERE bday LIKE '%$todaybday'");
    while($bdaymem = $db->fetch_array($bdayquery)) {
        $bdaymessage = str_replace(array('*USER*', '*BBNAME*'), array($bdaymem['username'], $bbname), $SETTINGS['bdayu2umsg']);
        $u2uquery = $db->query("SELECT u2uid FROM $table_u2u WHERE owner='$bdaymem[username]' AND folder='Inbox' AND subject='$lang[bdayu2u_subject]'");
        if ($db->num_rows($u2uquery) == 0) {
            if (!isset($_COOKIE['birthdayu2u']) || $_COOKIE['birthdayu2u'] != $bdaymem['username']) {
                $db->query("INSERT INTO $table_u2u ( u2uid, msgto, msgfrom, type, owner, folder, subject, message, dateline, readstatus, sentstatus ) VALUES ('', '".addslashes($bdaymem['username'])."', '".$bbname." Staff', 'incoming', '".addslashes($bdaymem['username'])."', 'Inbox', '$lang[bdayu2u_subject]', '$bdaymessage', '" . time() . "', 'no', 'yes')");
                $bdaytime = (time() + 24 * 3600);
                put_cookie('bdayu2u', $self['username'], $bdaytime);
            }
        }
        $db->free_result($u2uquery);
    }
    $db->free_result($bdayquery);
}
// U2U Birthday Message Mod End

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