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
 * This file keeps track of upgrades to the unilabeltype_imageboard
19
 *
20
 * Sometimes, changes between versions involve alterations to database
21
 * structures and other major things that may break installations. The upgrade
22
 * function in this file will attempt to perform all the necessary actions to
23
 * upgrade your older installation to the current version. If there's something
24
 * it cannot do itself, it will tell you what you need to do.  The commands in
25
 * here will all be database-neutral, using the functions defined in DLL libraries.
26
 *
27
 * @package     unilabeltype_imageboard
28
 * @author      Andreas Schenkel
29
 * @copyright   Andreas Schenkel {@link https://github.com/andreasschenkel}
30
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
32
 
33
defined('MOODLE_INTERNAL') || die(); // @codingStandardsIgnoreLine
34
 
35
/**
36
 * Execute unilabelimageboard upgrade from the given old version.
37
 *
38
 * @param int $oldversion
39
 * @return bool
40
 */
41
function xmldb_unilabeltype_imageboard_upgrade($oldversion) {
42
    global $DB;
43
 
44
    $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
45
 
46
    // An upgrade begins here. For each one, you'll need one
47
    // block of code similar to the next one. Please, delete
48
    // this comment lines once this file start handling proper
49
    // upgrade code.
50
 
51
    // First example, some fields were added to install.xml on 2007/04/01.
52
 
53
    if ($oldversion < 2023080100) {
54
        // Define field border to be added to unilabeltype_imageboard.
55
        $table = new xmldb_table('unilabeltype_imageboard_img');
56
        $field = new xmldb_field('border', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'targetheight');
57
 
58
        // Conditionally launch add field border.
59
        if (!$dbman->field_exists($table, $field)) {
60
            $dbman->add_field($table, $field);
61
        }
62
        upgrade_plugin_savepoint(true, 2023080100, 'unilabeltype', 'imageboard');
63
    }
64
    if ($oldversion < 2023092400) {
65
        // Define field fontsize to be added to unilabeltype_imageboard.
66
        $table = new xmldb_table('unilabeltype_imageboard');
67
        $field = new xmldb_field('fontsize', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'canvasheight');
68
 
69
        // Conditionally launch add field fontsize.
70
        if (!$dbman->field_exists($table, $field)) {
71
            $dbman->add_field($table, $field);
72
        }
73
        upgrade_plugin_savepoint(true, 2023092400, 'unilabeltype', 'imageboard');
74
    }
75
    if ($oldversion < 2023092501) {
76
        // Define field titlebackgroundcolor to be added to unilabeltype_imageboard.
77
        $table = new xmldb_table('unilabeltype_imageboard');
78
        $field = new xmldb_field('titlebackgroundcolor', XMLDB_TYPE_CHAR, '255', null, null, null, '0', 'fontsize');
79
 
80
        // Conditionally launch add field titlebackgroundcolor.
81
        if (!$dbman->field_exists($table, $field)) {
82
            $dbman->add_field($table, $field);
83
        }
84
        upgrade_plugin_savepoint(true, 2023092501, 'unilabeltype', 'imageboard');
85
    }
86
 
87
    if ($oldversion < 2023101200) {
88
 
89
        // Define table unilabeltype_imageboard_img to be renamed to NEWNAMEGOESHERE.
90
        $table = new xmldb_table('unilabeltype_imageboard_tile');
91
 
92
        // Launch rename table for unilabeltype_imageboard_img.
93
        $dbman->rename_table($table, 'unilabeltype_imageboard_img');
94
 
95
        // Imageboard savepoint reached.
96
        upgrade_plugin_savepoint(true, 2023101200, 'unilabeltype', 'imageboard');
97
    }
98
 
99
    if ($oldversion < 2023102900) {
100
 
101
        // Define field autoscale to be added to unilabeltype_imageboard.
102
        $table = new xmldb_table('unilabeltype_imageboard');
103
        $field = new xmldb_field('autoscale', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'titlebackgroundcolor');
104
 
105
        // Conditionally launch add field autoscale.
106
        if (!$dbman->field_exists($table, $field)) {
107
            $dbman->add_field($table, $field);
108
        }
109
 
110
        // Imageboard savepoint reached.
111
        upgrade_plugin_savepoint(true, 2023102900, 'unilabeltype', 'imageboard');
112
    }
113
 
114
    if ($oldversion < 2023102901) {
115
        // Define field titlecolor to be added to unilabeltype_imageboard.
116
        $table = new xmldb_table('unilabeltype_imageboard');
117
        $field = new xmldb_field('titlecolor', XMLDB_TYPE_CHAR, '255', null, null, null, '0', 'fontsize');
118
 
119
        // Conditionally launch add field titlecolor.
120
        if (!$dbman->field_exists($table, $field)) {
121
            $dbman->add_field($table, $field);
122
        }
123
        upgrade_plugin_savepoint(true, 2023102901, 'unilabeltype', 'imageboard');
124
    }
125
 
126
    if ($oldversion < 2024012400) {
127
 
128
        // Define field sortorder to be added to unilabeltype_imageboard_img.
129
        $table = new xmldb_table('unilabeltype_imageboard_img');
130
        $field = new xmldb_field('newwindow', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'url');
131
 
132
        // Conditionally launch add field newwindow.
133
        if (!$dbman->field_exists($table, $field)) {
134
            $dbman->add_field($table, $field);
135
        }
136
 
137
        // Grid savepoint reached.
138
        upgrade_plugin_savepoint(true, 2024012400, 'unilabeltype', 'imageboard');
139
    }
140
 
141
    return true;
142
}