From 2f458352b8660386021af6868dcec75943bb8483 Mon Sep 17 00:00:00 2001
From: Andreas Fischer
Date: Sun, 8 May 2011 15:24:03 +0200
Subject: [PATCH 1/4] [ticket/10173] Use a loop var for the birthdays list to
allow proper templating
Introduce a loop variable for the list of birthdays to allow templates to
handle how the list is displayed.
We keep the old BIRTHDAY_LIST variable that contains the precompiled list
around for backward compatibility.
PHPBB3-10173
---
phpBB/index.php | 14 +++++++++++---
phpBB/styles/prosilver/template/index_body.html | 4 ++--
phpBB/styles/subsilver2/template/index_body.html | 2 +-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/phpBB/index.php b/phpBB/index.php
index 0830dd0686..e5dceeacf2 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -96,12 +96,20 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
while ($row = $db->sql_fetchrow($result))
{
- $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
+ $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
+ $birthday_list .= (($birthday_list != '') ? ', ' : '') . $birthday_username;
+ $birthday_year = (int) substr($row['user_birthday'], -4);
+ $birthday_age = $now['year'] - $birthday_year;
- if ($age = (int) substr($row['user_birthday'], -4))
+ if ($birthday_year)
{
- $birthday_list .= ' (' . ($now['year'] - $age) . ')';
+ $birthday_list .= ' (' . $birthday_age . ')';
}
+
+ $template->assign_block_vars('birthdays', array(
+ 'USERNAME' => $birthday_username,
+ 'AGE' => ($birthday_year) ? $birthday_age : '',
+ ));
}
$db->sql_freeresult($result);
}
diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html
index 539c851d1d..b183cf4372 100644
--- a/phpBB/styles/prosilver/template/index_body.html
+++ b/phpBB/styles/prosilver/template/index_body.html
@@ -35,9 +35,9 @@
{L_LEGEND}: {LEGEND}
-
+
{L_BIRTHDAYS}
- {L_CONGRATULATIONS}: {BIRTHDAY_LIST}{L_NO_BIRTHDAYS}
+ {L_CONGRATULATIONS}: {birthdays.USERNAME} ({birthdays.AGE}), {L_NO_BIRTHDAYS}
diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html
index e52e357564..100199c209 100644
--- a/phpBB/styles/subsilver2/template/index_body.html
+++ b/phpBB/styles/subsilver2/template/index_body.html
@@ -50,7 +50,7 @@
 |
- {L_CONGRATULATIONS}: {BIRTHDAY_LIST}{L_NO_BIRTHDAYS} |
+ {L_CONGRATULATIONS}: {birthdays.USERNAME} ({birthdays.AGE}), {L_NO_BIRTHDAYS} |
From 6a7d7285fbee7fd7838f1bf45e631cb3307ac514 Mon Sep 17 00:00:00 2001
From: Andreas Fischer
Date: Sun, 8 May 2011 16:41:55 +0200
Subject: [PATCH 2/4] [ticket/10173] Use an array for the legacy birthday list
as per rxu.
PHPBB3-10173
---
phpBB/index.php | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/phpBB/index.php b/phpBB/index.php
index e5dceeacf2..62c229f0b5 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -81,7 +81,7 @@ $db->sql_freeresult($result);
$legend = implode(', ', $legend);
// Generate birthday list if required ...
-$birthday_list = '';
+$birthday_list = array();
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
@@ -96,20 +96,17 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
while ($row = $db->sql_fetchrow($result))
{
- $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
- $birthday_list .= (($birthday_list != '') ? ', ' : '') . $birthday_username;
- $birthday_year = (int) substr($row['user_birthday'], -4);
- $birthday_age = $now['year'] - $birthday_year;
-
- if ($birthday_year)
- {
- $birthday_list .= ' (' . $birthday_age . ')';
- }
+ $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
+ $birthday_year = (int) substr($row['user_birthday'], -4);
+ $birthday_age = $now['year'] - $birthday_year;
$template->assign_block_vars('birthdays', array(
'USERNAME' => $birthday_username,
'AGE' => ($birthday_year) ? $birthday_age : '',
));
+
+ // For 3.0 compatibility
+ $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
}
$db->sql_freeresult($result);
}
@@ -122,7 +119,7 @@ $template->assign_vars(array(
'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'LEGEND' => $legend,
- 'BIRTHDAY_LIST' => $birthday_list,
+ 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode(', ', $birthday_list),
'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'),
'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'),
From a072526890a5ebbe363f57f31f9c516a9a416883 Mon Sep 17 00:00:00 2001
From: Andreas Fischer
Date: Sun, 8 May 2011 21:31:19 +0200
Subject: [PATCH 3/4] [ticket/10173] Only calculate age if year is not false as
per nn-.
PHPBB3-10173
---
phpBB/index.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/phpBB/index.php b/phpBB/index.php
index 62c229f0b5..5d62cb1071 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -98,15 +98,15 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
$birthday_year = (int) substr($row['user_birthday'], -4);
- $birthday_age = $now['year'] - $birthday_year;
+ $birthday_age = ($birthday_year) ? $now['year'] - $birthday_year : '';
$template->assign_block_vars('birthdays', array(
'USERNAME' => $birthday_username,
- 'AGE' => ($birthday_year) ? $birthday_age : '',
+ 'AGE' => $birthday_age,
));
// For 3.0 compatibility
- $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
+ $birthday_list[] = $birthday_username . (($birthday_age) ? ' (' . $birthday_age . ')' : '');
}
$db->sql_freeresult($result);
}
From 6aa2f9e7422c41193294c871913867ee42dc34a0 Mon Sep 17 00:00:00 2001
From: Andreas Fischer
Date: Wed, 11 May 2011 11:21:37 +0200
Subject: [PATCH 4/4] [ticket/10173] Use correct variable, checking for
$birthday_year was correct.
PHPBB3-10173
---
phpBB/index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpBB/index.php b/phpBB/index.php
index 5d62cb1071..427377a2cd 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -106,7 +106,7 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
));
// For 3.0 compatibility
- $birthday_list[] = $birthday_username . (($birthday_age) ? ' (' . $birthday_age . ')' : '');
+ $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
}
$db->sql_freeresult($result);
}