aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Models/Studip.php
blob: 7f54da81fa327ffc655844d8ae6477a1662651a8 (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

namespace JsonApi\Models;

class Studip
{
    public function getId()
    {
        return 'studip';
    }

    public function getProperties()
    {
        $oerCampusVisible =  $GLOBALS['perm']->have_perm(\Config::get()->OER_PUBLIC_STATUS);
        $properties = [
            new StudipProperty('studip-version', 'Stud.IP-Version', $GLOBALS['SOFTWARE_VERSION']),
            new StudipProperty('OERCAMPUS_VISIBLE', 'Is oer campus visible with current user permission?', $oerCampusVisible),
        ];

        $oerCampusEnabled = self::getConfigOption('OERCAMPUS_ENABLED');
        if ($oerCampusEnabled) {
            $properties[] = $oerCampusEnabled;
        }

        $oerEnableSuggestions = self::getConfigOption('OER_ENABLE_SUGGESTIONS');
        if ($oerEnableSuggestions) {
            $properties[] = $oerEnableSuggestions;
        }

        $copyrightDialog = self::getConfigOption('COPYRIGHT_DIALOG_ON_UPLOAD');
        if ($copyrightDialog) {
            $properties[] = $copyrightDialog;
        }

        return $properties;
    }

    private static function getConfigOption($field)
    {
        $config = \Config::get();

        if (!isset($config[$field])) {
            return null;
        }

        $description = $config->getMetadata($field)['description'];
        $value = $config->getValue($field);

        return new StudipProperty($field, $description, $value);
    }
}