Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
 * Tiny text editor recordrtc plugin upgrade script.
19
 *
20
 * @package    tiny_recordrtc
21
 * @copyright  2024 The Open University
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/**
26
 * Run all Tiny recordrtc upgrade steps between the current DB version and the current version on disk.
27
 * @param int $oldversion The old version of the plugin in the DB.
28
 * @return bool
29
 */
30
function xmldb_tiny_recordrtc_upgrade($oldversion) {
31
    if ($oldversion < 2024042400) {
32
        // Convert the old setting to the new one.
33
        $allowedtypes = get_config('tiny_recordrtc', 'allowedtypes');
34
        if ($allowedtypes === 'both') {
35
            set_config(
36
                'allowedtypes',
37
                implode(',', [
38
                    tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_TYPE,
39
                    tiny_recordrtc\constants::TINYRECORDRTC_VIDEO_TYPE,
40
                ]),
41
                'tiny_recordrtc'
42
            );
43
        }
44
 
45
        upgrade_plugin_savepoint(true, 2024042400, 'tiny', 'recordrtc');
46
    }
47
 
48
    // Automatically generated Moodle v4.5.0 release upgrade line.
49
    // Put any upgrade step following this.
50
 
51
    if ($oldversion < 2024112000) {
52
        // The input bitrate to be converted.
53
        $currentbitrate = get_config('tiny_recordrtc', 'audiobitrate');
54
 
55
        // Supported bitrates.
56
        $supportedbitrates = \tiny_recordrtc\constants::TINYRECORDRTC_AUDIO_BITRATES;
57
 
58
        // Find the nearest value.
59
        usort($supportedbitrates, fn($a, $b) => abs($currentbitrate - $a) <=> abs($currentbitrate - $b));
60
        $nearestbitrate = $supportedbitrates[0];
61
 
62
        // Update the bitrate setting with the nearest supported bitrate.
63
        set_config('audiobitrate', $nearestbitrate, 'tiny_recordrtc');
64
 
65
        upgrade_plugin_savepoint(true, 2024112000, 'tiny', 'recordrtc');
66
    }
67
 
68
    // Automatically generated Moodle v5.0.0 release upgrade line.
69
    // Put any upgrade step following this.
70
 
71
    return true;
72
}