Example #1
0
function print_menu()
{
    if (auth_is_user_authenticated()) {
        $t_protected = current_user_get_field('protected');
        $t_current_project = helper_get_current_project();
        print '<table class="width100" cellspacing="0">';
        print '<tr>';
        print '<td class="menu">';
        $t_menu_options = array();
        # Main Page
        $t_menu_options[] = '<a href="main_page.php">' . lang_get('main_link') . '</a>';
        # My View
        $t_menu_options[] = '<a href="my_view_page.php">' . lang_get('my_view_link') . '</a>';
        # View Bugs
        $t_menu_options[] = '<a href="view_all_bug_page.php">' . lang_get('view_bugs_link') . '</a>';
        # Report Bugs
        if (access_has_project_level(config_get('report_bug_threshold'))) {
            $t_menu_options[] = string_get_bug_report_link();
        }
        # Changelog Page
        if (access_has_project_level(config_get('view_changelog_threshold'))) {
            $t_menu_options[] = '<a href="changelog_page.php">' . lang_get('changelog_link') . '</a>';
        }
        # Roadmap Page
        if (access_has_project_level(config_get('roadmap_view_threshold'))) {
            $t_menu_options[] = '<a href="roadmap_page.php">' . lang_get('roadmap_link') . '</a>';
        }
        # Summary Page
        if (access_has_project_level(config_get('view_summary_threshold'))) {
            $t_menu_options[] = '<a href="summary_page.php">' . lang_get('summary_link') . '</a>';
        }
        # Project Documentation Page
        if (ON == config_get('enable_project_documentation')) {
            $t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get('docs_link') . '</a>';
        }
        # Project Wiki
        if (wiki_is_enabled()) {
            $t_menu_options[] = '<a href="wiki.php?type=project&amp;id=' . $t_current_project . '">' . lang_get('wiki') . '</a>';
        }
        # Manage Users (admins) or Manage Project (managers) or Manage Custom Fields
        $t_show_access = min(config_get('manage_user_threshold'), config_get('manage_project_threshold'), config_get('manage_custom_fields_threshold'));
        if (access_has_global_level($t_show_access) || access_has_any_project($t_show_access)) {
            $t_current_project = helper_get_current_project();
            if (access_has_global_level(config_get('manage_user_threshold'))) {
                $t_link = 'manage_user_page.php';
            } else {
                if (access_has_project_level(config_get('manage_project_threshold'), $t_current_project) && $t_current_project != ALL_PROJECTS) {
                    $t_link = 'manage_proj_edit_page.php?project_id=' . $t_current_project;
                } else {
                    $t_link = 'manage_proj_page.php';
                }
            }
            $t_menu_options[] = "<a href=\"{$t_link}\">" . lang_get('manage_link') . '</a>';
        }
        # News Page
        if (access_has_project_level(config_get('manage_news_threshold'))) {
            # Admin can edit news for All Projects (site-wide)
            if (ALL_PROJECTS != helper_get_current_project() || access_has_project_level(ADMINISTRATOR)) {
                $t_menu_options[] = '<a href="news_menu_page.php">' . lang_get('edit_news_link') . '</a>';
            } else {
                $t_menu_options[] = '<a href="login_select_proj_page.php">' . lang_get('edit_news_link') . '</a>';
            }
        }
        # Account Page (only show accounts that are NOT protected)
        if (OFF == $t_protected) {
            $t_menu_options[] = '<a href="account_page.php">' . lang_get('account_link') . '</a>';
        }
        # Add custom options
        $t_custom_options = prepare_custom_menu_options('main_menu_custom_options');
        $t_menu_options = array_merge($t_menu_options, $t_custom_options);
        if (config_get('time_tracking_enabled') && config_get('time_tracking_with_billing')) {
            $t_menu_options[] = '<a href="billing_page.php">' . lang_get('time_tracking_billing_link') . '</a>';
        }
        # Logout (no if anonymously logged in)
        if (!current_user_is_anonymous()) {
            $t_menu_options[] = '<a href="logout_page.php">' . lang_get('logout_link') . '</a>';
        }
        print implode($t_menu_options, ' | ');
        print '</td>';
        print '<td class="menu right nowrap">';
        print '<form method="post" action="jump_to_bug.php">';
        if (ON == config_get('use_javascript')) {
            $t_bug_label = lang_get('issue_id');
            print "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" value=\"{$t_bug_label}\" onfocus=\"if (this.value == '{$t_bug_label}') this.value = ''\" onblur=\"if (this.value == '') this.value = '{$t_bug_label}'\" />&nbsp;";
        } else {
            print "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" />&nbsp;";
        }
        print '<input type="submit" class="button-small" value="' . lang_get('jump') . '" />&nbsp;';
        print '</form>';
        print '</td>';
        print '</tr>';
        print '</table>';
    }
}
Example #2
0
/**
 * Print the main menu
 * @return null
 */
function print_menu()
{
    if (auth_is_user_authenticated()) {
        $t_protected = current_user_get_field('protected');
        $t_current_project = helper_get_current_project();
        $t_menu_options = array();
        # Main Page
        $t_menu_options[] = '<a href="' . helper_mantis_url('main_page.php') . '">' . lang_get('main_link') . '</a>';
        # Plugin / Event added options
        $t_event_menu_options = event_signal('EVENT_MENU_MAIN_FRONT');
        foreach ($t_event_menu_options as $t_plugin => $t_plugin_menu_options) {
            foreach ($t_plugin_menu_options as $t_callback => $t_callback_menu_options) {
                if (is_array($t_callback_menu_options)) {
                    $t_menu_options = array_merge($t_menu_options, $t_callback_menu_options);
                } else {
                    if (!is_null($t_callback_menu_options)) {
                        $t_menu_options[] = $t_callback_menu_options;
                    }
                }
            }
        }
        # My View
        $t_menu_options[] = '<a href="' . helper_mantis_url('my_view_page.php">') . lang_get('my_view_link') . '</a>';
        # View Bugs
        $t_menu_options[] = '<a href="' . helper_mantis_url('view_all_bug_page.php">') . lang_get('view_bugs_link') . '</a>';
        # Report Bugs
        if (access_has_project_level(config_get('report_bug_threshold'))) {
            $t_menu_options[] = string_get_bug_report_link();
        }
        # Changelog Page
        if (access_has_project_level(config_get('view_changelog_threshold'))) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('changelog_page.php">') . lang_get('changelog_link') . '</a>';
        }
        # Roadmap Page
        if (access_has_project_level(config_get('roadmap_view_threshold'))) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('roadmap_page.php">') . lang_get('roadmap_link') . '</a>';
        }
        # Summary Page
        if (access_has_project_level(config_get('view_summary_threshold'))) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('summary_page.php">') . lang_get('summary_link') . '</a>';
        }
        # Project Documentation Page
        if (ON == config_get('enable_project_documentation')) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('proj_doc_page.php">') . lang_get('docs_link') . '</a>';
        }
        # Project Wiki
        if (config_get_global('wiki_enable') == ON) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('wiki.php?type=project&amp;id=') . $t_current_project . '">' . lang_get('wiki') . '</a>';
        }
        # Plugin / Event added options
        $t_event_menu_options = event_signal('EVENT_MENU_MAIN');
        foreach ($t_event_menu_options as $t_plugin => $t_plugin_menu_options) {
            foreach ($t_plugin_menu_options as $t_callback => $t_callback_menu_options) {
                if (is_array($t_callback_menu_options)) {
                    $t_menu_options = array_merge($t_menu_options, $t_callback_menu_options);
                } else {
                    if (!is_null($t_callback_menu_options)) {
                        $t_menu_options[] = $t_callback_menu_options;
                    }
                }
            }
        }
        # Manage Users (admins) or Manage Project (managers) or Manage Custom Fields
        if (access_has_global_level(config_get('manage_site_threshold'))) {
            $t_link = helper_mantis_url('manage_overview_page.php');
            $t_menu_options[] = '<a class="manage-menu-link" href="' . $t_link . '">' . lang_get('manage_link') . '</a>';
        } else {
            $t_show_access = min(config_get('manage_user_threshold'), config_get('manage_project_threshold'), config_get('manage_custom_fields_threshold'));
            if (access_has_global_level($t_show_access) || access_has_any_project($t_show_access)) {
                $t_current_project = helper_get_current_project();
                if (access_has_global_level(config_get('manage_user_threshold'))) {
                    $t_link = helper_mantis_url('manage_user_page.php');
                } else {
                    if (access_has_project_level(config_get('manage_project_threshold'), $t_current_project) && $t_current_project != ALL_PROJECTS) {
                        $t_link = helper_mantis_url('manage_proj_edit_page.php?project_id=') . $t_current_project;
                    } else {
                        $t_link = helper_mantis_url('manage_proj_page.php');
                    }
                }
                $t_menu_options[] = "<a href=\"{$t_link}\">" . lang_get('manage_link') . '</a>';
            }
        }
        # News Page
        if (news_is_enabled() && access_has_project_level(config_get('manage_news_threshold'))) {
            # Admin can edit news for All Projects (site-wide)
            if (ALL_PROJECTS != helper_get_current_project() || current_user_is_administrator()) {
                $t_menu_options[] = '<a href="' . helper_mantis_url('news_menu_page.php">') . lang_get('edit_news_link') . '</a>';
            } else {
                $t_menu_options[] = '<a href="' . helper_mantis_url('login_select_proj_page.php">') . lang_get('edit_news_link') . '</a>';
            }
        }
        # Account Page (only show accounts that are NOT protected)
        if (OFF == $t_protected) {
            $t_menu_options[] = '<a class="account-menu-link" href="' . helper_mantis_url('account_page.php">') . lang_get('account_link') . '</a>';
        }
        # Add custom options
        $t_custom_options = prepare_custom_menu_options('main_menu_custom_options');
        $t_menu_options = array_merge($t_menu_options, $t_custom_options);
        # Time Tracking / Billing
        if (config_get('time_tracking_enabled') && access_has_global_level(config_get('time_tracking_reporting_threshold'))) {
            $t_menu_options[] = '<a href="' . helper_mantis_url('billing_page.php">') . lang_get('time_tracking_billing_link') . '</a>';
        }
        # Logout (no if anonymously logged in)
        if (!current_user_is_anonymous()) {
            $t_menu_options[] = '<a id="logout-link" href="' . helper_mantis_url('logout_page.php">') . lang_get('logout_link') . '</a>';
        }
        echo '<form method="post" action="' . helper_mantis_url('jump_to_bug.php" class="bug-jump-form">');
        echo '<fieldset class="bug-jump">';
        # CSRF protection not required here - form does not result in modifications
        $t_bug_label = lang_get('issue_id');
        echo '<input type="hidden" name="bug_label" value="', $t_bug_label, '" />';
        echo '<input type="text" name="bug_id" size="10" class="small" />&#160;';
        echo '<input type="submit" class="button-small" value="' . lang_get('jump') . '" />&#160;';
        echo '</fieldset>';
        echo '</form>';
        echo '<div class="main-menu">';
        echo '<div>';
        echo '<ul class="menu">';
        echo '<li>';
        echo implode($t_menu_options, "</li>\n<li>");
        echo '</li>';
        echo '</ul>';
        echo '</div>';
        echo '</div>';
    }
}