Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 75 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @ignore |
| 16 | */ |
| 17 | define('IN_PHPBB', true); |
| 18 | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 19 | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 20 | include($phpbb_root_path . 'common.' . $phpEx); |
| 21 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 22 | |
| 23 | // Start session management |
| 24 | $user->session_begin(); |
| 25 | $auth->acl($user->data); |
| 26 | $user->setup('viewforum'); |
| 27 | |
| 28 | display_forums('', $config['load_moderators']); |
| 29 | |
| 30 | /** @var \phpbb\group\helper $group_helper */ |
| 31 | $group_helper = $phpbb_container->get('group_helper'); |
| 32 | |
| 33 | // This is shown only if display_online_list is true |
| 34 | $group_helper->display_legend(); |
| 35 | |
| 36 | // Generate birthday list if required ... |
| 37 | $show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')); |
| 38 | |
| 39 | $birthdays = $birthday_list = array(); |
| 40 | if ($show_birthdays) |
| 41 | { |
| 42 | $time = $user->create_datetime(); |
| 43 | $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); |
| 44 | |
| 45 | // Display birthdays of 29th february on 28th february in non-leap-years |
| 46 | $leap_year_birthdays = ''; |
| 47 | if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) |
| 48 | { |
| 49 | $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'"; |
| 50 | } |
| 51 | |
| 52 | $sql_ary = array( |
| 53 | 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday', |
| 54 | 'FROM' => array( |
| 55 | USERS_TABLE => 'u', |
| 56 | ), |
| 57 | 'LEFT_JOIN' => array( |
| 58 | array( |
| 59 | 'FROM' => array(BANS_TABLE => 'b'), |
| 60 | 'ON' => 'u.user_id = b.ban_userid', |
| 61 | ), |
| 62 | ), |
| 63 | 'WHERE' => 'b.ban_id IS NULL |
| 64 | AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ") |
| 65 | AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)", |
| 66 | ); |
| 67 | |
| 68 | /** |
| 69 | * Event to modify the SQL query to get birthdays data |
| 70 | * |
| 71 | * @event core.index_modify_birthdays_sql |
| 72 | * @var array now The assoc array with the 'now' local timestamp data |
| 73 | * @var array sql_ary The SQL array to get the birthdays data |
| 74 | * @var object time The user related Datetime object |
| 75 | * @since 3.1.7-RC1 |
| 76 | */ |
| 77 | $vars = array('now', 'sql_ary', 'time'); |
| 78 | extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_sql', compact($vars))); |
| 79 | |
| 80 | $sql = $db->sql_build_query('SELECT', $sql_ary); |
| 81 | $result = $db->sql_query($sql); |
| 82 | $rows = $db->sql_fetchrowset($result); |
| 83 | $db->sql_freeresult($result); |
| 84 | |
| 85 | foreach ($rows as $row) |
| 86 | { |
| 87 | $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); |
| 88 | $birthday_year = (int) substr($row['user_birthday'], -4); |
| 89 | $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : ''; |
| 90 | |
| 91 | $birthdays[] = array( |
| 92 | 'USERNAME' => $birthday_username, |
| 93 | 'AGE' => $birthday_age, |
| 94 | ); |
| 95 | |
| 96 | // For 3.0 compatibility |
| 97 | $birthday_list[] = $birthday_username . (($birthday_age) ? " ({$birthday_age})" : ''); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Event to modify the birthdays list |
| 102 | * |
| 103 | * @event core.index_modify_birthdays_list |
| 104 | * @var array birthdays Array with the users birthdays data |
| 105 | * @var array rows Array with the birthdays SQL query result |
| 106 | * @since 3.1.7-RC1 |
| 107 | */ |
| 108 | $vars = array('birthdays', 'rows'); |
| 109 | extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_list', compact($vars))); |
| 110 | |
| 111 | $template->assign_block_vars_array('birthdays', $birthdays); |
| 112 | } |
| 113 | |
| 114 | $controller_helper = $phpbb_container->get('controller.helper'); |
| 115 | // Assign index specific vars |
| 116 | $template->assign_vars(array( |
| 117 | 'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']), |
| 118 | 'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']), |
| 119 | 'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']), |
| 120 | 'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])), |
| 121 | |
| 122 | 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list), |
| 123 | |
| 124 | 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), |
| 125 | 'U_SEND_PASSWORD' => ($config['email_enable'] && $config['allow_password_reset']) ? $controller_helper->route('phpbb_ucp_forgot_password_controller') : '', |
| 126 | 'S_DISPLAY_BIRTHDAY_LIST' => $show_birthdays, |
| 127 | 'S_INDEX' => true, |
| 128 | |
| 129 | 'U_CANONICAL' => generate_board_url() . '/', |
| 130 | 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', |
| 131 | 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front') : '') |
| 132 | ); |
| 133 | |
| 134 | $page_title = ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['INDEX']; |
| 135 | |
| 136 | /** |
| 137 | * You can use this event to modify the page title and load data for the index |
| 138 | * |
| 139 | * @event core.index_modify_page_title |
| 140 | * @var string page_title Title of the index page |
| 141 | * @since 3.1.0-a1 |
| 142 | */ |
| 143 | $vars = array('page_title'); |
| 144 | extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); |
| 145 | |
| 146 | // Output page |
| 147 | page_header($page_title, true); |
| 148 | |
| 149 | $template->set_filenames(array( |
| 150 | 'body' => 'index_body.html') |
| 151 | ); |
| 152 | |
| 153 | page_footer(); |