aboutsummaryrefslogtreecommitdiff
path: root/lib/navigation/FooterNavigation.php
blob: 9124fc2a38016e91ce552e9dd168df63a0de2063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
 * FooterNavigation.php - navigation for the footer on every page
 *
 * 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      Michael Riehemann <michael.riehemann@uni-oldenburg.de>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 * @since       2.1
 */

class FooterNavigation extends Navigation
{
    /**
     * Initialize a new Navigation instance.
     */
    public function __construct()
    {
        parent::__construct(_('Footer'));
    }

    public function initSubNavigation()
    {
        parent::initSubNavigation();

        // imprint
        $this->addSubNavigation('siteinfo', new Navigation(_('Impressum'), 'dispatch.php/siteinfo/show?cancel_login=1'));

        // sitemap
        if (is_object($GLOBALS['user']) && $GLOBALS['user']->id !== 'nobody') {
            $this->addSubNavigation('sitemap', new Navigation(_('Sitemap'), 'dispatch.php/sitemap/'));
        }

        //studip
        $this->addSubNavigation('studip', new Navigation(_('Stud.IP'), 'http://www.studip.de/'));

        // Datenschutzerklärung

        //Check if the privacy url is one of the Stud.IP pages:
        $privacy_url = Config::get()->PRIVACY_URL;
        if (is_internal_url($privacy_url)) {
            //It is a Stud.IP page. Add the cancel_login URL parameter.
            $privacy_url = URLHelper::getURL($privacy_url, ['cancel_login' => '1']);
        }

        $this->addSubNavigation('privacy', new Navigation(_('Datenschutzerklärung'), $privacy_url));

        $a11yurl = Config::get()->ACCESSIBILITY_DISCLAIMER_URL;
        if ($a11yurl) {
            $this->addSubNavigation(
                'a11ydisclaimer',
                new Navigation(
                    _('Barrierefreiheitserklärung'),
                    URLHelper::getURL($a11yurl, ['cancel_login' => 1], true)
                )
            );
        }

        if (
            Config::get()->REPORT_BARRIER_MODE === 'on'
            || (
                Config::get()->REPORT_BARRIER_MODE === 'logged-in'
                && User::findCurrent()
            )
        ) {
            $url = Request::url();

            // Remove 'page' parameter if the page links to itself
            if (str_contains($url, 'dispatch.php/accessibility/forms/report_barrier')) {
                $url = URLHelper::getURL($url, ['page' => null], true);
            }

            $this->addSubNavigation(
                'report_barrier',
                new Navigation(
                    _('Barriere melden'),
                    URLHelper::getURL(
                        'dispatch.php/accessibility/forms/report_barrier',
                        ['page' => $url, 'cancel_login' => '1']
                    )
                )
            );
        }
    }
}