/** * (11) Print the user's account information * Also print the select box where users can switch projects * @return null */ function html_login_info() { $t_username = current_user_get_field('username'); $t_access_level = get_enum_element('access_levels', current_user_get_access_level()); $t_now = date(config_get('complete_date_format')); $t_realname = current_user_get_field('realname'); echo '<table class="hide">'; echo '<tr>'; echo '<td class="login-info-left">'; if (current_user_is_anonymous()) { $t_return_page = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING'])) { $t_return_page .= '?' . $_SERVER['QUERY_STRING']; } $t_return_page = string_url($t_return_page); echo lang_get('anonymous') . ' | <a href="' . helper_mantis_url('login_page.php?return=' . $t_return_page) . '">' . lang_get('login_link') . '</a>'; if (config_get_global('allow_signup') == ON) { echo ' | <a href="' . helper_mantis_url('signup_page.php') . '">' . lang_get('signup_link') . '</a>'; } } else { echo lang_get('logged_in_as'), ": <span class=\"italic\">", string_html_specialchars($t_username), "</span> <span class=\"small\">"; echo is_blank($t_realname) ? "({$t_access_level})" : "(" . string_html_specialchars($t_realname) . " - {$t_access_level})"; echo "</span>"; } echo '</td>'; echo '<td class="login-info-middle">'; echo "<span class=\"italic\">{$t_now}</span>"; echo '</td>'; echo '<td class="login-info-right">'; # Project Selector hidden if only one project visisble to user $t_show_project_selector = true; $t_project_ids = current_user_get_accessible_projects(); if (count($t_project_ids) == 1) { $t_project_id = (int) $t_project_ids[0]; if (count(current_user_get_accessible_subprojects($t_project_id)) == 0) { $t_show_project_selector = false; } } if ($t_show_project_selector) { echo '<form method="post" name="form_set_project" action="' . helper_mantis_url('set_project.php') . '">'; # CSRF protection not required here - form does not result in modifications echo lang_get('email_project'), ': '; if (ON == config_get('show_extended_project_browser')) { print_extended_project_browser(helper_get_current_project_trace()); } else { if (ON == config_get('use_javascript')) { echo '<select name="project_id" class="small" onchange="document.forms.form_set_project.submit();">'; } else { echo '<select name="project_id" class="small">'; } print_project_option_list(join(';', helper_get_current_project_trace()), true, null, true); echo '</select> '; } echo '<input type="submit" class="button-small" value="' . lang_get('switch') . '" />'; echo '</form>'; } else { # User has only one project, set it as both current and default if (ALL_PROJECTS == helper_get_current_project()) { helper_set_current_project($t_project_id); if (!current_user_is_protected()) { current_user_set_default_project($t_project_id); } # Force reload of current page, except if we got here after # creating the first project $t_redirect_url = str_replace(config_get('short_path'), '', $_SERVER['REQUEST_URI']); if ('manage_proj_create.php' != $t_redirect_url) { html_meta_redirect($t_redirect_url, 0, false); } } } if (OFF != config_get('rss_enabled')) { # Link to RSS issues feed for the selected project, including authentication details. echo '<a href="' . htmlspecialchars(rss_get_issues_feed_url()) . '">'; echo '<img src="' . helper_mantis_url('images/rss.png') . '" alt="' . lang_get('rss') . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; echo '</a>'; } echo '</td>'; echo '</tr>'; echo '</table>'; }
/** * (10) Print the user's account information * Also print the select box where users can switch projects * @return void */ function html_login_info() { $t_username = current_user_get_field('username'); $t_access_level = get_enum_element('access_levels', current_user_get_access_level()); $t_now = date(config_get('complete_date_format')); $t_realname = current_user_get_field('realname'); # Login information echo '<div id="login-info">' . "\n"; if (current_user_is_anonymous()) { $t_return_page = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING'])) { $t_return_page .= '?' . $_SERVER['QUERY_STRING']; } $t_return_page = string_url($t_return_page); echo "\t" . '<span id="logged-anon-label">' . lang_get('anonymous') . '</span>' . "\n"; echo "\t" . '<span id="login-link"><a href="' . helper_mantis_url('login_page.php?return=' . $t_return_page) . '">' . lang_get('login_link') . '</a></span>' . "\n"; if (config_get_global('allow_signup') == ON) { echo "\t" . '<span id="signup-link"><a href="' . helper_mantis_url('signup_page.php') . '">' . lang_get('signup_link') . '</a></span>' . "\n"; } } else { echo "\t" . '<span id="logged-in-label">' . lang_get('logged_in_as') . '</span>' . "\n"; echo "\t" . '<span id="logged-in-user">' . string_html_specialchars($t_username) . '</span>' . "\n"; echo "\t" . '<span id="logged-in">'; echo !is_blank($t_realname) ? "\t" . '<span id="logged-in-realname">' . string_html_specialchars($t_realname) . '</span>' . "\n" : ''; echo "\t" . '<span id="logged-in-accesslevel" class="' . $t_access_level . '">' . $t_access_level . '</span>' . "\n"; echo "\t" . '</span>' . "\n"; } echo '</div>' . "\n"; # RSS feed if (OFF != config_get('rss_enabled')) { echo '<div id="rss-feed">' . "\n"; # Link to RSS issues feed for the selected project, including authentication details. echo "\t" . '<a href="' . htmlspecialchars(rss_get_issues_feed_url()) . '">' . "\n"; echo "\t" . '<img src="' . helper_mantis_url('images/rss.png') . '" alt="' . lang_get('rss') . '" title="' . lang_get('rss') . '" />' . "\n"; echo "\t" . '</a>' . "\n"; echo '</div>' . "\n"; } # Project Selector (hidden if only one project visisble to user) $t_show_project_selector = true; $t_project_ids = current_user_get_accessible_projects(); if (count($t_project_ids) == 1) { $t_project_id = (int) $t_project_ids[0]; if (count(current_user_get_accessible_subprojects($t_project_id)) == 0) { $t_show_project_selector = false; } } if ($t_show_project_selector) { echo '<div id="project-selector-div">'; echo '<form method="post" id="form-set-project" action="' . helper_mantis_url('set_project.php') . '">'; echo '<fieldset id="project-selector">'; # CSRF protection not required here - form does not result in modifications echo '<label for="form-set-project-id">' . lang_get('email_project') . '</label>'; echo '<select id="form-set-project-id" name="project_id">'; print_project_option_list(join(';', helper_get_current_project_trace()), true, null, true); echo '</select> '; echo '<input type="submit" class="button" value="' . lang_get('switch') . '" />'; echo '</fieldset>'; echo '</form>'; echo '</div>'; } else { # User has only one project, set it as both current and default if (ALL_PROJECTS == helper_get_current_project()) { helper_set_current_project($t_project_id); if (!current_user_is_protected()) { current_user_set_default_project($t_project_id); } # Force reload of current page, except if we got here after # creating the first project $t_redirect_url = str_replace(config_get('short_path'), '', $_SERVER['REQUEST_URI']); if ('manage_proj_create.php' != $t_redirect_url) { html_meta_redirect($t_redirect_url, 0, false); } } } # Current time echo '<div id="current-time">' . $t_now . '</div>'; }