MDL-65606 mod_data: Add approvalstatusclass to template
[moodle.git] / mod / data / db / upgrade.php
CommitLineData
1adbd2c3 1<?php
aab98aaf 2// This file keeps track of upgrades to
b8a342d7 3// the data module
4//
5// Sometimes, changes between versions involve
6// alterations to database structures and other
7// major things that may break installations.
8//
9// The upgrade function in this file will attempt
10// to perform all the necessary actions to upgrade
2e0406a5 11// your older installation to the current version.
b8a342d7 12//
13// If there's something it cannot do itself, it
14// will tell you what you need to do.
15//
16// The commands in here will all be database-neutral,
b1f93b15 17// using the methods of database_manager class
775f811a 18//
19// Please do not forget to use upgrade_set_timeout()
20// before any action that may take longer time to finish.
b8a342d7 21
e8c82aac
EL
22defined('MOODLE_INTERNAL') || die();
23
775f811a 24function xmldb_data_upgrade($oldversion) {
e8c82aac 25 global $CFG, $DB;
b8a342d7 26
f33e1ed4 27 $dbman = $DB->get_manager();
25322ba3 28
f9729dcf
MG
29 if ($oldversion < 2017032800) {
30
31 // Define field completionentries to be added to data. Require a number of entries to be considered complete.
32 $table = new xmldb_table('data');
6d353d2d 33 $field = new xmldb_field('completionentries', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'config');
f9729dcf
MG
34
35 // Conditionally launch add field timemodified.
36 if (!$dbman->field_exists($table, $field)) {
37 $dbman->add_field($table, $field);
38 }
39
40 // Data savepoint reached.
41 upgrade_mod_savepoint(true, 2017032800, 'data');
42 }
43
5e272283
EL
44 // Automatically generated Moodle v3.3.0 release upgrade line.
45 // Put any upgrade step following this.
46
6499085f
EL
47 // Automatically generated Moodle v3.4.0 release upgrade line.
48 // Put any upgrade step following this.
49
00977e98
EL
50 // Automatically generated Moodle v3.5.0 release upgrade line.
51 // Put any upgrade step following this.
52
f47c8f35
EL
53 // Automatically generated Moodle v3.6.0 release upgrade line.
54 // Put any upgrade step following this.
55
3572a25c
EL
56 // Automatically generated Moodle v3.7.0 release upgrade line.
57 // Put any upgrade step following this.
58
2ddd7605
MM
59 if ($oldversion < 2019052001) {
60
61 $columns = $DB->get_columns('data');
62
63 $oldclass = "mod-data-default-template ##approvalstatus##";
64 $newclass = "mod-data-default-template ##approvalstatusclass##";
65
66 // Update existing classes.
67 $DB->replace_all_text('data', $columns['singletemplate'], $oldclass, $newclass);
68 $DB->replace_all_text('data', $columns['listtemplate'], $oldclass, $newclass);
69 $DB->replace_all_text('data', $columns['addtemplate'], $oldclass, $newclass);
70 $DB->replace_all_text('data', $columns['rsstemplate'], $oldclass, $newclass);
71 $DB->replace_all_text('data', $columns['asearchtemplate'], $oldclass, $newclass);
72
73 // Data savepoint reached.
74 upgrade_mod_savepoint(true, 2019052001, 'data');
75 }
a4cdd6d2 76 return true;
b8a342d7 77}