Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 topic teaser.
19
 *
20
 * @package     unilabeltype_topicteaser
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_topicteaser_upgrade($oldversion) {
34
    global $CFG, $DB;
35
 
36
    $dbman = $DB->get_manager();
37
 
38
    if ($oldversion < 2018081800) {
39
        // Define field clickaction to be added to unilabeltype_topicteaser.
40
        $table = new xmldb_table('unilabeltype_topicteaser');
41
        $field = new xmldb_field('clickaction', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'presentation');
42
 
43
        // Conditionally launch add field clickaction.
44
        if (!$dbman->field_exists($table, $field)) {
45
            $dbman->add_field($table, $field);
46
        }
47
 
48
        // Topicteaser savepoint reached.
49
        upgrade_plugin_savepoint(true, 2018081800, 'unilabeltype', 'topicteaser');
50
    }
51
 
52
    if ($oldversion < 2018090201) {
53
        // Define field showcoursetitle to be added to unilabeltype_topicteaser.
54
        $table = new xmldb_table('unilabeltype_topicteaser');
55
        $field = new xmldb_field('showcoursetitle', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'showintro');
56
 
57
        // Conditionally launch add field showcoursetitle.
58
        if (!$dbman->field_exists($table, $field)) {
59
            $dbman->add_field($table, $field);
60
        }
61
 
62
        // Topicteaser savepoint reached.
63
        upgrade_plugin_savepoint(true, 2018090201, 'unilabeltype', 'topicteaser');
64
    }
65
 
66
    if ($oldversion < 2019030700) {
67
        // Define field columns to be added to unilabeltype_topicteaser.
68
        $table = new xmldb_table('unilabeltype_topicteaser');
69
        $field = new xmldb_field('columns', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'presentation');
70
 
71
        // Conditionally launch add field columns.
72
        if (!$dbman->field_exists($table, $field)) {
73
            $dbman->add_field($table, $field);
74
        }
75
 
76
        // Topicteaser savepoint reached.
77
        upgrade_plugin_savepoint(true, 2019030700, 'unilabeltype', 'topicteaser');
78
    }
79
 
80
    if ($oldversion < 2019050900) {
81
        // Define field carouselinterval to be added to unilabeltype_topicteaser.
82
        $table = new xmldb_table('unilabeltype_topicteaser');
83
        $field = new xmldb_field('carouselinterval', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columns');
84
 
85
        // Conditionally launch add field carouselinterval.
86
        if (!$dbman->field_exists($table, $field)) {
87
            $dbman->add_field($table, $field);
88
        }
89
 
90
        // Add the default carouselinterval to the instances.
91
        $cfg = get_config('unilabeltype_topicteaser');
92
 
93
        if ($records = $DB->get_records('unilabeltype_topicteaser', null)) {
94
            foreach ($records as $r) {
95
                $r->carouselinterval = $cfg->carouselinterval;
96
                $DB->update_record('unilabeltype_topicteaser', $r);
97
            }
98
        }
99
 
100
        // Topicteaser savepoint reached.
101
        upgrade_plugin_savepoint(true, 2019050900, 'unilabeltype', 'topicteaser');
102
    }
103
 
104
    if ($oldversion < 2020022900) {
105
        // Define field columnsmiddle to be added to unilabeltype_topicteaser.
106
        $table = new xmldb_table('unilabeltype_topicteaser');
107
        $field = new xmldb_field('columnsmiddle', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columns');
108
 
109
        // Conditionally launch add field columnsmiddle.
110
        if (!$dbman->field_exists($table, $field)) {
111
            $dbman->add_field($table, $field);
112
        }
113
 
114
        // Define field columnssmall to be added to unilabeltype_topicteaser.
115
        $table = new xmldb_table('unilabeltype_topicteaser');
116
        $field = new xmldb_field('columnssmall', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'columnsmiddle');
117
 
118
        // Conditionally launch add field columnssmall.
119
        if (!$dbman->field_exists($table, $field)) {
120
            $dbman->add_field($table, $field);
121
        }
122
 
123
        // Grid savepoint reached.
124
        upgrade_plugin_savepoint(true, 2020022900, 'unilabeltype', 'topicteaser');
125
    }
126
 
127
    return true;
128
}