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
 * tool_dataprivacy plugin upgrade code
19
 *
20
 * @package    tool_dataprivacy
21
 * @copyright  2018 Jun Pataleta
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/**
26
 * Function to upgrade tool_dataprivacy.
27
 *
28
 * @param int $oldversion the version we are upgrading from
29
 * @return bool result
30
 */
31
function xmldb_tool_dataprivacy_upgrade($oldversion) {
32
    global $CFG, $DB;
33
 
34
    $dbman = $DB->get_manager();
35
 
36
    // Automatically generated Moodle v4.1.0 release upgrade line.
37
    // Put any upgrade step following this.
38
 
39
    // Automatically generated Moodle v4.2.0 release upgrade line.
40
    // Put any upgrade step following this.
41
 
42
    if ($oldversion < 2023062700) {
43
        // Define table tool_dataprivacy_contextlist to be created.
44
        $table = new xmldb_table('tool_dataprivacy_contextlist');
45
 
46
        // Adding fields to table tool_dataprivacy_contextlist.
47
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
48
        $table->add_field('component', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
49
        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
50
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
51
 
52
        // Adding keys to table tool_dataprivacy_contextlist.
53
        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
54
 
55
        // Conditionally launch create table for tool_dataprivacy_contextlist.
56
        if (!$dbman->table_exists($table)) {
57
            $dbman->create_table($table);
58
        }
59
 
60
        // Define table tool_dataprivacy_ctxlst_ctx to be created.
61
        $table = new xmldb_table('tool_dataprivacy_ctxlst_ctx');
62
 
63
        // Adding fields to table tool_dataprivacy_ctxlst_ctx.
64
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
65
        $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
66
        $table->add_field('contextlistid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
67
        $table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
68
        $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
69
        $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
70
 
71
        // Adding keys to table tool_dataprivacy_ctxlst_ctx.
72
        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
73
        $table->add_key('contextlistid', XMLDB_KEY_FOREIGN, ['contextlistid'], 'tool_dataprivacy_contextlist', ['id']);
74
 
75
        // Conditionally launch create table for tool_dataprivacy_ctxlst_ctx.
76
        if (!$dbman->table_exists($table)) {
77
            $dbman->create_table($table);
78
        }
79
 
80
        // Define table tool_dataprivacy_rqst_ctxlst to be created.
81
        $table = new xmldb_table('tool_dataprivacy_rqst_ctxlst');
82
 
83
        // Adding fields to table tool_dataprivacy_rqst_ctxlst.
84
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
85
        $table->add_field('requestid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
86
        $table->add_field('contextlistid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
87
 
88
        // Adding keys to table tool_dataprivacy_rqst_ctxlst.
89
        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
90
        $table->add_key('requestid', XMLDB_KEY_FOREIGN, ['requestid'], 'tool_dataprivacy_request', ['id']);
91
        $table->add_key('contextlistid', XMLDB_KEY_FOREIGN, ['contextlistid'], 'tool_dataprivacy_contextlist', ['id']);
92
        $table->add_key('requestidcontextlistid', XMLDB_KEY_UNIQUE, ['requestid', 'contextlistid']);
93
 
94
        // Conditionally launch create table for tool_dataprivacy_rqst_ctxlst.
95
        if (!$dbman->table_exists($table)) {
96
            $dbman->create_table($table);
97
        }
98
 
99
        // Dataprivacy savepoint reached.
100
        upgrade_plugin_savepoint(true, 2023062700, 'tool', 'dataprivacy');
101
    }
102
 
103
    // Automatically generated Moodle v4.3.0 release upgrade line.
104
    // Put any upgrade step following this.
105
 
106
    // Automatically generated Moodle v4.4.0 release upgrade line.
107
    // Put any upgrade step following this.
108
 
109
    return true;
110
}