Modification Name: U2U Birthday Message v1.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.8 SP3

Updated for 1.9.8 by: WormHole @ XMB Garage

Notes: This modification is released under the GPL. 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 hit submit
=============================

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

        $sightmlon = $sightmloff = '';
        settingHTML('sightml', $sightmlon, $sightmloff);
        
==========
Add Below:
==========

        // U2U Birthday Message Mod Begin
        $birthdayu2uon = $birthdayu2uoff = '';
        settingHTML('birthdayu2u', $birthdayu2uon, $birthdayu2uoff);
        // U2U Birthday Message Mod End

======
Find:
======

        printsetting4($lang['tickercontents'], 'tickercontentsnew', stripslashes($SETTINGS['tickercontents']), 5, 50);
        ?>
        
============
Replace With:
============

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

======
Find:
======

        $onlinetoday_statusnew = formOnOff('onlinetoday_statusnew');

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


        // U2U Birthday Message Mod Begin
        $birthdayu2unew = formOnOff('birthdayu2unew');
        // U2U Birthday Message Mod End

======
Find:
======

        $db->query("UPDATE ".X_PREFIX."settings SET
        
================
Replace Code With:
================

        $db->query("UPDATE ".X_PREFIX."settings SET
            birthdayu2u='$birthdayu2unew',
            bdayu2umsg='$bdayu2umsgnew',

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

error_reporting(E_ALL&~E_NOTICE);

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

// Suppress server time zone error when debug is on
date_default_timezone_set("America/New_York");

======
Find:
======

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

// Birthday U2U Mod Begin
// Check for new birthdays...
if ($SETTINGS['birthdayu2u'] == 'on') {
    $todaybday = '-'.date('m-d');
    $bdayquery = $db->query("SELECT username FROM ".X_PREFIX."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 ".X_PREFIX."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 ".X_PREFIX."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('birthdayu2u', $self['username'], $bdaytime);
            }
        }
        $db->free_result($u2uquery);
    }
    $db->free_result($bdayquery);
}
// Birthday U2U Mod End

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