aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/quickselection.php
blob: 88d24f0c729b30ff925a0cce0c0cc24313830957 (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
<?php

class QuickselectionController extends AuthenticatedController
{
    public function save_action()
    {
        if (Config::get()->QUICK_SELECTION === null) {
            Config::get()->create('QUICK_SELECTION', [
                'range'       => 'user',
                'type'        => 'array',
                'description' => 'Einstellungen des QuickSelection-Widgets',
            ]);
        }

        $add_removes = Request::optionArray('add_removes');

        // invert add_removes so that only unchecked values are stored into config
        $names = [];

        $navigation = Navigation::getItem('/start');
        foreach ($navigation as $name => $nav) {
            if (!in_array($name, $add_removes)) {
                $names[$name] = 'deactivated';
            }

        }

        WidgetHelper::addWidgetUserConfig($GLOBALS['user']->id, 'QUICK_SELECTION', $names);

        $template = PluginEngine::getPlugin('QuickSelection')->getPortalTemplate();

        $this->response->add_header('X-Dialog-Close', 1);
        $this->response->add_header('X-Dialog-Execute', 'STUDIP.QuickSelection.update');

        $this->render_template($template);
    }

    public function configuration_action()
    {
        $this->links = Navigation::getItem('/start');
        $this->config = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'QUICK_SELECTION');

        PageLayout::setTitle(_('Schnellzugriff konfigurieren'));
    }
}