Back to vBulletin 3.8 Add-ons

Calendar Active Members Time Cut-Off hack
Mod Version: 1.00, by PlickBadger

vB Version: 3.8.2 Rating: (0 vote - 0 average) Installs: 6
Released: 08 Jul 2009 Last Update: Never Downloads: 1
Not Supported Code Changes  

If you want your calendar to adhere to the Active Members Time Cut-Off and the Show birthdays for active users only Active Members option. Modify the following files

modify your /forum/includes/functions_calendar.php as follows:
find

PHP Code:
function cache_birthdays($weekly 0)
{
    global 
$doublemonth$vbulletin$calendarinfo$doublemonth1$doublemonth2;

    
$birthday = array(); 
add the following directly below it
PHP Code:
    // calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
    
if ($vbulletin->options['activememberdays'] > AND ($vbulletin->options['activememberoptions'] & 1))
    {
        
$datecut TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
        
$activitycut "AND lastactivity >= $datecut";
    }
    else
    {
        
$activitycut '';
    } 
Then add
PHP Code:
$activitycut 
to the end of the following 2 SQL statements

before:
PHP Code:
        if (!$weekly)
        { 
// cache birthdays for a single month
            
$birthdays $vbulletin->db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE birthday LIKE '
$doublemonth-%' AND
                    usergroupid IN (
$ids) AND
                    showbirthday IN (2, 3)
            "
);
        }
        else
        { 
// cache for two months!
            
$birthdays $vbulletin->db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE (birthday LIKE '
$doublemonth1-%' OR
                    birthday LIKE '
$doublemonth2-%') AND
                    usergroupid IN (
$ids) AND
                    showbirthday IN (2,3)
            "
);
        } 
after:
PHP Code:
        if (!$weekly)
        { 
// cache birthdays for a single month
            
$birthdays $vbulletin->db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE birthday LIKE '
$doublemonth-%' AND
                    usergroupid IN (
$ids) AND
                    showbirthday IN (2, 3)
                    
$activitycut
            "
);
        }
        else
        { 
// cache for two months!
            
$birthdays $vbulletin->db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE (birthday LIKE '
$doublemonth1-%' OR
                    birthday LIKE '
$doublemonth2-%') AND
                    usergroupid IN (
$ids) AND
                    showbirthday IN (2,3)
                    
$activitycut
            "
);
        } 
Then modify your /forum/calendar.php as follows:
find
PHP Code:
        // set date range for events to cache.
        
$eventrange = array('frommonth' => $month'fromyear' => $year'nextmonth' => $month'nextyear' => $year);

        
// cache events for this month only.
        
$eventcache cache_events($eventrange); 
add the following directly below it
PHP Code:
        // calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
        
if ($vbulletin->options['activememberdays'] > AND ($vbulletin->options['activememberoptions'] & 1))
        {
            
$datecut TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
            
$activitycut "AND lastactivity >= $datecut";
        }
        else
        {
            
$activitycut '';
        } 
Then add
PHP Code:
$activitycut 
To the following SQL statement
before:
PHP Code:
        if ($calendarinfo['showbirthdays'])
        {  
// Load the birthdays for today

            
foreach($vbulletin->usergroupcache AS $usergroupid => $usergroup)
            {
                if (
$usergroup['genericoptions'] & $vbulletin->bf_ugp_genericoptions['showbirthday'])
                {
                    
$ids .= ",$usergroupid";
                }
            }

            
$comma '';
            
$birthday $db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE birthday LIKE '
$doublemonth-$doubleday-%' AND
                    usergroupid IN (0
$ids) AND
                    showbirthday IN (2,3)
            "
); 
after:
PHP Code:
        if ($calendarinfo['showbirthdays'])
        {  
// Load the birthdays for today

            
foreach($vbulletin->usergroupcache AS $usergroupid => $usergroup)
            {
                if (
$usergroup['genericoptions'] & $vbulletin->bf_ugp_genericoptions['showbirthday'])
                {
                    
$ids .= ",$usergroupid";
                }
            }

            
$comma '';
            
$birthday $db->query_read_slave("
                SELECT birthday, username, userid, showbirthday
                FROM " 
TABLE_PREFIX "user
                WHERE birthday LIKE '
$doublemonth-$doubleday-%' AND
                    usergroupid IN (0
$ids) AND
                    showbirthday IN (2,3)
                    
$activitycut
            "
); 
I did not write this code, I swiped it from functions_databuild.php, but I thought it might be useful to someone

Download

No files for download.

Similar Mods

0 Posters, None Active Members, Active Members and 1 Posters Display Hack. vBulletin 2.x Full Releases

vblts.ru supports vBulletin®, 2022-2025