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 = [
|
|
|
48 |
'both' => new lang_string('audioandvideo', 'tiny_recordrtc'),
|
|
|
49 |
'audio' => new lang_string('onlyaudio', 'tiny_recordrtc'),
|
|
|
50 |
'video' => new lang_string('onlyvideo', 'tiny_recordrtc')
|
|
|
51 |
];
|
|
|
52 |
$name = get_string('allowedtypes', 'tiny_recordrtc');
|
|
|
53 |
$desc = get_string('allowedtypes_desc', 'tiny_recordrtc');
|
|
|
54 |
$default = 'both';
|
|
|
55 |
$setting = new admin_setting_configselect('tiny_recordrtc/allowedtypes', $name, $desc, $default, $options);
|
|
|
56 |
$settings->add($setting);
|
|
|
57 |
|
|
|
58 |
// Audio bitrate.
|
|
|
59 |
$name = get_string('audiobitrate', 'tiny_recordrtc');
|
|
|
60 |
$desc = get_string('audiobitrate_desc', 'tiny_recordrtc');
|
|
|
61 |
$default = '128000';
|
|
|
62 |
$setting = new admin_setting_configtext('tiny_recordrtc/audiobitrate', $name, $desc, $default, PARAM_INT, 8);
|
|
|
63 |
$settings->add($setting);
|
|
|
64 |
|
|
|
65 |
// Video bitrate.
|
|
|
66 |
$name = get_string('videobitrate', 'tiny_recordrtc');
|
|
|
67 |
$desc = get_string('videobitrate_desc', 'tiny_recordrtc');
|
|
|
68 |
$default = '2500000';
|
|
|
69 |
$setting = new admin_setting_configtext('tiny_recordrtc/videobitrate', $name, $desc, $default, PARAM_INT, 8);
|
|
|
70 |
$settings->add($setting);
|
|
|
71 |
|
|
|
72 |
// Audio recording time limit.
|
|
|
73 |
$name = get_string('audiotimelimit', 'tiny_recordrtc');
|
|
|
74 |
$desc = get_string('audiotimelimit_desc', 'tiny_recordrtc');
|
|
|
75 |
// Validate audiotimelimit greater than 0.
|
|
|
76 |
$setting = new admin_setting_configduration('tiny_recordrtc/audiotimelimit', $name, $desc, $defaulttimelimit);
|
|
|
77 |
$setting->set_validate_function(function(int $value): string {
|
|
|
78 |
if ($value <= 0) {
|
|
|
79 |
return get_string('timelimitwarning', 'tiny_recordrtc');
|
|
|
80 |
}
|
|
|
81 |
return '';
|
|
|
82 |
});
|
|
|
83 |
$settings->add($setting);
|
|
|
84 |
|
|
|
85 |
// Video recording time limit.
|
|
|
86 |
$name = get_string('videotimelimit', 'tiny_recordrtc');
|
|
|
87 |
$desc = get_string('videotimelimit_desc', 'tiny_recordrtc');
|
|
|
88 |
// Validate videotimelimit greater than 0.
|
|
|
89 |
$setting = new admin_setting_configduration('tiny_recordrtc/videotimelimit', $name, $desc, $defaulttimelimit);
|
|
|
90 |
$setting->set_validate_function(function(int $value): string {
|
|
|
91 |
if ($value <= 0) {
|
|
|
92 |
return get_string('timelimitwarning', 'tiny_recordrtc');
|
|
|
93 |
}
|
|
|
94 |
return '';
|
|
|
95 |
});
|
|
|
96 |
$settings->add($setting);
|
|
|
97 |
}
|