aboutsummaryrefslogtreecommitdiff
path: root/lib/navigation/CalendarNavigation.php
blob: f307348aa7aaeffa45a9aca1d40068af9a630d95 (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
<?php
# Lifter010: TODO
/*
 * CalendarNavigation.php - navigation for calendar
 *
 * 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
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 */

class CalendarNavigation extends Navigation
{
    /**
     * Initialize a new Navigation instance.
     */
    public function __construct()
    {
        $title = _('Planer');
        $main_url = URLHelper::getURL('dispatch.php/calendar/calendar', ['defaultDate' => date('Y-m-d')]);
        if (!$GLOBALS['perm']->have_perm('admin') && Config::get()->SCHEDULE_ENABLE) {
            $main_url = URLHelper::getURL('dispatch.php/calendar/schedule/index');
        }
        parent::__construct($title, $main_url);

        $this->setImage(Icon::create('schedule', 'navigation', ['title' => $title]));
    }

    /**
     * Initialize the sub-navigation of this item. This method
     * is called once before the first item is added or removed.
     */
    public function initSubNavigation()
    {
        parent::initSubNavigation();

        if (!$GLOBALS['perm']->have_perm('admin') && Config::get()->SCHEDULE_ENABLE) {
            $navigation = new Navigation(_('Stundenplan'), 'dispatch.php/calendar/schedule/index');
            $this->addSubNavigation('schedule', $navigation);
        }

        if (Config::get()->CALENDAR_ENABLE) {
            $navigation = new Navigation(_('Kalender'), 'dispatch.php/calendar/calendar', ['defaultDate' => date('Y-m-d')]);
            $this->addSubNavigation('calendar', $navigation);
        }
    }
}