Completed
Push — master ( 1d1df5...87b1fe )
by Jesus
07:01
created

config::defaultvalues()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 30
nc 1
nop 0
dl 0
loc 33
rs 8.8571
c 0
b 0
f 0
1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17
/**
18
 * The mod_bigbluebuttonbn locallib/config.
19
 *
20
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
21
 * @copyright 2017 - present Blindside Networks Inc
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
23
 */
24
25
namespace mod_bigbluebuttonbn\locallib;
26
27
defined('MOODLE_INTERNAL') || die();
28
29
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php');
30
31
class config {
32
33
    /**
34
     * @return string
35
     */
36
    public static function get_moodle_version_major() {
37
        global $CFG;
38
39
        $versionarray = explode('.', $CFG->version);
40
41
        return $versionarray[0];
42
    }
43
44
45
    /**
46
     * @return array
47
     */
48
    public static function defaultvalues() {
49
        return array(
50
            'server_url' => (string) BIGBLUEBUTTONBN_DEFAULT_SERVER_URL,
51
            'server_url' => (string) BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET,
52
            'importrecordings_enabled' => 'false',
53
            'voicebridge_editable' => 'false',
54
            'recording_default' => 'true',
55
            'recording_editable' => 'true',
56
            'recording_icons_enabled' => 'true',
57
            'importrecordings_enabled' => 'false',
58
            'importrecordings_from_deleted_activities_enabled' => 'false',
59
            'waitformoderator_default' => 'false',
60
            'waitformoderator_editable' => 'true',
61
            'waitformoderator_ping_interval' => '10',
62
            'waitformoderator_cache_ttl' => '60',
63
            'userlimit_default' => '0',
64
            'userlimit_editable' => 'false',
65
            'preuploadpresentation_enabled' => 'false',
66
            'sendnotifications_enabled' => 'false',
67
            'recordingready_enabled' => 'false',
68
            'recordingstatus_enabled' => 'false',
69
            'meetingevents_enabled' => 'false',
70
            'moderator_default' => 'owner',
71
            'scheduled_duration_enabled' => 'false',
72
            'scheduled_duration_compensation' => '10',
73
            'scheduled_pre_opening' => '10',
74
            'recordings_html_default' => 'false',
75
            'recordings_html_editable' => 'false',
76
            'recordings_deleted_activities_default' => 'false',
77
            'recordings_deleted_activities_editable' => 'false'
78
79
        );
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public static function defaultvalue($setting) {
86
        $defaultvalues = self::defaultvalues();
87
        if (!array_key_exists($setting, $defaultvalues)) {
88
            return;
89
        }
90
91
        return $defaultvalues[$setting];
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public static function get($setting) {
98
        global $CFG;
99
100
        if (isset($CFG->bigbluebuttonbn[$setting])) {
101
            return (string) $CFG->bigbluebuttonbn[$setting];
102
        }
103
104
        if (isset($CFG->{'bigbluebuttonbn_'.$setting})) {
105
            return (string)$CFG->{'bigbluebuttonbn_'.$setting};
106
        }
107
108
        return  self::defaultvalue($setting);
109
    }
110
111
    /**
112
     * @return boolean
113
     */
114
    public static function recordings_enabled() {
115
        global $CFG;
116
117
        return !(isset($CFG->bigbluebuttonbn['recording_default)']) &&
118
                 isset($CFG->bigbluebuttonbn['recording_editable']));
119
    }
120
121
     /**
122
      * @return array
123
      */
124
    public static function get_options() {
125
        return [
126
               'version_major' => self::get_moodle_version_major(),
127
               'voicebridge_editable' => self::get('voicebridge_editable'),
128
               'recording_default' => self::get('recording_default'),
129
               'recording_editable' => self::get('recording_editable'),
130
               'waitformoderator_default' => self::get('waitformoderator_default'),
131
               'waitformoderator_editable' => self::get('waitformoderator_editable'),
132
               'userlimit_default' => self::get('userlimit_default'),
133
               'userlimit_editable' => self::get('userlimit_editable'),
134
               'preuploadpresentation_enabled' => self::get('preuploadpresentation_enabled'),
135
               'sendnotifications_enabled' => self::get('sendnotifications_enabled'),
136
               'recordings_html_default' => self::get('recordings_html_default'),
137
               'recordings_html_editable' => self::get('recordings_html_editable'),
138
               'recordings_deleted_activities_default' => self::get('recordings_deleted_activities_default'),
139
               'recordings_deleted_activities_editable' => self::get('recordings_deleted_activities_editable'),
140
               'recording_icons_enabled' => self::get('recording_icons_enabled'),
141
               'instance_type_enabled' => self::recordings_enabled(),
142
               'instance_type_default' => BIGBLUEBUTTONBN_TYPE_ALL,
143
          ];
144
    }
145
}
146