PDA

View Full Version : Mini Mods - Calendar Active Members Time Cut-Off hack


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

Fynnon
07-08-2009, 07:31 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

What, i don`t really understand what you`re saying in that phrase, lol !?
This mod will show me in memberlist who is celebrating his birthday ?

Its interesting, good mod, too bad it has to have template edits cause everytime you update vB and the template with it you need to do this edit again and if you have like 20 mods like this...

I always wanted to to have a better memberlist to see more about users, like their COUNTRY and other stuff ! 10x

PlickBadger
07-08-2009, 09:58 PM
The Forum Home Page options (Active Members Time Cut-Off and the Show birthdays for active users only) in the AdminCP limit the birthdays shown on the home page to users that have been active within certain amount of days.

This hack makes the Calendar do the same thing.

ntduyphuong
07-09-2009, 02:38 AM
Use the option in vBulletin Options is much safer

PlickBadger
07-09-2009, 12:16 PM
That's the whole point. The option in Vbulletin doesn't work for the calendar, only the home page