aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/course/forum/configs.php
blob: a065a6a73e3dcc66a7aac8cdc2d2c20fbd55f9ae (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 Course_Forum_ConfigsController extends Forum\BaseController
{
    public function before_filter(&$action, &$args)
    {
        parent::before_filter($action, $args);

        if (!$this->user_id) {
            throw new LoginException();
        }

        if (! $this->is_admin) {
            throw new AccessDeniedException();
        }
    }

    public function edit_action()
    {
        $config = Context::get()->getConfiguration();

        $this->render_vue_app(
            Studip\VueApp::create('forum/configs/Edit')
                ->withProps([
                    'config' => [
                        'moderator' => $config->FORUM_MODERATION_PERMISSION,
                        'categories_navigation' => $config->FORUM_HIDE_CATEGORIES_NAVIGATION
                    ]
                ])
        );
    }

    public function save_action()
    {
        CSRFProtection::verifyUnsafeRequest();

        $config = Context::get()->getConfiguration();

        $config->store('FORUM_MODERATION_PERMISSION', trim(Request::option('moderator')));

        $config->store('FORUM_HIDE_CATEGORIES_NAVIGATION', Request::bool('categories_navigation'));

        PageLayout::postSuccess(_('Die Einstellungen wurden gespeichert.'));

        $this->relocate('course/forum/topics');
    }
}