-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrade.php
106 lines (89 loc) · 4.64 KB
/
upgrade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Upgrade script for tool_opensesame.
*
* @package tool_opensesame
* @copyright 2023 Felicia Wilkes <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Upgrade the plugin.
*
* @param int $oldversion
* @return bool always true
*/
function xmldb_tool_opensesame_upgrade(int $oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2023011115) {
// Define table tool_opensesame to be created.
$table = new xmldb_table('tool_opensesame');
// Adding fields to table tool_opensesame.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('provider', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, 'OpenSesame');
$table->add_field('idopensesame', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'Default Title');
$table->add_field('descriptiontext', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
$table->add_field('thumbnailurl', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('duration', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, '000000');
$table->add_field('languages', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
$table->add_field('oscategories', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('publishername', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('packagedownloadurl', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('aicclaunchurl', XMLDB_TYPE_TEXT, null, null, null, null, null);
// Adding keys to table tool_opensesame.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
$table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
// Conditionally launch create table for tool_opensesame.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Opensesame savepoint reached.
upgrade_plugin_savepoint(true, 2023011115, 'tool', 'opensesame');
}
if ($oldversion < 2023011116) {
// Define field active to be added to tool_opensesame.
$table = new xmldb_table('tool_opensesame');
$field = new xmldb_field('active', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, '0', 'aicclaunchurl');
// Conditionally launch add field active.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Changing type of field idopensesame on table tool_opensesame to char.
$table = new xmldb_table('tool_opensesame');
$field = new xmldb_field('idopensesame', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, '0', 'provider');
// Launch change of type for field idopensesame.
$dbman->change_field_type($table, $field);
// Opensesame savepoint reached.
upgrade_plugin_savepoint(true, 2023011116, 'tool', 'opensesame');
}
if ($oldversion < 2023013100) {
// Define field courseid to be added to tool_opensesame.
$table = new xmldb_table('tool_opensesame');
$field = new xmldb_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'active');
// Conditionally launch add field courseid.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Opensesame savepoint reached.
upgrade_plugin_savepoint(true, 2023013100, 'tool', 'opensesame');
}
return true;
}