public static function create_nav_bar()

in app/libraries/CommonUtilities.php [101:268]


    public static function create_nav_bar()
    {
        $menus = array();
        if  ( Session::has('loggedin') && 
            ( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only')) &&
              !Session::has("gateway-provider")
            ) {
            $menus = array
            (
                'Project' => array
                (
                    array('label' => 'Create', 'url' => URL::to('/') . '/project/create', "nav-active" => "project"),
                    array('label' => 'Browse', 'url' => URL::to('/') . '/project/browse', "nav-active" => "project")
                ),
                'Experiment' => array
                (
                    array('label' => 'Create', 'url' => URL::to('/') . '/experiment/create', "nav-active" => "experiment"),
                    array('label' => 'Browse', 'url' => URL::to('/') . '/experiment/browse', "nav-active" => "experiment")
                )
            );

            if( isset( Config::get('pga_config.portal')['jira-help']))
            {
                $menus['Help'] = array();
                if( Config::get('pga_config.portal')['jira-help']['report-issue-script'] != '' 
                    && Config::get('pga_config.portal')['jira-help']['report-issue-collector-id'] != '')
                {
                    $menus['Help'][] = array('label' => 'Report Issue', 'url' => '#', "nav-active", "");
                }  
    //                array('label' => 'Forgot Password?', 'url' => URL::to('/') . '/forgot-password', "nav-active" => "")
                if( Config::get('pga_config.portal')['jira-help']['request-feature-script'] != '' 
                    && Config::get('pga_config.portal')['jira-help']['request-feature-collector-id'] != '')
                {
                    $menus['Help'][] = array('label' => 'Request Feature', 'url' => '#', "nav-active", "");
                }

                if( count( $menus['Help'] ) == 0 )
                    unset( $menus['Help']);
            }
        }

        $navbar = '<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
                       <span class="sr-only">Toggle navigation</span>
                       <span class="icon-bar"></span>
                       <span class="icon-bar"></span>
                       <span class="icon-bar"></span>
                    </button>
                    <!--
                    <a class="navbar-brand" href="' . URL::to('home') . '" title="PHP Gateway with Airavata">PGA</a>
                    -->
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                    <ul class="nav navbar-nav">';
            
            $navbar .= '<li>
                        <a href="' . URL::to("/") . '">
                            <span class="brand-logo"></span>
                        </a>
                        </li>';


        foreach ($menus as $label => $options) {
            Session::has('loggedin') ? $disabled = '' : $disabled = ' class="disabled"';

            $active = "";
            if (Session::has("nav-active") && isset($options[0]['nav-active'])) {
                if ($options[0]['nav-active'] == Session::get("nav-active"))
                    $active = " active ";
            }
            $navbar .= '<li class="dropdown ' . $active . '">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $label . '<span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">';

            if (Session::has('loggedin')) {
                foreach ($options as $option) {
                    $id = strtolower(str_replace(' ', '-', $option['label']));

                    $navbar .= '<li' . $disabled . '><a href="' . $option['url'] . '" id=' . $id . '>' . $option['label'] . '</a></li>';
                }
            }

            $navbar .= '</ul></li>';
        }

        $active = "";
        if(Session::has('loggedin') && 
            (Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only')) &&
            !Session::has("gateway-provider")
        ){
            if( Session::get("nav-active") == "storage")
                $active = "active";
            $navbar .= '<li class="' . $active . '"><a href="' . URL::to("/") . '/files/browse"><span class="glyphicon glyphicon-folder-close"></span> Storage</a></li>';
        }
        $navbar .= '</ul>

        <ul class="nav navbar-nav navbar-right">';

        // right-aligned content

        if (Session::has('loggedin')) {
            $active = "";
            if (Session::has("nav-active")) {
                if ("user-console" == Session::get("nav-active") || "user-dashboard" == Session::get("nav-active"))
                    $active = " active ";
            }

            if( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only') || Session::has('gateway-provider')){
                //notification bell
                $notices = array();
                if (CommonUtilities::isAiravataUp()) {
                    $notices = CommonUtilities::get_all_notices();
                }
                $navbar .= CommonUtilities::get_notices_ui( $notices);
            }

            if ( (Session::has("admin") || Session::has("admin-read-only")) && !Session::has("gateway-provider") )
                $navbar .= '<li class="' . $active . '"><a href="' . URL::to("/") . '/admin/dashboard"><span class="glyphicon glyphicon-user"></span>Admin Dashboard</a></li>';
            else if ( Session::has("gateway-provider"))
                $navbar .= '<li class="' . $active . '"><a href="' . URL::to("/") . '/admin/dashboard"><span class="glyphicon glyphicon-user"></span>Dashboard</a></li>';
            else
                $navbar .= '<li class="' . $active . '"><a href="' . URL::to("/") . '/account/dashboard"><span class="glyphicon glyphicon-user"></span>Dashboard</a></li>';

            $navbar .= '<li class="dropdown' . (Session::get("nav-active") == 'user-menu' ? ' active' : '') . '">

                <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . Session::get("username") . ' <span class="caret"></span></a>';
            $navbar .= '<ul class="dropdown-menu" role="menu">';

            if ( Session::has("existing-gateway-provider")) {
                $requestedGateways = Session::get("requestedGateways");
                foreach( $requestedGateways as $gatewayId => $gateway){
                    if( $gateway["approvalStatus"] == "Approved"){
                        $navbar .= '<li><a href="' . URL::to('/') . '/admin/dashboard?gatewayId=' . $gateway["gatewayInfo"]->gatewayId . '">Manage ' . $gateway["gatewayInfo"]->gatewayName . '</a></li>';
                    }
                }
            }

            if( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only') || Session::has('gateway-provider') ){
                $navbar .= '<li><a href="' . URL::to('/') . '/account/settings"><span class="glyphicon glyphicon-cog"></span> User settings</a></li>';
            }
            $navbar .= '<li><a href="' . URL::to('/') . '/logout"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>';
            $navbar .= '</ul></li>';
        } else {

            if( CommonUtilities::hasAuthPasswordOption() ){
                $navbar .= '<li><a href="' . URL::to('/') . '/create"><span class="glyphicon glyphicon-user"></span> Create account</a></li>';
            }
            $navbar .= '<li><a href="' . URL::to('/') . '/login"><span class="glyphicon glyphicon-log-in"></span> Log in</a></li>';
        }

        $navbar .= '</ul></div></div></nav>';

        // Check if theme user has created links in their theme to the login and create account page.
        if( !Session::has('loggedin') &&
                isset( Config::get('pga_config.portal')['theme-based-login-links-configured']))
        {
            if( Config::get('pga_config.portal')['theme-based-login-links-configured'] ){
                $navbar = "";
            }
        }

        echo $navbar;
    }