aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/my_studygroups.php
blob: 579d47ecc4ddbab1b8bc3d960f03fa6b76662659 (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
<?php
class MyStudygroupsController extends AuthenticatedController
{
    public function before_filter(&$action, &$args)
    {
        parent::before_filter($action, $args);

        if (!$GLOBALS['perm']->have_perm('root')) {
            Navigation::activateItem('/browse/my_studygroups/index');
        }
    }

    public function index_action()
    {
        PageLayout::setHelpKeyword('Basis.MeineStudiengruppen');
        PageLayout::setTitle(_('Meine Studiengruppen'));
        URLHelper::removeLinkParam('cid');

        $this->studygroups  = MyRealmModel::getStudygroups();
        $this->nav_elements = MyRealmModel::calc_single_navigation($this->studygroups);
        $this->set_sidebar();
    }

    public function set_sidebar()
    {
        if ($GLOBALS['user']->perms === 'user') {
            return;
        }

        $sidebar = Sidebar::Get();

        $actions = new ActionsWidget();
        $actions->addLink(
            _('Neue Studiengruppe anlegen'),
            URLHelper::getURL('dispatch.php/course/wizard', ['studygroup' => 1]),
            Icon::create('add')
        )->asDialog('size=auto');
        if (count($this->studygroups) > 0) {
            $actions->addLink(
                _('Farbgruppierung ändern'),
                URLHelper::getURL('dispatch.php/my_courses/groups/all/true'),
                Icon::create('group4')
            )->asDialog();
        }
        $sidebar->addWidget($actions);
    }
}