Merge pull request #539 from torrentpier/user-birthday-icon-profile

Added user birthday icon in profile
This commit is contained in:
Roman Kelesidis 2023-02-20 21:30:44 +07:00 committed by GitHub
commit bd9561fc42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View file

@ -2092,3 +2092,21 @@ function clean_tor_dirname($dirname)
{
return str_replace(array('[', ']', '<', '>', "'"), array('&#91;', '&#93;', '&lt;', '&gt;', '&#039;'), $dirname);
}
/**
* Get birthday icon
*
* @param $user_birthday
* @param $user_id
* @return string
*/
function user_birthday_icon($user_birthday, $user_id): string
{
global $bb_cfg, $images, $lang;
$current_date = bb_date(TIMENOW, 'md', false);
$user_birthday = ($user_id != GUEST_UID && !empty($user_birthday) && $user_birthday != '1900-01-01')
? date('md', strtotime($user_birthday)) : false;
return ($bb_cfg['birthday_enabled'] && $current_date == $user_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : '';
}

View file

@ -99,6 +99,7 @@ $template->assign_vars(array(
'USER_POINTS' => $profiledata['user_points'],
'GENDER' => ($bb_cfg['gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '',
'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? $profiledata['user_birthday'] : '',
'BIRTHDAY_ICON' => user_birthday_icon($profiledata['user_birthday'], $profiledata['user_id']),
'AGE' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? birthday_age($profiledata['user_birthday']) : '',
'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),

View file

@ -221,6 +221,7 @@ ajax.callback.gen_passkey = function(data){
{RANK_IMAGE}
<!-- ENDIF -->
</p>
<!-- IF BIRTHDAY_ICON --><div class="mrg_8">{BIRTHDAY_ICON}</div><!-- ENDIF -->
<h4 class="cat border bw_TB" id="username">{L_CONTACT} <span class="editable bold">{USERNAME}</span></h4>
<div class="spacer_4"></div>

View file

@ -566,13 +566,9 @@ if ($topic_has_poll) {
$prev_post_time = $max_post_time = 0;
$this_date = bb_date(TIMENOW, 'md', false);
for ($i = 0; $i < $total_posts; $i++) {
$poster_id = $postrow[$i]['user_id'];
$poster = ($poster_id == GUEST_UID) ? $lang['GUEST'] : $postrow[$i]['username'];
$poster_birthday = ($poster_id != GUEST_UID && !empty($postrow[$i]['user_birthday']) && $postrow[$i]['user_birthday'] != '1900-01-01')
? date('md', strtotime($postrow[$i]['user_birthday'])) : '';
$post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']);
$max_post_time = max($max_post_time, $postrow[$i]['post_time']);
$poster_posts = ($poster_id != GUEST_UID) ? $postrow[$i]['user_posts'] : '';
@ -732,7 +728,7 @@ for ($i = 0; $i < $total_posts; $i++) {
'DELETE' => $delpost_btn,
'IP' => $ip_btn,
'POSTER_BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $this_date == $poster_birthday) ? '<img src="' . $images['icon_birthday'] . '" alt="" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : '',
'POSTER_BIRTHDAY' => user_birthday_icon($postrow[$i]['user_birthday'], $postrow[$i]['user_id']),
'MC_COMMENT' => ($mc_type) ? bbcode2html($mc_comment) : '',
'MC_BBCODE' => ($mc_type) ? $mc_comment : '',