============================================================================================================================
Modification Title: Monthly Birthday Display

Version: 1.01

Author: David Boothe

Description:
This modification adds a section to the main index that displays a list of registered forum members whose birthday is in the current month.
The information will be displayed in the format 'UserName (Day of Month - Age) for each user.

Copyright: 2008 The XMB Group. All rights reserved.

Compatibility: XMB 1.9.5 SP1  This modification will not work properly with any other versions.

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 v3 License. A copy is provided with this software package.

============================================================================================================================
=======
Step 1:
=======
=======================
Edit File: lang/English.lang.php
=======================
==========
Find Code:
==========

?>

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

// Monthly Birthday Display Mod Begin
$lang['birthdays'] = "This Month's Birthdays";
$lang['textmembersbirthdays'] = " members have birthdays this month";
$lang['textmemberbirthday'] = " member has a birthday this month";
// Monthly Birthday Display Mod End

============================================================================================================================
=======
Step 2:
=======
===============================
Go To Administration Panel --> Templates
===============================
=========================
Create Template: index_birthdays
=========================
========================
Add Code and Submit Changes
========================

<br />
<table border="0" cellpadding="0" cellspacing="0" width="$tablewidth" align="center">
<tr>
<td bgcolor="$bordercolor">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr class="tablerow">
<td width="100%">
<table cellspacing="{$THEME['borderwidth']}" cellpadding="$tablespace" border="0" width="100%" align="center">
<tr>
<td  class="category">
<strong><font color="$cattext">$lang[birthdays]</font></strong>
</td>
</tr>
<tr>
<td bgcolor="$altbg2" class="mediumtxt">
$thismonthbirthdays&nbsp;
</td>
</tr>
<tr>
<td bgcolor="$altbg1" class="mediumtxt">$membirthmonth</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>

============================================================================================================================
=======
Step 3:
=======
==========================
Go To Admin Panel --> Templates
==========================
================
Edit Template: index
================
==========
Find Code:
==========

$whosonline
</table>
</td>
</tr>
</table>

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

$birthdays

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

loadtemplates(
'index',

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

loadtemplates(
'index',
'index_birthdays',

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

    if ($SETTINGS['catsonly'] == 'on') {
        $fquery = $db->query("SELECT name as cat_name, fid as cat_fid FROM $table_forums WHERE type='group' ORDER BY displayorder ASC");
    } else {
        $fquery = $db->query("SELECT f.*, c.name as cat_name, c.fid as cat_fid FROM $table_forums f LEFT JOIN $table_forums c ON (f.fup = c.fid) WHERE (c.type='group' AND f.type='forum' AND c.status='on' AND f.status='on') OR (f.type='forum' AND f.fup='' AND f.status='on') ORDER BY c.displayorder ASC, f.displayorder ASC");
    }

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

    // Monthly Birthday Display Mod Begin
    $birthdays = '';
    $query = $db->query("SELECT username, status, SUBSTRING(bday,9) as dayborn, substring(bday,1,4) as birthyear FROM $table_members where SUBSTRING(bday,6,2)=month(now()) order by dayborn, birthyear desc");
    $birthdaydaynum = $db->num_rows($query);

    $thismonthbirthdays = array();
    $curryear = intval(date('Y'));
    while($birthdaymember = $db->fetch_array($query)) {
        $age = $curryear - intval($birthdaymember['birthyear']);
        $dayborn = $birthdaymember['dayborn'];
        $last2 = $dayborn % 100;
        $last1 = $dayborn % 10;
        if ($last2 < 10 || $last2 > 13) {
            if ($last1 == 0) $dayborn = "$dayborn"."th";
            if ($last1 == 1) $dayborn = "$dayborn"."st";
            if ($last1 == 2) $dayborn = "$dayborn"."nd";
            if ($last1 == 3) $dayborn = "$dayborn"."rd";
            if ($last1 > 3)  $dayborn = "$dayborn"."th";
        } else {
            $dayborn = "$dayborn"."th";
        }
        if (substr($dayborn,0,1) == "0") {
            $dayborn = substr($dayborn,1);
        }
        $pre = '<span class="status_'.str_replace(' ', '_', $birthdaymember['status']).'">';
        $suff = '</span>';
        $thismonthbirthdays[] = '<a href="member.php?action=viewpro&amp;member='.rawurlencode($birthdaymember['username']).'">'.$pre.''.$birthdaymember['username'].' ('.$dayborn.', '.$age.')'.$suff.'</a>';
        $x++;
    }
    $thismonthbirthdays = implode(', ', $thismonthbirthdays);
    $db->free_result($query);

    if ($birthdaydaynum == 1) {
        $membirthmonth = $birthdaydaynum.$lang['textmemberbirthday'];
    } else {
        $membirthmonth = $birthdaydaynum.$lang['textmembersbirthdays'];
    }
    eval('$birthdays = "'.template('index_birthdays').'";');
    // Monthly Birthday Display Mod End

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

    $welcome = $whosonline = '';

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

    $welcome = $whosonline = $birthdays = '';

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