Merge branch 'w18_MDL-39374_m26_folderlog' of git://github.com/skodak/moodle
[moodle.git] / mod / forum / db / upgrade.php
CommitLineData
1adbd2c3 1<?php
b8a342d7 2
8f685009 3// This file is part of Moodle - http://moodle.org/
b8a342d7 4//
8f685009
SH
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
b8a342d7 9//
8f685009
SH
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
b8a342d7 14//
8f685009
SH
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * This file keeps track of upgrades to
20 * the forum module
21 *
22 * Sometimes, changes between versions involve
23 * alterations to database structures and other
24 * major things that may break installations.
25 *
26 * The upgrade function in this file will attempt
27 * to perform all the necessary actions to upgrade
2e0406a5 28 * your older installation to the current version.
8f685009
SH
29 *
30 * If there's something it cannot do itself, it
31 * will tell you what you need to do.
32 *
33 * The commands in here will all be database-neutral,
34 * using the methods of database_manager class
35 *
36 * Please do not forget to use upgrade_set_timeout()
37 * before any action that may take longer time to finish.
38 *
39 * @package mod-forum
40 * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 */
b8a342d7 43
775f811a 44function xmldb_forum_upgrade($oldversion) {
9146b979 45 global $CFG, $DB, $OUTPUT;
b8a342d7 46
506522d5 47 $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
b8a342d7 48
506522d5
FM
49 // Moodle v2.2.0 release upgrade line.
50 // Put any upgrade step following this.
c5a8abfe 51
506522d5
FM
52 // Moodle v2.3.0 release upgrade line.
53 // Put any upgrade step following this.
46f2a936 54
506522d5
FM
55 // Moodle v2.4.0 release upgrade line.
56 // Put any upgrade step following this.
99c3c503 57
506522d5
FM
58 // Moodle v2.5.0 release upgrade line.
59 // Put any upgrade step following this.
60 if ($oldversion < 2013020500) {
99c3c503 61
506522d5
FM
62 // Define field displaywordcount to be added to forum.
63 $table = new xmldb_table('forum');
64 $field = new xmldb_field('displaywordcount', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionposts');
6b9dfe73 65
506522d5
FM
66 // Conditionally launch add field displaywordcount.
67 if (!$dbman->field_exists($table, $field)) {
68 $dbman->add_field($table, $field);
69 }
70
71 // Forum savepoint reached.
72 upgrade_mod_savepoint(true, 2013020500, 'forum');
73 }
6b9dfe73 74
afd5e85c
RT
75 // Forcefully assign mod/forum:allowforcesubscribe to frontpage role, as we missed that when
76 // capability was introduced.
6af8e417 77 if ($oldversion < 2013021200) {
afd5e85c
RT
78 // If capability mod/forum:allowforcesubscribe is defined then set it for frontpage role.
79 if (get_capability_info('mod/forum:allowforcesubscribe')) {
80 assign_legacy_capabilities('mod/forum:allowforcesubscribe', array('frontpage' => CAP_ALLOW));
81 }
82 // Forum savepoint reached.
6af8e417 83 upgrade_mod_savepoint(true, 2013021200, 'forum');
afd5e85c 84 }
6af8e417 85
a4cdd6d2 86 return true;
b8a342d7 87}
88
1adbd2c3 89