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 |
* Upgrades for coursesize
|
|
|
19 |
*
|
|
|
20 |
* @package report_coursesize
|
|
|
21 |
* @copyright 2022 Catalyst IT
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Upgrade coursesize plugin.
|
|
|
27 |
*
|
|
|
28 |
* @param int $oldversion
|
|
|
29 |
* @return boolean
|
|
|
30 |
*/
|
|
|
31 |
function xmldb_report_coursesize_upgrade($oldversion) {
|
|
|
32 |
global $DB;
|
|
|
33 |
$dbman = $DB->get_manager();
|
|
|
34 |
|
|
|
35 |
if ($oldversion < 2021030802) {
|
|
|
36 |
// Define table report_coursesize to be created.
|
|
|
37 |
$table = new xmldb_table('report_coursesize');
|
|
|
38 |
|
|
|
39 |
// Adding fields to table report_coursesize.
|
|
|
40 |
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
|
41 |
$table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
42 |
$table->add_field('filesize', XMLDB_TYPE_INTEGER, '15', null, XMLDB_NOTNULL, null, null);
|
|
|
43 |
$table->add_field('backupsize', XMLDB_TYPE_INTEGER, '15', null, null, null, null);
|
|
|
44 |
|
|
|
45 |
// Adding keys to table report_coursesize.
|
|
|
46 |
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
|
|
47 |
|
|
|
48 |
// Adding indexes to table report_coursesize.
|
|
|
49 |
$table->add_index('course', XMLDB_INDEX_NOTUNIQUE, ['course']);
|
|
|
50 |
|
|
|
51 |
// Conditionally launch create table for report_coursesize.
|
|
|
52 |
if (!$dbman->table_exists($table)) {
|
|
|
53 |
$dbman->create_table($table);
|
|
|
54 |
} else {
|
|
|
55 |
// Throw warning - some old unsupported branches use a similar table that is not compatible with this version,
|
|
|
56 |
// these must be cleaned up manually.
|
|
|
57 |
print_error("Cannot upgrade this old coursereport plugin - you should check/delete the old table before upgrading to this release.");
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
// Coursesize savepoint reached.
|
|
|
61 |
upgrade_plugin_savepoint(true, 2021030802, 'report', 'coursesize');
|
|
|
62 |
}
|
|
|
63 |
return true;
|
|
|
64 |
}
|