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 |
* unilabel type course teaser.
|
|
|
19 |
*
|
|
|
20 |
* @package unilabeltype_courseteaser
|
|
|
21 |
* @author Andreas Grabs <info@grabs-edv.de>
|
|
|
22 |
* @copyright 2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
* @param mixed $oldversion
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Upgrade hook for this plugin.
|
|
|
29 |
*
|
|
|
30 |
* @param int $oldversion
|
|
|
31 |
* @return bool
|
|
|
32 |
*/
|
|
|
33 |
function xmldb_unilabeltype_courseteaser_upgrade($oldversion) {
|
|
|
34 |
global $CFG, $DB;
|
|
|
35 |
|
|
|
36 |
$dbman = $DB->get_manager();
|
|
|
37 |
|
|
|
38 |
if ($oldversion < 2019030700) {
|
|
|
39 |
// Define field columns to be added to unilabeltype_courseteaser.
|
|
|
40 |
$table = new xmldb_table('unilabeltype_courseteaser');
|
|
|
41 |
$field = new xmldb_field('columns', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'presentation');
|
|
|
42 |
|
|
|
43 |
// Conditionally launch add field columns.
|
|
|
44 |
if (!$dbman->field_exists($table, $field)) {
|
|
|
45 |
$dbman->add_field($table, $field);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
// Courseteaser savepoint reached.
|
|
|
49 |
upgrade_plugin_savepoint(true, 2019030700, 'unilabeltype', 'courseteaser');
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
if ($oldversion < 2019050900) {
|
|
|
53 |
// Define field carouselinterval to be added to unilabeltype_courseteaser.
|
|
|
54 |
$table = new xmldb_table('unilabeltype_courseteaser');
|
|
|
55 |
$field = new xmldb_field('carouselinterval', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columns');
|
|
|
56 |
|
|
|
57 |
// Conditionally launch add field carouselinterval.
|
|
|
58 |
if (!$dbman->field_exists($table, $field)) {
|
|
|
59 |
$dbman->add_field($table, $field);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
// Add the default carouselinterval to the instances.
|
|
|
63 |
$cfg = get_config('unilabeltype_courseteaser');
|
|
|
64 |
|
|
|
65 |
if ($records = $DB->get_records('unilabeltype_courseteaser', null)) {
|
|
|
66 |
foreach ($records as $r) {
|
|
|
67 |
$r->carouselinterval = $cfg->carouselinterval;
|
|
|
68 |
$DB->update_record('unilabeltype_courseteaser', $r);
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
// Topicteaser savepoint reached.
|
|
|
73 |
upgrade_plugin_savepoint(true, 2019050900, 'unilabeltype', 'courseteaser');
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
if ($oldversion < 2020022900) {
|
|
|
77 |
// Define field columnsmiddle to be added to unilabeltype_courseteaser.
|
|
|
78 |
$table = new xmldb_table('unilabeltype_courseteaser');
|
|
|
79 |
$field = new xmldb_field('columnsmiddle', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columns');
|
|
|
80 |
|
|
|
81 |
// Conditionally launch add field columnsmiddle.
|
|
|
82 |
if (!$dbman->field_exists($table, $field)) {
|
|
|
83 |
$dbman->add_field($table, $field);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
// Define field columnssmall to be added to unilabeltype_courseteaser.
|
|
|
87 |
$table = new xmldb_table('unilabeltype_courseteaser');
|
|
|
88 |
$field = new xmldb_field('columnssmall', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columnsmiddle');
|
|
|
89 |
|
|
|
90 |
// Conditionally launch add field columnssmall.
|
|
|
91 |
if (!$dbman->field_exists($table, $field)) {
|
|
|
92 |
$dbman->add_field($table, $field);
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
// Grid savepoint reached.
|
|
|
96 |
upgrade_plugin_savepoint(true, 2020022900, 'unilabeltype', 'courseteaser');
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
return true;
|
|
|
100 |
}
|