From e4e7fb05095f0be3e5a8ad0bdc301032c30f62e6 Mon Sep 17 00:00:00 2001 From: nanosimbiot Date: Tue, 16 Aug 2011 14:14:00 +0000 Subject: [PATCH] r215 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit список именинников git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@215 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- upload/config_mods.php | 1 + upload/includes/functions.php | 58 +++++++++++----------- upload/includes/ucp/usercp_register.php | 2 +- upload/index.php | 37 +++++++++++++- upload/language/lang_russian/lang_main.php | 6 +++ upload/tracker.php | 2 +- 6 files changed, 75 insertions(+), 31 deletions(-) diff --git a/upload/config_mods.php b/upload/config_mods.php index 7d4f203c0..3eef84594 100644 --- a/upload/config_mods.php +++ b/upload/config_mods.php @@ -35,6 +35,7 @@ $bb_cfg['no_avatar'] = 'images/avatars/gallery/noavatar.png'; $bb_cfg['birthday']['enabled'] = true; $bb_cfg['birthday']['max_user_age'] = 100; $bb_cfg['birthday']['min_user_age'] = 10; +$bb_cfg['birthday']['check_day'] = 7; // CallSeed $bb_cfg['callseed'] = false; \ No newline at end of file diff --git a/upload/includes/functions.php b/upload/includes/functions.php index e41275f8c..a27dd21e9 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -1558,7 +1558,7 @@ function setup_style () } // Create date/time from format and timezone -function bb_date ($gmepoch, $format = false, $tz = null) +function bb_date ($gmepoch, $format = false, $tz = null, $replace = true) { global $bb_cfg, $lang; @@ -1574,38 +1574,40 @@ function bb_date ($gmepoch, $format = false, $tz = null) $thetime = ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; - $time_format = " H:i"; + if($replace) + { + $time_format = " H:i"; - $date = getdate(); - $today = $date['mday']; - $month = $date['mon']; - $year = $date['year']; + $date = getdate(); + $today = $date['mday']; + $month = $date['mon']; + $year = $date['year']; - $forum_date_today = @gmdate ("d", $gmepoch + (3600 * $tz)); - $forum_date_month = @gmdate ("m", $gmepoch + (3600 * $tz)); - $forum_date_year = @gmdate ("Y", $gmepoch + (3600 * $tz)); + $forum_date_today = @gmdate ("d", $gmepoch + (3600 * $tz)); + $forum_date_month = @gmdate ("m", $gmepoch + (3600 * $tz)); + $forum_date_year = @gmdate ("Y", $gmepoch + (3600 * $tz)); - if ($forum_date_today == $today && $forum_date_month == $month && $forum_date_year == $year) - { - $thetime = $lang['TODAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); - } - elseif ($today != 1 && $forum_date_today == ($today-1) && $forum_date_month == $month && $forum_date_year == $year) - { - $thetime = $lang['YESTERDAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); - } - elseif ($today == 1 && $month != 1) - { - $yesterday = date ("t", mktime(0, 0, 0, ($month-1), 1, $year)); - if ($forum_date_today == $yesterday && $forum_date_month == ($month-1) && $forum_date_year == $year) + if ($forum_date_today == $today && $forum_date_month == $month && $forum_date_year == $year) + { + $thetime = $lang['TODAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); + } + elseif ($today != 1 && $forum_date_today == ($today-1) && $forum_date_month == $month && $forum_date_year == $year) + { $thetime = $lang['YESTERDAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); + } + elseif ($today == 1 && $month != 1) + { + $yesterday = date ("t", mktime(0, 0, 0, ($month-1), 1, $year)); + if ($forum_date_today == $yesterday && $forum_date_month == ($month-1) && $forum_date_year == $year) + $thetime = $lang['YESTERDAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); + } + elseif ($today == 1 && $month == 1) + { + $yesterday = date ("t", mktime(0, 0, 0, 12, 1, ($year -1))); + if ($forum_date_today == $yesterday && $forum_date_month == 12 && $forum_date_year == ($year-1)) + $thetime = $lang['YESTERDAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); + } } - elseif ($today == 1 && $month == 1) - { - $yesterday = date ("t", mktime(0, 0, 0, 12, 1, ($year -1))); - if ($forum_date_today == $yesterday && $forum_date_month == 12 && $forum_date_year == ($year-1)) - $thetime = $lang['YESTERDAY'] . @gmdate($time_format, $gmepoch + (3600 * $tz)); - } - return ($thetime); } diff --git a/upload/includes/ucp/usercp_register.php b/upload/includes/ucp/usercp_register.php index 57eee8142..49402fac2 100644 --- a/upload/includes/ucp/usercp_register.php +++ b/upload/includes/ucp/usercp_register.php @@ -726,7 +726,7 @@ if($bb_cfg['birthday']['enabled'] && $mode != 'register') } $s_birthday .= build_select('b_md', $months, $b_md); - $year = date('Y'); + $year = bb_date(TIMENOW, 'Y', '', false); $years = array($lang['DELTA_TIME']['INTERVALS']['year'][0] => 0); for($i=$year-$bb_cfg['birthday']['max_user_age']; $i<=$year-$bb_cfg['birthday']['min_user_age']; $i++) { diff --git a/upload/index.php b/upload/index.php index a59db7ce1..db78d629b 100644 --- a/upload/index.php +++ b/upload/index.php @@ -330,11 +330,46 @@ if ($bb_cfg['show_latest_news']) $template->assign_block_vars('news', array( 'NEWS_TOPIC_ID' => $news['topic_id'], 'NEWS_TITLE' => $news['topic_title'], - 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M'), + 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', '', false), 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']), )); } } + +if($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) +{ + $this_year = bb_date(TIMENOW, 'Y', '', false); + $date_today = bb_date(TIMENOW, 'Ymd', '', false); + $date_forward = bb_date(TIMENOW+($bb_cfg['birthday']['check_day']*86400), 'Ymd', '', false); + + $birthday_today_list = $birthday_week_list = array(); + + foreach ($stats['birthday'] as $birthdayrow) + { + $user_birthday2 = $this_year . ($user_birthday = realdate("md", $birthdayrow['user_birthday'])); + + if ($user_birthday2 < $date_today) $user_birthday2 += 10000; + + if ($user_birthday2 > $date_today && $user_birthday2 <= $date_forward) + { + // user are having birthday within the next days + $birthday_week_list[] = ''. wbr($birthdayrow['username']) .' ('. birthday_age($birthdayrow['user_birthday']) .')'; + } + elseif ($user_birthday2 == $date_today) + { + //user have birthday today + $birthday_today_list[] = ''. wbr($birthdayrow['username']) .' ('. birthday_age($birthdayrow['user_birthday']) .')'; + } + } + $birthday_today_list = ($birthday_today_list) ? $lang['BIRTHDAY_TODAY'] . join(', ', $birthday_today_list) : $lang['NOBIRTHDAY_TODAY']; + $birthday_week_list = ($birthday_week_list) ? sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day'], join(', ', $birthday_week_list)) : sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day']); + + $template->assign_vars(array( + 'WHOSBIRTHDAY_WEEK' => $birthday_week_list, + 'WHOSBIRTHDAY_TODAY' => $birthday_today_list, + )); +} + // Allow cron if (IS_AM) { diff --git a/upload/language/lang_russian/lang_main.php b/upload/language/lang_russian/lang_main.php index 8e31290bd..a544b900b 100644 --- a/upload/language/lang_russian/lang_main.php +++ b/upload/language/lang_russian/lang_main.php @@ -582,11 +582,17 @@ $lang['GENDER_SELECT'] = array( 2 => 'Женский' ); $lang['MODULE_OFF'] = 'Модуль отключен!'; + $lang['BIRTHDAY'] = 'День рождения'; $lang['WRONG_BIRTHDAY_FORMAT'] = 'Дата рождения указана неверно'; $lang['AGE'] = 'Возраст'; $lang['BIRTHDAY_TO_HIGH'] = 'Извините, сайт запрещено посещать людям старше %d лет'; $lang['BIRTHDAY_TO_LOW'] = 'Извините, сайт запрещено посещать детям младше %d лет'; +$lang['BIRTHDAY_TODAY'] = 'Пользователи, празднующие День Рождения сегодня:'; +$lang['BIRTHDAY_WEEK'] = 'Пользователи, празднующие День Рождения в ближайшие %d дней: %s'; +$lang['NOBIRTHDAY_WEEK'] = 'В ближайшие %d дней никто не празднует День Рождения.'; // %d is substitude with the number of days +$lang['NOBIRTHDAY_TODAY'] = 'Сегодня никто не празднует День Рождения.'; + $lang['NO_THEMES'] = 'В базе нет цветовых схем'; $lang['TIMEZONE'] = 'Часовой пояс'; $lang['DATE_FORMAT_PROFILE'] = 'Формат даты'; diff --git a/upload/tracker.php b/upload/tracker.php index 79d272088..6d5ef9e9b 100644 --- a/upload/tracker.php +++ b/upload/tracker.php @@ -780,7 +780,7 @@ if ($allowed_forums) 'VIEWS' => $tor['topic_views'], 'ADDED_RAW' => $tor['reg_time'], 'ADDED_TIME' => bb_date($tor['reg_time'], $time_format), - 'ADDED_DATE' => bb_date($tor['reg_time'], $date_format), + 'ADDED_DATE' => bb_date($tor['reg_time'], $date_format, '', false), )); } }