Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Settings that allow turning on and off recordrtc features
19
 *
20
 * @package    tiny_recordrtc
21
 * @copyright  2022, Stevani Andolo <stevani@hotmail.com.au>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
// Needed for constants.
28
require_once($CFG->dirroot . '/lib/editor/tiny/plugins/recordrtc/classes/plugininfo.php');
29
 
30
$ADMIN->add('editortiny', new admin_category('tiny_recordrtc', new lang_string('pluginname', 'tiny_recordrtc')));
31
 
32
if ($ADMIN->fulltree) {
33
    $defaulttimelimit = 120;
34
 
35
    $url = parse_url($CFG->wwwroot);
36
    $hostname = parse_url($CFG->wwwroot, PHP_URL_HOST);
37
    $isvalid = in_array($hostname, ['localhost', '127.0.0.1', '::1']);
38
    $isvalid = $isvalid || preg_match("/^.*\.localhost$/", $hostname);
39
 
40
    if (!$isvalid && $url['scheme'] !== 'https') {
41
        $warning = html_writer::div(get_string('insecurealert', 'tiny_recordrtc'), 'box py-3 generalbox alert alert-danger');
42
        $setting = new admin_setting_description('tiny_recordrtc/warning', null, $warning);
43
        $settings->add($setting);
44
    }
45
 
46
    // Types allowed.
47
    $options = [
1441 ariadna 48
        \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_TYPE => new lang_string('onlyaudio', 'tiny_recordrtc'),
49
        \tiny_recordrtc\constants::TINYRECORDRTC_VIDEO_TYPE => new lang_string('onlyvideo', 'tiny_recordrtc'),
50
        \tiny_recordrtc\constants::TINYRECORDRTC_SCREEN_TYPE => new lang_string('onlyscreen', 'tiny_recordrtc'),
1 efrain 51
    ];
52
    $name = get_string('allowedtypes', 'tiny_recordrtc');
53
    $desc = get_string('allowedtypes_desc', 'tiny_recordrtc');
1441 ariadna 54
    $default = [
55
        \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_TYPE => 1,
56
        \tiny_recordrtc\constants::TINYRECORDRTC_VIDEO_TYPE => 1,
57
    ];
58
    $setting = new admin_setting_configmulticheckbox('tiny_recordrtc/allowedtypes', $name, $desc, $default, $options);
1 efrain 59
    $settings->add($setting);
60
 
61
    // Audio bitrate.
62
    $name = get_string('audiobitrate', 'tiny_recordrtc');
63
    $desc = get_string('audiobitrate_desc', 'tiny_recordrtc');
1441 ariadna 64
    $options = [];
65
    foreach (\tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES as $rate) {
66
        $kbrate = $rate / 1000;
67
        $options[$rate] = get_string('kbrate', 'tiny_recordrtc', $kbrate);
68
    }
69
    $setting = new admin_setting_configselect(
70
        name: 'tiny_recordrtc/audiobitrate',
71
        visiblename: $name,
72
        description: $desc,
73
        defaultsetting: \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES[5],
74
        choices: $options,
75
    );
1 efrain 76
    $settings->add($setting);
77
 
78
    // Video bitrate.
79
    $name = get_string('videobitrate', 'tiny_recordrtc');
80
    $desc = get_string('videobitrate_desc', 'tiny_recordrtc');
81
    $default = '2500000';
82
    $setting = new admin_setting_configtext('tiny_recordrtc/videobitrate', $name, $desc, $default, PARAM_INT, 8);
83
    $settings->add($setting);
84
 
1441 ariadna 85
    // Screen bitrate.
86
    $name = get_string('screenbitrate', 'tiny_recordrtc');
87
    $desc = get_string('screenbitrate_desc', 'tiny_recordrtc');
88
    $default = '2500000';
89
    $setting = new admin_setting_configtext('tiny_recordrtc/screenbitrate', $name, $desc, $default, PARAM_INT, 8);
90
    $settings->add($setting);
91
 
1 efrain 92
    // Audio recording time limit.
93
    $name = get_string('audiotimelimit', 'tiny_recordrtc');
94
    $desc = get_string('audiotimelimit_desc', 'tiny_recordrtc');
95
    // Validate audiotimelimit greater than 0.
96
    $setting = new admin_setting_configduration('tiny_recordrtc/audiotimelimit', $name, $desc, $defaulttimelimit);
97
    $setting->set_validate_function(function(int $value): string {
98
        if ($value <= 0) {
99
            return get_string('timelimitwarning', 'tiny_recordrtc');
100
        }
101
        return '';
102
    });
103
    $settings->add($setting);
104
 
105
    // Video recording time limit.
106
    $name = get_string('videotimelimit', 'tiny_recordrtc');
107
    $desc = get_string('videotimelimit_desc', 'tiny_recordrtc');
108
    // Validate videotimelimit greater than 0.
109
    $setting = new admin_setting_configduration('tiny_recordrtc/videotimelimit', $name, $desc, $defaulttimelimit);
110
    $setting->set_validate_function(function(int $value): string {
111
        if ($value <= 0) {
112
            return get_string('timelimitwarning', 'tiny_recordrtc');
113
        }
114
        return '';
115
    });
116
    $settings->add($setting);
1441 ariadna 117
 
118
    // Screen recording time limit.
119
    $name = get_string('screentimelimit', 'tiny_recordrtc');
120
    $desc = get_string('screentimelimit_desc', 'tiny_recordrtc');
121
    // Validate screentimelimit greater than 0.
122
    $setting = new admin_setting_configduration('tiny_recordrtc/screentimelimit', $name, $desc, $defaulttimelimit);
123
    $setting->set_validate_function(function(int $value): string {
124
        if ($value <= 0) {
125
            return get_string('timelimitwarning', 'tiny_recordrtc');
126
        }
127
        return '';
128
    });
129
    $settings->add($setting);
130
 
131
    // Screen output settings.
132
    // Number of items to display in a box.
133
    $options = [
134
        \tiny_recordrtc\constants::TINYRECORDRTC_SCREEN_HD => get_string('screenresolution_hd', 'tiny_recordrtc'),
135
        \tiny_recordrtc\constants::TINYRECORDRTC_SCREEN_FHD => get_string('screenresolution_fhd', 'tiny_recordrtc'),
136
    ];
137
    $name = get_string('screensize', 'tiny_recordrtc');
138
    $desc = get_string('screensize_desc', 'tiny_recordrtc');
139
    $default = '1280,720';
140
    $setting = new admin_setting_configselect('tiny_recordrtc/screensize', $name, $desc, $default, $options);
141
    $settings->add($setting);
142
 
143
    // Pausing allowed.
144
    $options = [
145
        '1' => new lang_string('yes'),
146
        '0' => new lang_string('no'),
147
    ];
148
 
149
    $name = get_string('allowedpausing', 'tiny_recordrtc');
150
    $setting = new admin_setting_configselect('tiny_recordrtc/allowedpausing', $name, '', 0, $options);
151
    $settings->add($setting);
152
 
153
    // Audio format selection.
154
    $audioformatoptions = [
155
        '0' => get_string('audiortcformatdefault', 'tiny_recordrtc'),
156
        '1' => get_string('audiortcformatmp3', 'tiny_recordrtc'),
157
    ];
158
    $setting = new admin_setting_configselect(
159
        name: 'tiny_recordrtc/audiortcformat',
160
        visiblename: get_string('audiortcformat', 'tiny_recordrtc'),
161
        description: '',
162
        defaultsetting: 0,
163
        choices: $audioformatoptions,
164
    );
165
    $settings->add($setting);
1 efrain 166
}