Skip to content
Snippets Groups Projects
Select Git revision
  • a5f1f453f0367fae23a3b179633fae738d4ad7ad
  • main default protected
  • pdf-annotieren
  • pdf-annotieren-2.0
  • issue-4244
  • issues-4244-b
  • pdf-annotieren-old
  • biest-4274
  • issue-2982
  • issue-660
  • issue-3326
  • issue-3270
  • issue-3616
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • issue-4255
  • issue-4261
  • issue-4262
  • v5.4.2
  • v5.3.5
  • v5.2.7
  • v5.1.8
  • v5.4.1
  • v5.3.4
  • v5.2.6
  • v5.1.7
  • v5.0.9
  • v5.4
  • v5.3.3
  • v5.2.5
  • v5.1.6
  • v5.0.8
  • v5.3.2
  • v5.2.4
  • v5.1.5
  • v5.0.7
  • v5.3.1
  • v5.2.3
41 results

StudipNavigation.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    StudipNavigation.php 6.03 KiB
    <?php
    # Lifter010: TODO
    /**
     * StudipNavigation.php - Stud.IP root navigation class
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * @author      Elmar Ludwig
     * @author      Michael Riehemann <michael.riehemann@uni-oldenburg.de>
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     */
    
    /**
     * This is the class for the top navigation (toolbar) in the page header.
     */
    class StudipNavigation extends Navigation
    {
        /**
         * Initialize the subnavigation of this item. This method
         * is called once before the first item is added or removed.
         */
        public function initSubNavigation()
        {
            global $perm, $user;
    
            parent::initSubNavigation();
    
            // top navigation (toolbar)
            $this->addSubNavigation('start', new StartNavigation());
    
            // if the user is not logged in, he will see the free courses, otherwise
            // the my courses page will be shown.
            if ($user->id !== 'nobody' || Config::get()->ENABLE_FREE_ACCESS) {
                $this->addSubNavigation('browse', new BrowseNavigation());
            }
    
            // if a course is selected, the navigation for it will be loaded
            if (Context::getId()) {
                $this->addSubNavigation('course', new CourseNavigation());
            }
    
            try {
                if (
                    Config::get()->RESOURCES_ENABLE
                    && Config::get()->RESOURCES_SHOW_PUBLIC_ROOM_PLANS
                    && $user->id === 'nobody'
                    && Room::publicBookingPlansExists()
                ) {
                    //Show a navigation entry for the public booking plans overview.
                    $nav = new Navigation(
                        _('Belegungspläne'),
                        URLHelper::getURL('dispatch.php/room_management/overview/public_booking_plans')
                    );
                    $nav->setImage(Icon::create('timetable', 'navigation'));
                    $this->addSubNavigation('public_booking_plans', $nav);
                }
            } catch (PDOException $e) {
                //The resource migration probably hasn't run yet.
                //Do nothing here.
            }
    
            // contents pages
            if (isset($user) && $user->id !== 'nobody') {
                $this->addSubNavigation('contents', new ContentsNavigation());
            }
    
            // contents pages
            if (
                Config::get()->OERCAMPUS_ENABLED
                && isset($perm)
                && $perm->have_perm(Config::get()->OER_PUBLIC_STATUS)
            ) {
                $this->addSubNavigation('oer', new OERNavigation());
            }
    
            if (isset($user) && $user->id !== 'nobody') {
                // internal message system
                $this->addSubNavigation('messaging', new MessagingNavigation());
    
                // community page
                $this->addSubNavigation('community', new CommunityNavigation());
    
                // user profile page
                $this->addSubNavigation('profile', new ProfileNavigation());
    
                // calendar and schedule page
                $this->addSubNavigation('calendar', new CalendarNavigation());
    
                // search page
                $this->addSubNavigation('search', new SearchNavigation());
    
                // avatar menu
                $this->addSubNavigation('avatar', new AvatarNavigation());
            } elseif (Config::get()->COURSE_SEARCH_IS_VISIBLE_NOBODY) {
                // search page
                $this->addSubNavigation('search', new SearchNavigation());
            }
    
            //Add the resource management icon, if that area is enabled
            //and the current user either has global admin permissions in the
            //room and resource management or if the the current user has
            //autor permissions on at least one resource.
            $current_user = User::findCurrent();
            //The resources navigation entry shall only be visible
            //for users who are logged in.
            if ($current_user) {
                try {
                    $show_resources_navigation = (
                        (
                            RoomManager::userHasRooms($current_user)
                            ||
                            ResourceManager::userHasGlobalPermission(
                                $current_user,
                                'user'
                            )
                        )
                        &&
                        Config::get()->RESOURCES_ENABLE
                    );
                    if ($show_resources_navigation) {
                        $this->addSubNavigation('resources', new ResourceNavigation());
                    }
                } catch (PDOException $e) {
                    //The resource migration probably hasn't run yet.
                    //Do nothing here.
                }
            }
    
            // admin page
            if (isset($perm) && $perm->have_perm('admin')) {
                $this->addSubNavigation('admin', new AdminNavigation());
            }
    
            //mvv pages
            if (MVV::isVisible()) {
                $this->addSubNavigation('mvv', new MVVNavigation());
            }
    
            // quick links
            $links = new Navigation('Links');
    
            // login / logout
            if (!isset($user) || $user->id === 'nobody') {
                if (in_array('CAS', $GLOBALS['STUDIP_AUTH_PLUGIN'])) {
                    $links->addSubNavigation('login_cas', new Navigation(_('Login CAS'), Request::url(), ['again' => 'yes', 'sso' => 'cas', 'cancel_login' => 1]));
                }
    
                if (in_array('Shib', $GLOBALS['STUDIP_AUTH_PLUGIN'])) {
                    $links->addSubNavigation('login_shib', new Navigation(_('Login Shibboleth'), Request::url(), ['again' => 'yes', 'sso' => 'shib', 'cancel_login' => 1]));
                }
    
                $links->addSubNavigation('login', new Navigation(_('Login'), Request::url(), ['again' => 'yes']));
            }
    
            $this->addSubNavigation('links', $links);
    
            // footer links
            $this->addSubNavigation('footer', new FooterNavigation(_('Footer')));
    
            // login page
            $this->addSubNavigation('login', new LoginNavigation(_('Login')));
        }
    }