PlickBadger
07-07-2009, 10:00 PM
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
function cache_birthdays($weekly = 0)
{
global $doublemonth, $vbulletin, $calendarinfo, $doublemonth1, $doublemonth2;
$birthday = array();
add the following directly below it
// calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
if ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 1))
{
$datecut = TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
$activitycut = "AND lastactivity >= $datecut";
}
else
{
$activitycut = '';
}
Then add
$activitycut
to the end of the following 2 SQL statements
before:
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:
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
// 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
// calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
if ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 1))
{
$datecut = TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
$activitycut = "AND lastactivity >= $datecut";
}
else
{
$activitycut = '';
}
Then add
$activitycut
To the following SQL statement
before:
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:
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
modify your /forum/includes/functions_calendar.php as follows:
find
function cache_birthdays($weekly = 0)
{
global $doublemonth, $vbulletin, $calendarinfo, $doublemonth1, $doublemonth2;
$birthday = array();
add the following directly below it
// calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
if ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 1))
{
$datecut = TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
$activitycut = "AND lastactivity >= $datecut";
}
else
{
$activitycut = '';
}
Then add
$activitycut
to the end of the following 2 SQL statements
before:
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:
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
// 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
// calendar hack to limit birthdays to active users pulled directly from functions_databuild.php
if ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 1))
{
$datecut = TIMENOW - (intval($vbulletin->options['activememberdays']) * 86400);
$activitycut = "AND lastactivity >= $datecut";
}
else
{
$activitycut = '';
}
Then add
$activitycut
To the following SQL statement
before:
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:
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