aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/activityfeed.php
blob: 1ea00a06db1fb88e688728ca2b7e79b57270558e (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
90
91
92
93
94
95
<?php

use \Studip\Activity\ActivityProvider;

class ActivityfeedController extends AuthenticatedController
{
    public function save_action()
    {
        if (Config::get()->ACTIVITY_FEED === NULL) {
            Config::get()->create('ACTIVITY_FEED', [
                'range' => 'user',
                'type' => 'array',
                'description' => 'Einstellungen des Activity-Widgets']
            );
        }

        $provider = Request::getArray('provider');

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

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

        $this->render_json($provider);
    }

    /**
     * return a list for all providers for every context
     *
     * @return array
     */
    private function getAllModules()
    {
        $modules = [];

        $modules['system'] = [
            'news'         => _('Ankündigungen'),
            'blubber'      => _('Blubber')
        ];

        $modules[Context::COURSE] = [
            'forum'        => _('Forum'),
            'participants' => _('Teilnehmende'),
            'documents'    => _('Dateien'),
            'wiki'         => _('Wiki'),
            'schedule'     => _('Ablaufplan'),
            'news'         => _('Ankündigungen'),
            'blubber'      => _('Blubber'),
            'courseware'   => _('Courseware')
        ];

        $modules[Context::INSTITUTE] = $modules[Context::COURSE];
        unset($modules[Context::INSTITUTE]['participants']);
        unset($modules[Context::INSTITUTE]['schedule']);

        $standard_plugins = PluginManager::getInstance()->getPlugins("StandardPlugin");
        foreach ($standard_plugins as $plugin) {
            if ($plugin instanceof ActivityProvider) {
                $modules[Context::COURSE][$plugin->getPluginName()] = $plugin->getPluginName();
                $modules[Context::INSTITUTE][$plugin->getPluginName()] = $plugin->getPluginName();
            }
        }

        $modules[Context::USER] = [
            'message'      => _('Nachrichten'),
            'news'         => _('Ankündigungen'),
            'blubber'      => _('Blubber'),
        ];

        $homepage_plugins = PluginEngine::getPlugins('HomepagePlugin');
        foreach ($homepage_plugins as $plugin) {
            if ($plugin->isActivated($GLOBALS['user']->id, 'user')) {
                if ($plugin instanceof ActivityProvider) {
                    $modules[Context::USER][] = $plugin;
                }
            }
        }

        return $modules;
    }

    public function configuration_action()
    {
        $this->config = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'ACTIVITY_FEED');
        $this->modules = $this->getAllModules();
        $this->context_translations = [
            Context::COURSE    => _('Veranstaltungen'),
            Context::INSTITUTE => _('Einrichtungen'),
            Context::USER      => _('Persönlich'),
            'system'            => _('Global')
        ];

        PageLayout::setTitle(_('Aktivitäten konfigurieren'));
    }
}