Report #37: Birthdays Ahead
This commit is contained in:
@@ -85,6 +85,7 @@ class acp_portal
|
||||
'portal_link_us' => array('lang' => 'PORTAL_LINK_US' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
'portal_links' => array('lang' => 'PORTAL_LINKS' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
'portal_birthdays' => array('lang' => 'PORTAL_BIRTHDAYS' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
'portal_birthdays_ahead' => array('lang' => 'PORTAL_BIRTHDAYS_AHEAD' , 'validate' => 'int' , 'type' => 'text:3:3' , 'explain' => true),
|
||||
'portal_random_member' => array('lang' => 'PORTAL_RANDOM_MEMBER' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
'portal_whois_online' => array('lang' => 'PORTAL_WHOIS_ONLINE' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
//'portal_change_style' => array('lang' => 'PORTAL_CHANGE_STYLE' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true),
|
||||
|
||||
@@ -56,6 +56,10 @@ $lang = array_merge($lang, array(
|
||||
'WIO_GUEST' => 'Guest',
|
||||
//'RECORD_ONLINE_USERS'=> 'View record: <strong>%1$s</strong><br />%2$s',
|
||||
|
||||
// Birthday
|
||||
'BIRTHDAYS_AHEAD' => 'In the next %s days',
|
||||
'NO_BIRTHDAYS_AHEAD' => 'In this period, no members have a birthday.',
|
||||
|
||||
// user menu
|
||||
'USER_MENU' => 'User menu',
|
||||
'UM_LOG_ME_IN' => 'remember me',
|
||||
|
||||
@@ -52,8 +52,10 @@ $lang = array_merge($lang, array(
|
||||
'PORTAL_LINK_US_EXPLAIN' => 'Display this block on portal.',
|
||||
'PORTAL_LINKS' => 'Links block',
|
||||
'PORTAL_LINKS_EXPLAIN' => 'Display this block on portal.',
|
||||
'PORTAL_BIRTHDAYS' => 'Birthday block',
|
||||
'PORTAL_BIRTHDAYS_EXPLAIN' => 'Display this block on portal.',
|
||||
'PORTAL_BIRTHDAYS' => 'Birthday block',
|
||||
'PORTAL_BIRTHDAYS_EXPLAIN' => 'Display this block on portal.',
|
||||
'PORTAL_BIRTHDAYS_AHEAD' => 'Birthdays ahead days',
|
||||
'PORTAL_BIRTHDAYS_AHEAD_EXPLAIN' => 'How many days to look ahead for birthdays.',
|
||||
'PORTAL_SEARCH' => 'Search block',
|
||||
'PORTAL_SEARCH_EXPLAIN' => 'Display this block on portal.',
|
||||
'PORTAL_WELCOME' => 'Welcome center block',
|
||||
|
||||
@@ -9,44 +9,72 @@
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// Generate birthday list if required ... / borrowed from index.php (RC4)
|
||||
// Generate birthday list if required ... / borrowed from index.php (RC4)
|
||||
$birthday_list = '';
|
||||
$birthday_ahead_list = '';
|
||||
if ($config['load_birthdays'] && $config['allow_birthdays'])
|
||||
{
|
||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||
$sql = 'SELECT user_id, username, user_colour, user_birthday
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
|
||||
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
|
||||
$result = $db->sql_query($sql);
|
||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||
$today = (mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']));
|
||||
|
||||
$sql = 'SELECT user_id, username, user_colour, user_birthday
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_birthday <> ''
|
||||
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') ORDER BY SUBSTRING(user_birthday FROM 4 FOR 2) ASC, SUBSTRING(user_birthday FROM 1 FOR 2) ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$birthdaydate = (gmdate('Y') . '-' . trim(substr($row['user_birthday'],3,-5)) . '-' . trim(substr($row['user_birthday'],0,-8) ));
|
||||
$user_birthday = strtotime($birthdaydate);
|
||||
if($user_birthday == $today)
|
||||
{
|
||||
$birthday_list .= get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
|
||||
|
||||
if ($age = (int) substr($row['user_birthday'], -4))
|
||||
{
|
||||
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
if ($age = (int) substr($row['user_birthday'], -4))
|
||||
{
|
||||
$birthday_list .= ' (' . ($now['year'] - $age) . ')<br />'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if( $portal_config['allow_birthdays_ahead'] > 0 )
|
||||
{
|
||||
if ( $user_birthday >= ($today + 86400) && $user_birthday <= ($today + ($portal_config['allow_birthdays_ahead'] * 86400) ) )
|
||||
{
|
||||
if ($row['user_colour'])
|
||||
{
|
||||
$user_colour = ' style="color:#' . $row['user_colour'] . '"';
|
||||
$row['username'] = '<strong>' . $row['username'] . '</strong>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_colour = '';
|
||||
}
|
||||
|
||||
$birthday_ahead_list .= '<a' . $user_colour . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']) . '" title="' . date('d M', $user_birthday) . '">' . $row['username'] . '</a>';
|
||||
|
||||
if ( $age = (int) substr($row['user_birthday'], -4) )
|
||||
{
|
||||
$birthday_ahead_list .= ' (' . ($now['year'] - $age) . ')<br />'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Assign index specific vars
|
||||
$template->assign_vars(array(
|
||||
'BIRTHDAY_LIST' => $birthday_list,
|
||||
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
|
||||
)
|
||||
'BIRTHDAY_LIST' => $birthday_list,
|
||||
'BIRTHDAYS_AHEAD_LIST' => ( $portal_config['allow_birthdays_ahead'] > 0 ) ? $birthday_ahead_list : '',
|
||||
'L_BIRTHDAYS_AHEAD' => sprintf($user->lang['BIRTHDAYS_AHEAD'], $portal_config['allow_birthdays_ahead']),
|
||||
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user