Completed
Pull Request — master (#39)
by Jesus
02:02
created

config   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 116
rs 10
c 2
b 0
f 0
wmc 9
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get_moodle_version_major() 0 5 1
B defaultvalues() 0 39 1
A defaultvalue() 0 7 2
A get() 0 10 3
A recordings_enabled() 0 3 1
B get_options() 0 26 1
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
        $versionarray = explode('.', $CFG->version);
39
        return $versionarray[0];
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public static function defaultvalues() {
46
        return array(
47
            'server_url' => (string) BIGBLUEBUTTONBN_DEFAULT_SERVER_URL,
48
            'shared_secret' => (string) BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET,
49
            'importrecordings_enabled' => 'false',
50
            'voicebridge_editable' => 'false',
51
            'importrecordings_enabled' => 'false',
52
            'importrecordings_from_deleted_enabled' => 'false',
53
            'waitformoderator_default' => 'false',
54
            'waitformoderator_editable' => 'true',
55
            'waitformoderator_ping_interval' => '10',
56
            'waitformoderator_cache_ttl' => '60',
57
            'userlimit_default' => '0',
58
            'userlimit_editable' => 'false',
59
            'preuploadpresentation_enabled' => 'false',
60
            'sendnotifications_enabled' => 'false',
61
            'recordingready_enabled' => 'false',
62
            'recordingstatus_enabled' => 'false',
63
            'meetingevents_enabled' => 'false',
64
            'participant_moderator_default' => 'owner',
65
            'scheduled_duration_enabled' => 'false',
66
            'scheduled_duration_compensation' => '10',
67
            'scheduled_pre_opening' => '10',
68
            'recordings_enabled' => true,
69
            'recordings_html_default' => 'false',
70
            'recordings_html_editable' => 'false',
71
            'recordings_deleted_default' => 'false',
72
            'recordings_deleted_editable' => 'false',
73
            'recordings_imported_default' => 'false',
74
            'recordings_imported_editable' => 'false',
75
            'recording_default' => 'true',
76
            'recording_editable' => 'true',
77
            'recording_icons_enabled' => 'true',
78
            'general_warning_message' => '',
79
            'general_warning_button_text' => '',
80
            'general_warning_button_href' => '',
81
            'general_warning_button_class' => '',
82
        );
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public static function defaultvalue($setting) {
89
        $defaultvalues = self::defaultvalues();
90
        if (!array_key_exists($setting, $defaultvalues)) {
91
            return;
92
        }
93
        return $defaultvalues[$setting];
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public static function get($setting) {
100
        global $CFG;
101
        if (isset($CFG->bigbluebuttonbn[$setting])) {
102
            return (string) $CFG->bigbluebuttonbn[$setting];
103
        }
104
        if (isset($CFG->{'bigbluebuttonbn_'.$setting})) {
105
            return (string)$CFG->{'bigbluebuttonbn_'.$setting};
106
        }
107
        return  self::defaultvalue($setting);
108
    }
109
110
    /**
111
     * @return boolean
112
     */
113
    public static function recordings_enabled() {
114
        return self::get('recordings_enabled');
115
    }
116
117
    /**
118
     * @return array
119
     */
120
    public static function get_options() {
121
        return [
122
               'version_major' => self::get_moodle_version_major(),
123
               'voicebridge_editable' => self::get('voicebridge_editable'),
124
               'waitformoderator_default' => self::get('waitformoderator_default'),
125
               'waitformoderator_editable' => self::get('waitformoderator_editable'),
126
               'userlimit_default' => self::get('userlimit_default'),
127
               'userlimit_editable' => self::get('userlimit_editable'),
128
               'preuploadpresentation_enabled' => self::get('preuploadpresentation_enabled'),
129
               'sendnotifications_enabled' => self::get('sendnotifications_enabled'),
130
               'recordings_enabled' => self::get('recordings_enabled'),
131
               'recordings_html_default' => self::get('recordings_html_default'),
132
               'recordings_html_editable' => self::get('recordings_html_editable'),
133
               'recordings_deleted_default' => self::get('recordings_deleted_default'),
134
               'recordings_deleted_editable' => self::get('recordings_deleted_editable'),
135
               'recordings_imported_default' => self::get('recordings_imported_default'),
136
               'recordings_imported_editable' => self::get('recordings_imported_editable'),
137
               'recording_default' => self::get('recording_default'),
138
               'recording_editable' => self::get('recording_editable'),
139
               'recording_icons_enabled' => self::get('recording_icons_enabled'),
140
               'general_warning_message' => self::get('general_warning_message'),
141
               'general_warning_button_text' => self::get('general_warning_button_text'),
142
               'general_warning_button_href' => self::get('general_warning_button_href'),
143
               'general_warning_button_class' => self::get('general_warning_button_class'),
144
          ];
145
    }
146
}
147